Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Dash_Riprock_UK
Frequent Visitor

Yahoo Finance Power Query Link Not Working

Hello,

I have a spreadsheet which downloads daily currency rates from Yahoo Finance using PowerQuery, for example...

 

= Csv.Document(Web.Contents("https://query1.finance.yahoo.com/v7/finance/download/USDGBP=X?period1=1609459200&period2=1924905600&..."),[Delimiter=",", Columns=7, Encoding=65001, QuoteStyle=QuoteStyle.None])

 

This has been working fine for months, and then today, when I go to refresh, I'm met with a message saying, " We couldn't authenticate with the credentials provided.  Please try again".

 

This information is readily available and doesn't require an account.  So why is this happening now?  Please can anyone help this has broken many months of work (and I've not changed a thing since setting it up and getting it working).

30 REPLIES 30

Hi Guys, Yahoo is on the case, I have been having this issue via Power BI and Power Shell since Friday (possibly Thursday) myself, so I reached out to them since I have a model which took me 1.5 years double full time to build and I was ready to pay for the data; apparently no need to, finger crossed since the market is hot at the moment...

Hi Marco,

Thanks for reaching out to Yahoo Finance.

I apologize for the inconvenience. I understand that you're experiencing issues with the feature to download historical data.

Please know our Engineering team is continuing to work to fix this known issue for you. We know it’s frustrating when things don't work and appreciate your patience while we correct the problem.


If you have any other questions or can provide further information regarding this issue, let us know by replying to this message.

Best,
Lucas
Yahoo Customer Care

Hey that's really GREAT!!! 😀👍

 

I tried contacting them myself, but found out that they make it really hard to get in touch with their support (and it appeared as if you need to be a paying customer as well, but I might be mistaken).

Anyway, thanks to you we at least know that they are aware of the issue. Please keep us posted!!!

Hello Guys, I have an update, I wrote some hours ago but it does not appear to show up...
One bad news and a semigood one.

As you can see from the Yahoo answer yesterday, they were asking for more details if available which I assumed was to help them with the investigation. So I did send them some more information, in particular the 2 ways the issue was showing up, meaning with a M query via Power BI, and via Power Shell.

1) 

Source = Web.Contents(

"https://query1.finance.yahoo.com/v7/finance/download",

[

RelativePath=Symbol,

Query=

[

period1= DateDiff2SecLT, //"1711497601"

period2= DateDiff2SecUT, //"1711584001"

interval="1d"

],

]

)

 

2)

# ► Create $session Object

$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession

 

# ► Call 3rd Url ( Get Yahoo's Data )

try {

$URL = $("https://query1.finance.yahoo.com/v7/finance/download/" + $Stock + "?period1=" + $dateDiff2SecLT + "&period2=" + $dateDiff2SecUT + "&interval=1d")

$ResponseText = Invoke-WebRequest -UseBasicParsing -Uri $URL -WebSession $session

$ResponseText = $ResponseText.ToString()

}

Then I got this meaningless answer:

Hi Marco,

Thank you for writing us back.


I apologize for the inconvenience. It appears that the program you're using is not supported by Yahoo Finance because of this we can't provide additional assistance with your concern.

If you have some suggestions and feedback on ways to improve our product we would love to hear from you. Send us your feedback on the Yahoo Finance Feedback Forum. This feedback helps us develop the future versions of our app.

 

If you have additional questions or concerns, please feel free to contact us again.

Best,
Lucas
Yahoo Customer Care


I asked clarification back again since this was counterminding their previous response but got just an automated reply back.

Then I carried on with the new string that was provided here with "chart", https://query2.finance.yahoo.com/v8/finance/chart/,
which works but of course with completely different format and data returned compared to the one we were discussing. 
Nevertheless the subset of data of the previous one is contained in this latter.

