cdp.client package

Subpackages

Submodules

cdp.client.api_client module

Coinbase Platform API

This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.

The version of the OpenAPI document: 0.0.1-alpha Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.

class cdp.client.api_client.ApiClient(configuration=None, header_name=None, header_value=None, cookie=None)

Bases: object

Generic API client for OpenAPI client library builds.

OpenAPI generic API client. This client handles the client- server communication, and is invariant across implementations. Specifics of the methods and models for each application are generated from the OpenAPI templates.

Parameters:
  • configuration – .Configuration object for this client

  • header_name – a header to pass when making calls to the API.

  • header_value – a header value to pass when making calls to the API.

  • cookie – a cookie to include in the header when making calls to the API

NATIVE_TYPES_MAPPING = {'bool': <class 'bool'>, 'date': <class 'datetime.date'>, 'datetime': <class 'datetime.datetime'>, 'decimal': <class 'decimal.Decimal'>, 'float': <class 'float'>, 'int': <class 'int'>, 'long': <class 'int'>, 'object': <class 'object'>, 'str': <class 'str'>}
PRIMITIVE_TYPES = (<class 'float'>, <class 'bool'>, <class 'bytes'>, <class 'str'>, <class 'int'>)
call_api(method, url, header_params=None, body=None, post_params=None, _request_timeout=None)

Makes the HTTP request (synchronous) :type method: :param method: Method to call. :type url: :param url: Path to method endpoint. :type header_params: :param header_params: Header parameters to be

placed in the request header.

Parameters:
  • body – Request body.

  • dict (post_params) – Request post form parameters, for application/x-www-form-urlencoded, multipart/form-data.

  • _request_timeout – timeout setting for this request.

Return type:

RESTResponse

Returns:

RESTResponse

deserialize(response_text, response_type, content_type)

Deserializes response into an object.

Parameters:
  • response – RESTResponse object to be deserialized.

  • response_type (str) – class literal for deserialized object, or string of class name.

  • content_type (Optional[str]) – content type of response.

Returns:

deserialized object.

files_parameters(files)

Builds form parameters.

Parameters:

files (Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]]) – File parameters.

Returns:

Form parameters with files.

classmethod get_default()

Return new instance of ApiClient.

This method returns newly created, based on default constructor, object of ApiClient class or returns a copy of default ApiClient.

Returns:

The ApiClient object.

param_serialize(method, resource_path, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, auth_settings=None, collection_formats=None, _host=None, _request_auth=None)

Builds the HTTP request params needed by the request. :type method: :param method: Method to call. :type resource_path: :param resource_path: Path to method endpoint. :type path_params: :param path_params: Path parameters in the url. :type query_params: :param query_params: Query parameters in the url. :type header_params: :param header_params: Header parameters to be

placed in the request header.

Parameters:
  • body – Request body.

  • dict (files) – Request post form parameters, for application/x-www-form-urlencoded, multipart/form-data.

  • list (auth_settings) – Auth Settings names for the request.

  • dict – key -> filename, value -> filepath, for multipart/form-data.

  • collection_formats – dict of collection formats for path, query, header, and post parameters.

  • _request_auth – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.

Return type:

Tuple[str, str, Dict[str, str], Optional[str], List[str]]

Returns:

tuple of form (path, http_method, query_params, header_params, body, post_params, files)

parameters_to_tuples(params, collection_formats)

Get parameters as list of tuples, formatting collections.

Parameters:
  • params – Parameters as dict or list of two-tuples

  • collection_formats (dict) – Parameter collection formats

Returns:

Parameters as list of tuples, collections formatted

parameters_to_url_query(params, collection_formats)

Get parameters as list of tuples, formatting collections.

Parameters:
  • params – Parameters as dict or list of two-tuples

  • collection_formats (dict) – Parameter collection formats

Returns:

URL query string (e.g. a=Hello%20World&b=123)

response_deserialize(response_data, response_types_map=None)

Deserializes response into an object. :type response_data: RESTResponse :param response_data: RESTResponse object to be deserialized. :type response_types_map: Optional[Dict[str, TypeVar(T)]] :param response_types_map: dict of response types. :rtype: ApiResponse :return: ApiResponse

sanitize_for_serialization(obj)

Builds a JSON POST object.

If obj is None, return None. If obj is SecretStr, return obj.get_secret_value() If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date

