As a web developer, I used Google News Feed API for converting RSS Feed to JSON format. I like more JSON than XML format, because it's easy to parse from my programming languages (Javascript or PHP or Python). Since google announced that they had deprecated this service, I was looking for new service that has ability like Google News Feed API. I opened google.com and type "Google News Feed API Alternative" and I found YQL (Yahoo! Query Language).
YQL has ability to access RSS Feed data with SQL-like commands and parse the result to JSON format. For example, I'll show you how to get feed data from Yahoo! News Top Stories (http://rss.news.yahoo.com/rss/topstories) using jQuery ajax function.
According to the example above, these are some important things to use YQL on your project :
1.
YQL API URL/Endpoint
We have to send a GET request to
https://query.yahooapis.com/v1/public/yql
var yql = 'https://query.yahooapis.com/v1/public/yql'
I'm storing YQL API endpoint in yql Javascript variable
2.
Query
We have to write this query to get feed data from a RSS Feed and send it through
q parameter while we send the GET request :
var query = 'select * from rss where url="http://rss.news.yahoo.com/rss/topstories"'
In this case, I'm storing the query in Javascript query variable. you can learn more about YQL queries/commands on this page :
https://developer.yahoo.com/yql/guide
3.
Response Format
To get JSON format, just send
format parameter with
"json" value while you send the GET request. You can also get XML format by changing
format parameter value by "
xml".
4.
Send GET request with jQuery
This is jQuery code to send our query to YQL endpoint..
$.get(yql, { q : query , format : 'json' } , function(response){ console.log(response)})
5.
Other YQL Parameters
The following table lists will show you other YQL parameters that you can use while send a GET request to YQL endpoint.
6.
YQL console
Try to write your query and get the result instantly on YQL console page :
https://developer.yahoo.com/yql/console/
Finally, I hope that you found the Google News Feed API alternative on this post.
See Ya...
Comments
Post a Comment