How to get yahoo finance stock data? - yahoo-finance

I have created and API on deevloper.yahoo.com and in yql console https://developer.yahoo.com/yql/console.
Tick show community table and search for finance.
I got result of stock data.Here I got exact data for historical data in josn and xml format.
Link for historical data yahoo.finance.historicaldata.
like I got all data
http://finance.yahoo.com/q/hp?s=AAPL+Historical+Prices and rest query for this stock is
yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22YHOO%22%20and%20startDate%20%3D%20%222009-09-11%22%20and%20endDate%20%3D%20%222010-03-10%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=
when I try to other stocks like yahoo.finance.balancesheet and other stock
I see the parameter I send in url is wrong specially where condition in other stock option
Can any one tell what will be exact url for other stock option.

What you appear to want is:
https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.historicaldata where symbol = "YHOO" and startDate = "2009-09-11" and endDate = "2010-03-10"&format=json&diagnostics=true&env=store://datatables.org/alltableswithkeys&callback=
You can feed that URL to, for instance, wget, and it will return a blob of JSON.
Where did I get that URL? I started the YQL Console with Show Community Tables checked. Next, I entered your query (the q parameter in the above) and received back valid looking JSON. Finally, I went down to the bottom of the page, where it says THE REST QUERY in green, and copied the URL out of the box.

Related

Exact text searches with the Microsoft Graph API

Can we do exact text searches using the the Microsoft Graph API?
I know the endpoint for search is:
GET /me/drive/root/search(q='{search-query}')
The documentation is unclear about what to pass into the search query (q) parameter.
The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content.
I have tried double quote formats
https://graph.microsoft.com/v1.0/me/drive/root/search(q='"Bob Bowen"')
and '+' formats
https://graph.microsoft.com/v1.0/me/drive/root/search(q='Bob+Bowen')
I'm running these queries using the "Try it" button on the Microsoft Graph Explorer and I'm expecting them to return nothing because the words "Bob Bowen" shouldn't exist in the sample drive. But I'm always getting some document hits, because the exact text search isn't working.
I just happened to have
IDriveItemSearchRequestBuilder searchRequest = graphServiceClient.Me.Drive.Root.Search(searchFile);
var searchResult = searchRequest.Request().GetAsync().Result.ToList();
In other variants, authorization error

Specify target worksheet in structured query of Google Sheets data

I am trying to query data from one of my google spreadsheets, and I have read the docs here.
My spreadsheet has two tabs/sheets. I can query data from the first sheet, but I can't figure out how to query data from the second sheet.
My query url looks like this:
https://docs.google.com/spreadsheets/d/[SpreadSheetId]/gviz/tq?tq=[query]
If I open the sheet in a browser I can see the sheet Id in the browser url:
https://docs.google.com/spreadsheets/d/[SpreadSheetId]/edit#gid=[SheetId]
Is there any way to specify this sheetId in the query url? I have tried adding various versions of /#gid=[sheetId] to my query url but it returns the full html of the page, not the json I expect.
The answer is:
https://docs.google.com/spreadsheets/d/[spreadSheetId]/gviz/tq?gid=[sheetId]&tq=[query]
Credits to tehhowch for pointing me in the right direction!

YQL not returning data from balance sheet or income statement

I have been trying to use YQL to access the fundamentals of listed companies. But what is showing up in the Yahoo finance page is not being returned from YQL queries. Specifically I need to retrieve data from balance sheet and income statement, a sample query for Apple in YQL is like:
SELECT * FROM yahoo.finance.balancesheet WHERE symbol='AAPL'
This, however, only returns a time frame (quarterly), and nothing else.
Link to YQL console of my sample query is here
Is the data inaccessible to YQL or is there anything wrong with the way I am running the query? How can I get a complete list of data as in http://finance.yahoo.com/q/bs?s=AAPL through YQL?
Your query used to work fine. However, a month or two ago, a number of yahoo.finance YQL "tables" stopped working.
IOW, you are doing it right, but YQL is broken.
If you mouse over the yahoo.finance.balancesheet entry in the left column of the YQL console, buttons labeled desc and src appear. If you click src, it fetches the scraping code for you: http://www.datatables.org/yahoo/finance/yahoo.finance.balancesheet.xml. To make the E4X JavaScript legible, right-click and select View Source or use wget or curl from the command line.
Notice that the code fetches http://finance.yahoo.com/q/bs?s=AAPL&quarterly and then uses an XPath query to find the data:
var query = y.xpath(rawresult, "//table[#class='yfnc_tabledata1']/tr/td/table/tr");
If you fetch the page into your browser and inspect the HTML, you find that there is indeed a table with class yfnc_tabledata1. However, it has no tr direct child. Apparently, Yahoo must have decided to add a tbody element. That probably explains why the query no longer scrapes any data.
The code page lists Ryan Hoium as the author. A little googling leads to the github repository where the code lives, alongside the code for the other Yahoo Finance tables.
Sadly, only the yahoo.finance.sectors table has received recent attention. The change was to add double slashes to its XPath expression. Double-slashes relax the "direct child" requirement, allowing, for example, tr to still be found even if there is an intervening tbody. However, it appears the new version has not been pushed out to the public site.

Getting block data from YQL

I read up on YQL. However i'm at a loss on how to get blocks of data.
I can get individual stock data fine but how do you get collated data like the FTSE 100 shares, without having to find the symbol for each 100 shares and pulling that data in individually?
Ideally i would have the hundred shares with each of their bits of data.
Thanks in advance,
Ewan
looks like you are right that only one stock can be queried at a time. since the api is restful, you can easily use a for loop in bash and curl all the stocks.
Whenever we query YQL table we need to give the SYMBOLS (tickers) as inputs. However there is a limit to the number of symbols you can enter in one go.
I created an Excel sheet where I read a list of symbols from a sheet and then query with YQL and dump the data in another sheet.
Let's assume you want to pull out historical prices with the following specifications:
Symbol/Ticker : symbol
StartDate
EndDate
The corresponding weblink to extract this info would be (in VBA syntax)
"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20in%20%28%27 " & symbol & "%27%29%20and%20startDate%20=%20%27" & startDate & "%27%20and%20endDate%20=%20%27" & endDate & "%27&diagnostics=true&env=store://datatables.org/alltableswithkeys"
You can find the Excel sheet present at my blog.

Google Drive Api not returning results by descending order of number of occurrences of word

I am using Google Documents List API for searching within documents.
Searching on the google drive ui returns results with most number of occurences of words first. But with api it returns the results with last uploaded date first.
This is the URL which i am using https://docs.google.com/feeds/default/private/full?q=search+term
I also tried with https://docs.google.com/feeds/default/private/full?q=search+term&desc=true but this gave the same results that we were getting earlier i.e. by last uploaded date first.
Can someone guide me with what additional parameters i should be adding to the url
You can use the orderBy query parameter to order the Documents List Feed by certain criteria:
last-modified: Default value, sort by last modified date.
last-accessed: sort by last accessed date.
title: sort by title (this is what you're looking for.
starred: sort documents by their "starred" attribute.

Resources