I managed to rewrite power shell to accomodate the result, I am not done yet, as this format I have assumes you pass just 1d as interval, some more arrangements are needed to manage multiple days in the same call, here ChatGPT can be your best friend, but I will post the final one later on.
Also, the date retrived for the set of data, in timestamp format, is much more confusing than the straightforward date retreived by the other connection, but it is manageable after you get the logic.
Data are also not as clean as with the previous connection, some are missing here and there, for instance as I write META symbol is missing for the 9/10 (yesterday)

Here the power shell script if it can be of help, I still have to adapt the M language which I have within a quite complex model. So far the period boundaries are harcoded but you see above the variables that you can adapt as needed.

----------------------------------------------------------------------------------

param(
  [string] $Stock,
  [string] $Cur,
  [string] $CountrySE
)
 
 
$server = "DATAKING"
$database = "Gekko"
$table = "ndsPrices"
$username = 
$password = 
 
$currentDate = Get-Date
$dateDiff = [math]::floor($currentDate.Subtract([datetime]::Parse("1970-01-01")).TotalDays)
$dateDiffSecL = (($dateDiff - 1) * 24 * 60 * 60)
$dateDiffSecU = ($dateDiff * 24 * 60 * 60)
# Lower and upper boundaries for the period in the connection to yahoo
$dateDiff2SecLT = $dateDiffSecL.ToString()
$dateDiff2SecUT = $dateDiffSecU.ToString()
 
 
 
 
 # ► Create $session Object
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
 
 
    # ► Call 3rd Url ( Get Yahoo's Data ) 
 
$URL = $("https://query2.finance.yahoo.com/v8/finance/chart/" + $Stock + "?period1=1725947999&period2=1726012799&interval=1d")
$ResponseText = Invoke-WebRequest -UseBasicParsing -Uri $URL -WebSession $session
$ResponseText = $ResponseText.ToString()
 
$tempFile = [System.IO.Path]::GetTempFileName()
$responseText | Set-Content -Path $tempFile -Encoding UTF8 -Force
 
# Load JSON data
$json = Get-Content -Raw -Path $tempFile | ConvertFrom-Json
 
# Extract relevant data from "indicators" section
 
$unixEpoch = [datetime]"1970-01-01 00:00:00"
 
$date = $unixEpoch.AddSeconds($json.chart.result[0].timestamp[0])
$formattedDate = $date.ToString("MM/dd/yyyy")
 
 
$high = $json.chart.result[0].indicators.quote[0].high[0]
$low = $json.chart.result[0].indicators.quote[0].low[0]
$volume = $json.chart.result[0].indicators.quote[0].volume[0]
$open = $json.chart.result[0].indicators.quote[0].open[0]
$close = $json.chart.result[0].indicators.quote[0].close[0]
$adjclose = $json.chart.result[0].indicators.adjclose[0].adjclose[0]
#$timestamp = [datetime]::FromFileTimeUTC($json.chart.result[0].timestamp[0] * 10000000 + 116444736000000000)
 
# Create SQL connection string
$connectionString = "Data Source=$server;Initial Catalog=$database;User ID=$username;Password=$password;"
 
# Insert data into SQL table
$query = @"
INSERT INTO $table (Symbol, Cur,  CountrySE, Date, DayOpen, DayHigh, DayLow, DayClose, DayAdjClose, DayVolume)
VALUES ('$Stock', '$Cur', '$CountrySE', '$formattedDate'  , $open, $high, $low, $close, $adjclose, $volume)
"@
 
# Execute SQL query
Invoke-Sqlcmd -ServerInstance $server -Database $database -Username $username -Password $password -Query $query
 
 
 
# Create a SQL connection object
$connectionString = "Data Source=$server;Initial Catalog=$database;User ID=$username;Password=$password;"
 
$connection = New-Object System.Data.SqlClient.SqlConnection($connectionString)
 