convert to string in iso8601 format.

If obj is decimal.Decimal return string representation. If obj is list, sanitize each element in the list. If obj is dict, return the dict. If obj is OpenAPI model, return the properties dict.

Parameters:

obj – The data to serialize.

Returns:

The serialized form of data.

select_header_accept(accepts)

Returns Accept based on an array of accepts provided.

Parameters:

accepts (List[str]) – List of headers.

Return type:

Optional[str]

Returns:

Accept (e.g. application/json).

select_header_content_type(content_types)

Returns Content-Type based on an array of content_types provided.

Parameters:

content_types – List of content-types.

Returns:

Content-Type (e.g. application/json).

classmethod set_default(default)

Set default instance of ApiClient.

It stores default ApiClient.

Parameters:

default – object of ApiClient.

set_default_header(header_name, header_value)
update_params_for_auth(headers, queries, auth_settings, resource_path, method, body, request_auth=None)

Updates header and query params based on authentication setting.

Parameters:
  • headers – Header parameters dict to be updated.

  • queries – Query parameters tuple list to be updated.

  • auth_settings – Authentication setting identifiers list.

Return type:

None

Resource_path:

A string representation of the HTTP request resource path.

Method:

A string representation of the HTTP request method.

Body:

A object representing the body of the HTTP request.

The object type is the return value of sanitize_for_serialization(). :type request_auth: :param request_auth: if set, the provided settings will

override the token in the configuration.

property user_agent

User agent for this API client

cdp.client.api_response module

API response object.

class cdp.client.api_response.ApiResponse(**data)

Bases: BaseModel, Generic[T]

API response object

data: T
headers: Optional[Mapping[str, str]]
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

raw_data: StrictBytes
status_code: StrictInt

cdp.client.configuration module

Coinbase Platform API

This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.

The version of the OpenAPI document: 0.0.1-alpha Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.

class cdp.client.configuration.Configuration(host=None, api_key=None, api_key_prefix=None, username=None, password=None, access_token=None, server_index=None, server_variables=None, server_operation_index=None, server_operation_variables=None, ignore_operation_servers=False, ssl_ca_cert=None, retries=None, *, debug=None)

Bases: object

This class contains various settings of the API client.

Parameters:

host – Base url.

:param ignore_operation_servers

Boolean to ignore operation servers for the API client. Config will use host as the base url regardless of the operation servers.

Parameters:
  • api_key – Dict to store API key(s). Each entry in the dict specifies an API key. The dict key is the name of the security scheme in the OAS specification. The dict value is the API key secret.

  • api_key_prefix – Dict to store API prefix (e.g. Bearer). The dict key is the name of the security scheme in the OAS specification. The dict value is an API key prefix when generating the auth data.

  • username – Username for HTTP basic authentication.

  • password – Password for HTTP basic authentication.

  • access_token – Access token.

  • server_index – Index to servers configuration.

  • server_variables – Mapping with string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before.

  • server_operation_index – Mapping from operation ID to an index to server configuration.

  • server_operation_variables – Mapping from operation ID to a mapping with string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before.

  • ssl_ca_cert – str - the path to a file of concatenated CA certificates in PEM format.

  • retries – Number of retries for API requests.

access_token

Access token

assert_hostname

Set this to True/False to enable/disable SSL hostname verification.

auth_settings()

Gets Auth Settings dict for api client.

Returns:

The Auth Settings information dict.

cert_file

client certificate file

connection_pool_maxsize

urllib3 connection pool’s maximum number of connections saved per pool. urllib3 uses 1 connection as default value, but this is not the best value when you are making a lot of possibly parallel requests to the same host, which is often the case here. cpu_count * 5 is used as default value to increase performance.

date_format

date format

datetime_format

datetime format

property debug

Debug status

Parameters:

value – The debug status, True or False.

Type:

bool

get_api_key_with_prefix(identifier, alias=None)

Gets API key (with prefix if set).

Parameters:
  • identifier – The identifier of apiKey.

  • alias – The alternative identifier of apiKey.

Returns:

The token for api key authentication.

get_basic_auth_token()

Gets HTTP basic authentication header (string).

Returns:

The token for basic HTTP authentication.

classmethod get_default()

Return the default configuration.

This method returns newly created, based on default constructor, object of Configuration class or returns a copy of default configuration.

Returns:

The configuration object.

