0

I'm trying to get SPY prices from Yahoo real-time API, the code used to work in the past but now I get this error (below), How can I overcome this problem

library(rjson)    
    json_file <- "http://finance.yahoo.com/webservice/v1/symbols/SPY/quote?format=json&view=detail"
    json_data <- fromJSON(paste(readLines(json_file), collapse=""))
    json_data

I get this error:

"Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open URL 'http://finance.yahoo.com/webservice/v1/symbols/AA/quote?format=json&view=detail': HTTP status was '406 Not Acceptable'
mql4beginner
  • 2,193
  • 5
  • 34
  • 73
  • 1
    I get the same error. It is likely they have moved the API endpoint from when you last ran your code. I noticed there is a Yahoo finance tag. You may want to check there. – Ian Wesley Apr 07 '17 at 14:58

1 Answers1

1

You can use this URL as an alternative. It downloads a CSV format but can be parsed easily. http://download.finance.yahoo.com/d/quotes.csv?s=GOOG+APPL&f=nl1r

Brian
  • 145
  • 1
  • 12