# Open the SQL connection
$connection.Open()
 
 
# Create a command object
$command = $connection.CreateCommand()
 
 
$command.CommandText = "insert into [ndspricesfull] select [Symbol]
      ,[Cur]
      ,[CountrySE]
      ,[Date]
      ,cast([DayOpen] as numeric(38, 10))
      ,cast([DayHigh] as numeric(38, 10))
      ,cast([DayLow] as numeric(38, 10))
      ,cast([DayClose] as numeric(38, 10))
      ,cast([DayAdjClose] as numeric(38, 10))
      ,cast([DayVolume] as bigint)
  FROM [dbo].[ndsprices] where CountrySE <> 'UK'
  union
  select [Symbol]
      ,[Cur]
      ,[CountrySE]
      ,[Date]
      ,cast([DayOpen] as numeric(38, 10)) / 100
      ,cast([DayHigh] as numeric(38, 10)) / 100
      ,cast([DayLow] as numeric(38, 10)) / 100
      ,cast([DayClose] as numeric(38, 10)) / 100
      ,cast([DayAdjClose] as numeric(38, 10)) / 100
      ,cast([DayVolume] as bigint)
  FROM [dbo].[ndsprices] where CountrySE = 'UK'
 
truncate table [ndsprices]
"
 
# you can get rid of try and catch if not wanted
try{
$command.ExecuteNonQuery()
}
catch {
 
$errorMessage = $_.Exception.Message
$errorDetails = $_.Exception 
 
# Create a SQL connection object
#$connectionString = "Data Source=$server;Initial Catalog=$database;User ID=$username;Password=$password;"
 
#$connection = New-Object System.Data.SqlClient.SqlConnection($connectionString)
 
# Open the SQL connection
#$connection.Open()
 
$cmdText= "INSERT INTO logPricesErr (symbol, err, errDetail) values ('" + $Stock + "', '" + $errorMessage + "', '" + $errorDetails  + "')"
 
# Create a command object
$command = $connection.CreateCommand()
 
# Prepare the SQL command
$command.CommandText = $cmdText
 
 
$command.Connection = $connection
 
$command.ExecuteNonQuery()
 
$command.CommandText = "truncate table [ndsprices]"
 
$command.ExecuteNonQuery()
 
$connection.Close()
 
throw $_
}
 
$connection.Close()
------------------------------------------------------------------------------
 
just get rid of the personal (mine) logic that you do not need and you have the script, please fill up the variables above as it suits you.

Here a cyclical bat file for the call:

set powershellScript=C:\.....\YOURFILENAME.ps1

sqlcmd -S %server% -U %login% -P %password% -d %database% -Q "set nocount on SELECT Symbol, Cur, CountrySE FROM cnfSymbolToLoadDB" -W -h-1 -s "," | FOR /F "tokens=1,2,3 delims=," %%D IN ('MORE') DO (
powershell.exe -ExecutionPolicy Bypass -File %powershellScript% "%%D" "%%E" "%%F"
)


Finally, I do not see why they closed the other connection, which was lighter as with less data retrieved, and left this open (and all the others), if the objective was to put it under a payment wall, also because I explicitely asked them how to pay to get the data, and they did not mind.

Either it was unintentional or I do not know... I still hope it goes back to work. 




 




Hi Guys, I have a lesser joyful update, but with most probably a happy ending.

You can see from the Yahoo email above that they were inviting to give more details on the case if possible, I reckoned to help them on the case. So I did. I gave them both forms that ceased working, with M query and Power Shell, here:

1)

 Source =  Web.Contents(

    "https://query1.finance.yahoo.com/v7/finance/download",

    [

        RelativePath=Symbol,

        Query=

        [

            period1= DateDiff2SecLT, //"1711497601"

            period2= DateDiff2SecUT, //"1711584001"

                    interval="1d"

        ],

    ]

)

 

2)

# ► Create $session Object

$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession

 

    # ► Call 3rd Url ( Get Yahoo's Data )

