openbankproject_client.client module

OpenBankProject API Client

This module provides a comprehensive client for interacting with the OpenBankProject API v5.1.0. It includes support for all API endpoints, authentication methods, and error handling.

class openbankproject_client.client.OpenBankProjectClient(base_url: str = 'https://api.openbankproject.com', api_version: str = 'v5.1.0', direct_login_token: str | None = None, username: str | None = None, password: str | None = None, consumer_key: str | None = None, gateway_login_token: str | None = None, timeout: int = 30)[source]

Bases: object

Client for the OpenBankProject API.

This client provides access to all API endpoints and handles authentication, request formatting, and error handling.

__init__(base_url: str = 'https://api.openbankproject.com', api_version: str = 'v5.1.0', direct_login_token: str | None = None, username: str | None = None, password: str | None = None, consumer_key: str | None = None, gateway_login_token: str | None = None, timeout: int = 30)[source]

Initialize the OpenBankProject API client.

Parameters:
  • base_url – Base URL of the API server

  • api_version – API version to use

  • direct_login_token – Pre-generated DirectLogin token (if available)

  • username – Username for DirectLogin authentication

  • password – Password for DirectLogin authentication

  • consumer_key – Consumer key for DirectLogin authentication

  • gateway_login_token – Pre-generated GatewayLogin token (if available)

  • timeout – Request timeout in seconds

_build_url(endpoint: str) str[source]

Build a full URL for the given endpoint.

Parameters:

endpoint – API endpoint path

Returns:

Full URL including base URL and API version

_handle_response(response: Response) Dict[source]

Handle API response and raise appropriate exceptions for errors.

Parameters:

response – Response object from requests

Returns:

Parsed JSON response as dictionary

Raises:
request(method: str, endpoint: str, **kwargs) Dict[source]

Make a request to the API.

Parameters:
  • method – HTTP method (GET, POST, PUT, DELETE)

  • endpoint – API endpoint path

  • **kwargs – Additional arguments to pass to requests

Returns:

Parsed JSON response as dictionary

Raises:

Various exceptions based on API response

get(endpoint: str, **kwargs) Dict[source]

Make a GET request to the API.

Parameters:
  • endpoint – API endpoint path

  • **kwargs – Additional arguments to pass to requests

Returns:

Parsed JSON response as dictionary

post(endpoint: str, **kwargs) Dict[source]

Make a POST request to the API.

Parameters:
  • endpoint – API endpoint path

  • **kwargs – Additional arguments to pass to requests

Returns:

Parsed JSON response as dictionary

put(endpoint: str, **kwargs) Dict[source]

Make a PUT request to the API.

Parameters:
  • endpoint – API endpoint path

  • **kwargs – Additional arguments to pass to requests

Returns:

Parsed JSON response as dictionary

delete(endpoint: str, **kwargs) Dict[source]

Make a DELETE request to the API.

Parameters:
  • endpoint – API endpoint path

  • **kwargs – Additional arguments to pass to requests

Returns:

Parsed JSON response as dictionary

authenticate() bool[source]

Authenticate with the API if not already authenticated.

Returns:

True if authentication was successful

Raises:

AuthenticationError – If authentication fails