The YQL Web Service has two URLs. The following URL allows access to public data, which does not require authorization:
http://query.yahooapis.com/v1/public/yql?[query_params]
The next URL requires authorization by OAuth and allows access to both public and private data:
http://query.yahooapis.com/v1/yql?[query_params]
The following URLs are for accessing data from Open Data Tables configured to use YQL streaming. The first URL is used to get public data, and the second requires authorization by OAuth and allows access to both public and private data.
http://query.yahooapis.com/v1/public/streaming/yql
http://query.yahooapis.com/v1/streaming/yql
The public URL has a lower rate limit than the OAuth-protected URL. Therefore, if you plan to use YQL heavily, you should access the OAuth-protected URL.
The following table lists the query parameters for the URLs of the YQL Web Service.
| Query Parameter | Required? | Default | Description |
|---|---|---|---|
q
|
Yes | (none) | The YQL statement to execute, such as SELECT. |
format
|
No |
xml
|
The format of the results of the call to the YQL Web Service. Allowed values: xml or json.
|
callback
|
No | (none) | The name of the JavaScript callback function for JSONP format. If callback is set and if format=json, then the response format is JSON. For more information on using XML instead of JSON, see JSONP-X.
|
crossProduct
|
No | (none) | When given the value optimized, the projected fields in SELECT statements that may be returned in separate item elements in the response are optimized to be in a single item element instead. See Optimizing the Response for more information.
|
diagnostics
|
No |
true
|
Diagnostic information is returned with the response unless this parameter is set to false.
|
debug
|
No | (none) |
Enables network-level logging of each network call within a YQL statement or API query. For more information, see, Logging Network Calls in Open Data Tables. |
env
|
No | (none) | Allows you to use multiple Open Data Tables through a YQL environment file. |
jsonCompat
|
No | (none) | Enables lossless JSON processing. The only allowed value is new. See JSON-to-JSON Transformation.
|
To make YQL Web Service queries easier to remember and share, you can shorten them with query aliases. Take for example a normal YQL REST query:
http://query.yahooapis.com/v1/yql?q=select+*+from+weather.forecast+where+location%3D%40zip
The corresponding query alias can look like this:
http://query.yahooapis.com/v1/public/yql/jonathan/weather?zip=94025
The easiest way to create query aliases is through the YQL console, though you can also use some of the more advanced functions through the yql.queries and yql.queries.query tables.
To create a short query alias based on a statement, follow these steps:
http://query.yahooapis.com/v1/public/yql/prefix/
If you decide later that you want to start over with a new prefix for your query aliases, you can run the following YQL statement to delete your existing prefix:
delete from yql.queries
Keep in mind that deleting your prefix also deletes all its associated query aliases.
http://query.yahooapis.com/v1/public/yql/prefix/alias/
All of your saved query aliases appear along the right side the YQL console under the Query Aliases heading. There, you can click on a alias name to see it in the REST query box. You can also click on the red X next to a particular alias name to delete it.
Query aliases support variable substitution
using the @ symbol. For example, the following YQL statement searches for questions about poetry that contain the name Auden:
select * from answers.search where query="Auden" and category_id=2115500137 and type="resolved"
Using variable substitution, you can replace Auden with the
variable poet. Here is an example:
select * from answers.search where query=@poet and category_id=2115500137 and type="resolved"
A corresponding query alias with the required parameter can look like this:
http://query.yahooapis.com/v1/public/yql/prefix/poet_questions?poet="Auden"