try {

$URL = $("https://query1.finance.yahoo.com/v7/finance/download/" + $Stock + "?period1=" + $dateDiff2SecLT + "&...

$ResponseText = Invoke-WebRequest -UseBasicParsing -Uri $URL -WebSession $session

$ResponseText = $ResponseText.ToString()

}

 

And then I got this meaningless reply:

Hi Marco, 
 
Thank you for writing us back.

 
I apologize for the inconvenience. It appears that the program you're using is not supported by Yahoo Finance because of this we can't provide additional assistance with your concern.
 
If you have some suggestions and feedback on ways to improve our product we would love to hear from you. Send us your feedback on the Yahoo Finance Feedback Forum. This feedback helps us develop the future versions of our app.

 

If you have additional questions or concerns, please feel free to contact us again. 
 

 
Best, 
Lucas 
Yahoo Customer Care

 

 

 

I replied back again, asking:

 
 

Hi Lucas

 
I wrote you some details about the issue since you had asked, now I am not sure if you are working on the issue I have reported in the first message or not; you wrote me the issue I was signaling, and that everybody else seems to have, was known and you were working on it, are you?
 
From last saturday this query seems to ask for a user to be indicated instead of working with anonymous connection, as it has done for at least February 2023:

"https://query2.finance.yahoo.com/v7/finance/download/" + $Stock + "?period1=1725321599&period2=1725667199&interval=1d"

Hence I asked if from now on it was necessary to have a bronze, silver or gold subscription, you told me it was a known issues you guys were working on, and soon to be solved, do I understand correctly?
Or?

 
 
But got an auto reply message.
 
This is the bad news. The good one is that as IT guys we know the sky is the limit, so I am working on a workaround, the prototype works, I got the data, as soon as I manage (hopefully) to integrate it in my great scheme of things I will post the full script. So annoying wasting time on the tech side when I should be here buying stocks!!



 

This URL will give the same data, but the response is formatted in JSON:

https://query2.finance.yahoo.com/v8/finance/chart/USDGBP=X?period1=1609459200&period2=1924905600&int...

Besides the chart option in the above URL, is it possible to get split, dividend, and market cap data? What should be the label?

Did you find a solution for that ? 

Hello,

Many thanks for your responses, it's much appreciated.

I've never used JSON... I tried the url in PowerQuery, but it's not clear what to do with it.  What are the steps to get this into just a data table? 

Also, my end date is (was) dynamic, i.e. previously, my query would search Yahoo Finance for today's date minus 1 day and return the data.  How does one incorporate that into the query?

Essentially you need to change the source in your query.

 

In Power BI Use Transform Data, select the relevant query then use the Advanced Editor. You will see Source = xxxx

 

Previously the table was contructed as CSV it now needs to be JSON so in my case the source is...

 

Source = Json.Document(Web.Contents("https://query1.finance.yahoo.com/v8/finance/chart/" & StickerSymbol & "?period1=" & StartOfPeriod & "&period2=" & EndOfPeriod & "&interval=1d&events=history&includeAdjustedClose=true"))

Hi @G05DVD ,
Can you please help me?
I tried to follow the above, but unfortunatelly not fully successful.  I am not good at "M".

 

(StockQuote as text) as table =>
let
today = Duration.TotalSeconds(DateTime.LocalNow() - #datetime(1970,1,1,0,0,0)),
lastyear = Duration.TotalSeconds(Date.AddYears(DateTime.LocalNow(),-5) - #datetime(1970,1,1,0,0,0)),
Source = Json.Document(Web.Contents("https://query1.finance.yahoo.com",[RelativePath="v7/finance/download/"&StockQuote&"?period1="&Number.ToText(Number.Round(lastyear))&"&period2="&Number.ToText(Number.Round(today))&"&interval=1d&events=history&includeAdjustedClose=true"]),[Delimiter=",", Columns=7, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type date}, {"Open", type number}, {"High", type number}, {"Low", type number}, {"Close", type number}, {"Adj Close", type number}, {"Volume", Int64.Type}})
in
#"Changed Type"

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors