node-yql is a YQL client for node.js
Yahoo! Query Language is an expressive SQL-like language that lets you query, filter, and join data across Web services. With YQL, apps run faster with fewer lines of code and a smaller network footprint.
Yahoo! and other websites across the Internet make much of their structured data available to developers, primarily through Web services. To access and query these services, developers traditionally endure the pain of locating the right URLs and documentation to access and query each Web service.
With YQL, developers can access and shape data across the Internet through one simple language, eliminating the need to learn how to call different APIs.
- SELECT title,abstract FROM search.web WHERE query="pizza";
- SELECT * FROM weather.forecast WHERE location = 90066;
- SELECT * FROM twitter.user.timeline WHERE id = 'yql';
- SELECT * FROM flickr.photos.interestingness(20);
You may find more examples at the YQL console
First, make sure you have Node installed. You can find instructions for installing it at http://nodejs.org/#download
With Node installed, you can install the node-yql module 2 ways:
-
The easiest method is to use NPM, node's package manager. Once you have NPM installed, simply run:
$ npm install yql
-
Or, you can clone the github repository, and just be sure you add this module's path to the $NODE_PATH env variable
$ git clone http://github.com/drgath/node-yql.git
A basic example
var YQL = require('yql');
YQL("SELECT * FROM weather.forecast WHERE (location = @zip)").exec({"zip": 94089}, function (error, results) {
if (error) throw error;
var location = results.channel.location,
condition = results.channel.item.condition;
console.log("The current weather in " + location.city + ', ' +
location.region + " is " + condition.temp + " degrees and " + condition.text);
});
$ node example.js
The current weather in Sunnyvale, CA is 47 degrees and Fair
- query - A YQL query
- options
- ssl: A boolean true/false flag to enable HTTPS (default:
false
) - headers: Object of valid HTTP headers (default
{}
) - env: Environment files (default:
http://datatables.org/alltables.env
)
- params - Parameters for variable replacement within the YQL statement.
- callback - A callback function that receives the result of the query
- Documentation: http://developer.yahoo.com/yql/guide/
- YQL Console: http://developer.yahoo.com/yql/console/