Code Documentation

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

Class for making public YQL queries

endpoint

Gets the endpoint for requests

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

Execute YQL query

get_endpoint()

Gets the endpoint for requests

get_endpoint_uri()

Get endpoint

static get_placeholder_keys(query)

Gets the @var placeholders

http://developer.yahoo.com/yql/guide/var_substitution.html

get_query_params(query, params, **kwargs)

Get the query params and validate placeholders

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

Get the the request url

set_endpoint(value)

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_token(token)

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()

get_token_and_auth_url(callback_url=None)

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

refresh_token(token)

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

count

The results count

diagnostics

The query diagnostics

lang

The language

one()

Return just one result directly.

pformat_raw(indent=4)

Pretty format the raw data

pprint_raw(indent=4)

Pretty print the raw data

query

The YQL query

query_params

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

raw

The raw data response

results

The query results dict.

rows

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.

uri

The uri used to query the YQL API

class yql.storage.BaseTokenStore

Base class for storage

class yql.storage.FileTokenStore(dir_path, 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(name)

Get a token from the filesystem

get_filepath(name)

Build filepath

set(name, token)

Write a token to file

exception yql.storage.TokenStoreError

Generic token storage

Previous topic

Contributing to Python YQL

Next topic

License

This Page