0

My application fetches historic data from the yahoo finance using HTTParty.get in ruby on rails.

previously I used the following url

data_source = "http://chart.finance.yahoo.com/table.csv?s=#{ticker}&a=5&b=15&c=2001&d=#{end_date.month - 1}&e=#{end_date.day}&f=#{end_date.year}&g=1d&ignore=.csv"

I found its not working from couple of days and got not found error. So I checked Yahoo finance and updated it accordingly

data_source = "https://query1.finance.yahoo.com/v7/finance/download/#{ticker}?period1=#{start_date}&period2=#{end_date}&interval=1d&events=history&crumb=.zG6G1yJSmP"

After updating I am getting Unauthorized error. Could any one help me out of this.

Regards,

Sreeraj

sreeraj nyros
  • 929
  • 1
  • 6
  • 17
  • You are trying to download the data with an expired cookie (i.e. the part "crumb=.zG6G1yJSmP" in your url). I have the same problem and currently checking here: https://stackoverflow.com/questions/44030983/yahoo-finance-url-not-working/44050039#44050039 how to solve it – ollol333 May 31 '17 at 17:10
  • Please try to download from: https://query1.finance.yahoo.com/v7/finance/chart/GDX?range=max&interval=1d&indicators=quote&includeTimestamps=true&includePrePost=false&corsDomain=finance.yahoo.com It will never asks for cookie or something similar – Balagurunathan Marimuthu Jun 22 '17 at 11:57
  • But, it will give you a response as `JSON` string. You need to parse it and write it into a `csv` file. – Balagurunathan Marimuthu Jun 22 '17 at 11:59

0 Answers0