classmethod get_default_copy()

Deprecated. Please use get_default instead.

Deprecated. Please use get_default instead.

Returns:

The configuration object.

get_host_from_settings(index, variables=None, servers=None)

Gets host URL based on the index and variables :type index: :param index: array index of the host settings :type variables: :param variables: hash of variable and the corresponding value :type servers: :param servers: an array of host settings or None :return: URL based on host settings

get_host_settings()

Gets an array of host settings

Returns:

An array of host settings

property host

Return generated host.

ignore_operation_servers

Ignore operation servers

key_file

client key file

logger

Logging Settings

property logger_file

Debug file location

logger_file_handler: Optional[FileHandler]

Log file handler

property logger_format

Log format

logger_stream_handler

Log stream handler

password

Password for HTTP basic authentication

proxy: Optional[str]

Proxy URL

proxy_headers

Proxy headers

refresh_api_key_hook

function hook to refresh API key if expired

retries

Adding retries to override urllib3 default value 3

safe_chars_for_path_param

Safe chars for path_param

server_operation_index

Default server index

server_operation_variables

Default server variables

classmethod set_default(default)

Set default instance of configuration.

It stores default configuration, which can be returned by get_default_copy method.

Parameters:

default – object of Configuration

socket_options

Options to pass down to the underlying urllib3 socket

ssl_ca_cert

Set this to customize the certificate file to verify the peer.

temp_folder_path

Temp file folder for downloading files

tls_server_name

SSL/TLS Server Name Indication (SNI) Set this to the SNI value expected by the server.

to_debug_report()

Gets the essential information for debugging.

Returns:

The report for debugging.

username

Username for HTTP basic authentication

verify_ssl

SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server.

cdp.client.exceptions module

Coinbase Platform API

This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.

The version of the OpenAPI document: 0.0.1-alpha Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.

exception cdp.client.exceptions.ApiAttributeError(msg, path_to_item=None)

Bases: OpenApiException, AttributeError

exception cdp.client.exceptions.ApiException(status=None, reason=None, http_resp=None, *, body=None, data=None)

Bases: OpenApiException

classmethod from_response(*, http_resp, body, data)
Return type:

Self

exception cdp.client.exceptions.ApiKeyError(msg, path_to_item=None)

Bases: OpenApiException, KeyError

exception cdp.client.exceptions.ApiTypeError(msg, path_to_item=None, valid_classes=None, key_type=None)

Bases: OpenApiException, TypeError

exception cdp.client.exceptions.ApiValueError(msg, path_to_item=None)

Bases: OpenApiException, ValueError

exception cdp.client.exceptions.BadRequestException(status=None, reason=None, http_resp=None, *, body=None, data=None)

Bases: ApiException

exception cdp.client.exceptions.ForbiddenException(status=None, reason=None, http_resp=None, *, body=None, data=None)

Bases: ApiException

exception cdp.client.exceptions.NotFoundException(status=None, reason=None, http_resp=None, *, body=None, data=None)

Bases: ApiException

exception cdp.client.exceptions.OpenApiException

Bases: Exception

The base exception class for all OpenAPIExceptions

exception cdp.client.exceptions.ServiceException(status=None, reason=None, http_resp=None, *, body=None, data=None)

Bases: ApiException

exception cdp.client.exceptions.UnauthorizedException(status=None, reason=None, http_resp=None, *, body=None, data=None)

Bases: ApiException

cdp.client.exceptions.render_path(path_to_item)

Returns a string representation of a path

cdp.client.rest module

Coinbase Platform API

This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.

The version of the OpenAPI document: 0.0.1-alpha Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.

class cdp.client.rest.RESTClientObject(configuration)

Bases: object

request(method, url, headers=None, body=None, post_params=None, _request_timeout=None)

Perform requests.

Parameters:
  • method – http request method

  • url – http request url

  • headers – http request headers

  • body – request json body, for application/json

  • post_params – request post parameters, application/x-www-form-urlencoded and multipart/form-data

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

class cdp.client.rest.RESTResponse(resp)

Bases: IOBase

getheader(name, default=None)

Returns a given response header.

getheaders()

Returns a dictionary of the response headers.

read()
cdp.client.rest.is_socks_proxy_url(url)

Module contents

Coinbase Platform API

This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.

The version of the OpenAPI document: 0.0.1-alpha Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.