data from API (read_lines())


I'm new to shiny. My first project is to build an app that displays the NBA scores for a user selected date. It works perfectly when I run it on a local machine but does not work when I deploy to

I debugged it so far that I found what is not working. Apparently the app does not read the data from the NBA API.

Here is a code sample of what I'm doing:


ui <- fluidPage(

  # Application title
  titlePanel("Get NBA Scores"),

  # Select date
      dateInput(inputId = "date",
                label = "Select Date")


server <- function(input, output) {

  date <- reactiveValues()
  url <- reactiveValues()
  nba <- reactiveValues()

  # add leading zero to day
  observe(date$day <- ifelse(nchar(day(as.character(input$date))) == 1, paste0("0", day(as.character(input$date))), day(as.character(input$date))))

  # add leading zero to month
  observe(date$month <- ifelse(nchar(month(as.character(input$date))) == 1, paste0("0", month(as.character(input$date))), month(as.character(input$date))))

  # extract year
  observe(date$year <- year(as.character(input$date)))

  # create url
  observe(url$url1 <- glue("{date$month}/{date$day}/{date$year}&LeagueID=00&DayOffset=0"))

  #import data
  observe(nba$nba <- read_lines(url$url1))

  output$boxscores <- renderText({
    #plot raw data

# Run the application 
shinyApp(ui = ui, server = server)

When I just want to display the url using

output$boxscores <- renderText({
  #plot url

it works fine. But when I want to get the external data it does not show anything (not even an error).

Am i doing something wrong? Or is it not possible to read external data on

Thanks for your help.

Yes it is possible to read external data from

However, is hosted in AWS, and from I am reading, NBA stats is explicitly blocking AWS IP addresses. Sorry I don't have better news.

Thanks for the information.
Then I will think of another way to build this app.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.