Cybrid Identity API Python Client
Cybrid-api-id-python is the official Python client for interacting with the Cybrid Identity APIs. Cybrid provides an all-in-one platform for compliant stablecoins and fiat payment infrastructure, offering crypto liquidity, secure wallet custody, and regulatory compliance. This library, currently at version 0.128.106, is actively maintained with frequent updates, reflecting ongoing development of the Cybrid platform.
Common errors
-
cybrid_api_id.exceptions.ApiException: (401) Reason: Unauthorized - Authentication failed
cause The API request was sent without a valid Bearer Token, or the provided token is expired or malformed.fixEnsure you have obtained a current Bearer Token from the Cybrid Identity Provider and correctly set it in the `Configuration` object's `access_token` field. Verify that the token is not expired. -
cybrid_api_id.exceptions.ApiException: (403) Reason: Forbidden - Invalid scope
cause The Bearer Token used for the API request does not possess the necessary scopes (permissions) to perform the requested operation.fixCheck the Cybrid API documentation for the specific endpoint to determine the required scopes. Generate a new Bearer Token that includes all necessary permissions for the intended API calls. -
cybrid_api_id.exceptions.ApiException: (404) Reason: Not Found
cause The requested resource (e.g., a user by GUID) does not exist, or the endpoint path is incorrect.fixVerify that the GUIDs or identifiers for resources are correct. Double-check the API endpoint path and ensure you're using the correct API class and method for the resource you're trying to access.
Warnings
- gotcha Never expose your Client ID or Client Secret publicly or embed them directly in your source code repository. These credentials are used to obtain Bearer Tokens and should be treated as highly sensitive.
- breaking As an auto-generated OpenAPI client, breaking changes in the underlying Cybrid API specification can lead to breaking changes in the Python client. While efforts are made to maintain backward compatibility, significant API changes may require client updates and code adjustments.
- gotcha Default Bearer Tokens might have broad scopes. Follow the principle of least privilege by requesting and using tokens with the minimum necessary scopes required for your application's operations to limit potential damage from compromised tokens.
- gotcha Directly exposing raw API errors to end-users can leak sensitive internal information. Cybrid API error responses may contain internal identifiers or diagnostic data.
Install
-
pip install cybrid-api-id-python
Imports
- Configuration
from cybrid_api_id.configuration import Configuration
- ApiClient
from cybrid_api_id.api_client import ApiClient
- BankApplicationsApi
from cybrid_api_id.api.bank_applications_api import BankApplicationsApi
- CustomerTokensApi
from cybrid_api_id.api.customer_tokens_api import CustomerTokensApi
- UsersApi
from cybrid_api_id.api.users_api import UsersApi
Quickstart
import os
from cybrid_api_id.configuration import Configuration
from cybrid_api_id.api_client import ApiClient
from cybrid_api_id.api.users_api import UsersApi
from pprint import pprint
# Retrieve Bearer Token from environment variable
# Ensure you obtain a token from the Cybrid platform (Sandbox or Production)
# using your Client ID and Client Secret.
# Example cURL to get token:
# curl -X POST https://id.production.cybrid.app/oauth/token -d '{"client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET","grant_type":"client_credentials","scope":"users:read"}'
CYBRID_BEARER_TOKEN = os.environ.get('CYBRID_BEARER_TOKEN', 'YOUR_BEARER_TOKEN')
if CYBRID_BEARER_TOKEN == 'YOUR_BEARER_TOKEN':
print("WARNING: Please set the CYBRID_BEARER_TOKEN environment variable or replace 'YOUR_BEARER_TOKEN' with a valid token.")
exit()
configuration = Configuration(
host = "https://id.sandbox.cybrid.app", # Use https://id.production.cybrid.app for production
access_token = CYBRID_BEARER_TOKEN
)
with ApiClient(configuration) as api_client:
api_instance = UsersApi(api_client)
try:
# List users
# Requires 'users:read' scope
api_response = api_instance.list_users(page=1, per_page=10)
print("Successfully listed users:")
pprint(api_response)
except Exception as e:
print(f"Exception when calling UsersApi->list_users: {e}")