canapi package

Submodules

canapi.auth module

class canapi.auth.CoinbaseExchangeAuth(api_key, secret_key, passphrase)[source]

Bases: requests.auth.AuthBase

canapi.client module

class canapi.client.ClientAPI(name: str, uri: str, endpoints: dict, root: bool = True, **kwargs)[source]

Bases: object

“A class for building any client api using the information about all of their endpoints.

Parameters:
  • name (str) – Name of the client api.
  • uri (str) – Base uri to use for all endpoints in the api.
  • endpoints (dict) – Available subapis and endpoints for the client.
  • root (bool) – If this api is the root api.
  • kwargs (dict) – Other persistent information to intialize the Session.
apis = {}
auth(**kwargs) → None[source]

Persists authentication information for the client.

persist(**kwargs) → None[source]

Persists given parameters for the client session.

class canapi.client.Endpoint(api: canapi.client.ClientAPI, info: dict)[source]

Bases: object

A class that provides the functionality of accessing and describing an endpoint.

Parameters:
  • api (ClientAPI) – The client api that this endpoint belongs to.
  • info (dict) – Information needed to make a successful request to the endpoint.

canapi.exceptions module

exception canapi.exceptions.ClientAPINotRegistered(name: str, version)[source]

Bases: Exception

Module contents

canapi.api(name: str, version: str = None, use_cache: bool = True, **kwargs) → canapi.client.ClientAPI[source]

Gets the client api associated with name.

If cached is set to True then the client api will be fetched from the ClientAPI.apis dictionary. If it is not exist, then the registry will be searched for files with the associated name. When cached is set to False the registry will always be checked and then be set in the cache.

Parameters:
  • name (str) – Name of the client api.
  • version (str) – Specific version of the client api.
  • use_cache (bool) – Whether or not to use the ClientAPI cache.
  • kwargs (keyword arguments) – Additional keyword arguments to set for the underlying requests.Session.
Returns:

The client api associated with name.

Return type:

ClientAPI

Raises:

ClientAPINotRegistered – If the client api can not be found in the remote and local registries.

canapi.from_config(config: dict) → canapi.client.ClientAPI[source]

Generates a client api from a config dictionary.

Parameters:config (dict) – The configuration dictionary.
Returns:A client api.
Return type:ClientAPI
canapi.from_json(path: str) → canapi.client.ClientAPI[source]

Generates a ClientAPI from a json configuration file.

Parameters:path (str) – The path of the configuration file.
Returns:A client api.
Return type:ClientAPI
canapi.init(path: str) → None[source]

Initializes canapi to search using a specified local registry.

Parameters:path (str) – The path for the local registry.