YQL Streaming

In general, when a YQL statement references an Open Data Table, the YQL Web service will make an HTTP call based on the URLs listed in the bindings element or execute the JavaScript in the execute element. To get updated results from the YQL Web service, you need to execute this YQL statement again. YQL streaming allows you to get updated results in a different way.

With YQL streaming, your Open Data Table can request YQL to poll data from your resource URI at a specified interval, process the responses, and return the results to the client, without the client having to execute the same YQL statements over and over again to get the updated results; this will reduce network latency and the need to store responses.

Configuring Open Data Tables to Use Streaming

To request streaming in your Open Data Table, you use the pollingFrequencySeconds attribute of the select binding to specify the interval that you want YQL to make requests. For example, the code snippet below configures YQL to poll the URL for Foursquare search every two seconds:

Note

When setting a polling frequency with pollingFrequencySeconds, try to match the update frequency of your data source. If you configure YQL to poll the source every two seconds, but the source usually updates data every minute, you will be increasing the network latency for YQL without the benefit of getting new data.

Using Open Data Tables Configured for Streaming

To use Open Data Tables that are configured for streaming, you must call the YQL Web Service URLs for streaming. You use YQL statements and invoke the Open Data Table in the same way as you would for any Open Data Table.

The following YQL Service URL is used to get public data from an Open Data Table that is configured to use YQL streaming:

http://query.yahooapis.com/v1/public/streaming/yql

The YQL Service URL below requires authorization by OAuth and allows access to both public and private data from an Open Data Table that is configured to use YQL streaming:

http://query.yahooapis.com/v1/streaming/yql

The following PHP code snippet shows how to get public data from the Open Data Table books_warehouse.xml that is configured to use YQL streaming:

Table of Contents