Code Documentation

class yql.Public(api_key=None, shared_secret=None, httplib2_inst=None)

Class for making public YQL queries


Gets the endpoint for requests

execute(query, params=None, **kwargs)

Execute YQL query


Gets the endpoint for requests


Get endpoint

static get_placeholder_keys(query)

Gets the @var placeholders

get_query_params(query, params, **kwargs)

Get the query params and validate placeholders

get_uri(query, params=None, **kwargs)

Get the the request url


Sets the endpoint and updates the uri

class yql.TwoLegged(api_key, shared_secret, httplib2_inst=None)

Two legged Auth is simple request which is signed prior to sending

static get_base_params()

Set-up the basic parameters needed for a request

get_uri(query, params=None, **kwargs)

Get the the request url

class yql.ThreeLegged(api_key, shared_secret, httplib2_inst=None)

Three-legged Auth is used when it involves private data such as a user’s contacts.

Three-legged auth is most likely to be used in a web-site or web-accessible application. Three-legged auth requires the user to authenticate the request through the Yahoo login.

Three-legged auth requires the implementation to:

  • Request a token
  • Get a authentication url
  • User uses the auth url to login which will redirect to a callback or shows a verfier string on screen
  • Verifier is read at the callback url or manually provided to get the access token
  • resources is access

For an implementation this will require calling the following methods in order the first time the user needs to authenticate

Once the access token has been provided subsequent requests can re-use it.

Access tokens expire after 1 hour, however they can be refreshed with the refresh_token() method


Check to see if a token has expired

get_access_token(token, verifier)

Get the access token

The verifier (required) should have been provided to the user following login to at the url returned by the get_token_and_auth_url() method.

If not you will need need to extract the auth_verifier parameter from your callback url on the site where you are implementing 3-legged auth in order to pass it to this function.

The access token can be stored and re-used for subsequent calls.

The stored token will also need to be refreshed periodically with refresh_token()


First step is to get the token and then send the request that provides the auth URL

Returns a tuple of token and the authorisation URL.

get_uri(query, params=None, **kwargs)

Get the the request url


Access Tokens only last for one hour from the point of being issued.

When a token has expired it needs to be refreshed this method takes an expired token and refreshes it.

token parameter can be either a token object or a token string.

class yql.YQLObj(result_dict)

A YQLObject is the object created as the result of a YQL query


The results count


The query diagnostics


The language


Return just one result directly.


Pretty format the raw data


Pretty print the raw data


The YQL query


The query parameters of the uri used to call the YQL API


The raw data response


The query results dict.


Get a list of rows returned by the query.

Results is a dict with one key but that key changes depending on the results This provides a way of getting at the rows list in an arbitrary way.

Added in version: 0.6 fixes results with 1 item so that they are still returned within a list.


The uri used to query the YQL API


Base class for storage

class, secret=None)

A simple filesystem based token store

Note: this is more intended as an example rather than something for heavy duty production usage.


Get a token from the filesystem


Build filepath

set(name, token)

Write a token to file


Generic token storage

Previous topic

Contributing to Python YQL

Next topic


This Page