I need to get data using API, but my code cannot open the connection. I would appreciate if you could let me know how to resole this error. I am using my own laptop. Besides, I do not have any proxy based on my settings->proxy.
Code:
library(tidyquant)
library(jsonlite)
library(tidyverse)
library(readr)
library(igraph)
library(dplyr)
library(lubridate)
library(data.table)
Sp500 <- tq_index("SP500") %>% add_column(exchange = "SP500")
sp400 <- tq_index("SP400") %>% add_column(exchange = "SP400")
sp600 <- tq_index("SP600") %>% add_column(exchange = "SP600")
NASDAQ <-tq_exchange("NASDAQ") %>% add_column(exchange = "NASDAQ")
NYSE<-tq_exchange("NYSE")%>% add_column(exchange = "NYSE")
#Rus2000 <- tq_index("RUSSELL2000") %>% add_column(exchange = "RUSSELL2000")
#Rus1000 <- tq_index("RUSSELL1000") %>% add_column(exchange = "RUSSELL1000")
tickers <- rbind(NASDAQ,NYSE)
str(tickers)
Error:
NASDAQ <-tq_exchange("NASDAQ") %>% add_column(exchange = "NASDAQ")
Getting data...
Error in open.connection(con, "rb") :
cannot open the connection to 'https://api.nasdaq.com/api/screener/stocks?tableonly=true&exchange=nasdaq&download=true'
In addition: Warning message:
In open.connection(con, "rb") :
URL 'https://api.nasdaq.com/api/screener/stocks?tableonly=true&exchange=nasdaq&download=true': Timeout of 60 seconds was reached