Cybrid Organization API Python Client

0.128.106 · active · verified Thu Apr 16

Cybrid-api-organization-python is the official Python client for the Cybrid Organization API, part of the broader Cybrid cryptocurrency infrastructure platform. It enables programmatic interaction with organizational resources, such as fetching and updating organization details. The library is automatically generated from OpenAPI specifications, ensuring it stays aligned with the API. It is actively maintained, with frequent releases, and the current version is 0.128.106.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure the Cybrid Organization API client, authenticate using an OAuth 2.0 Bearer Token, and fetch the current organization's details. It's crucial to obtain the `CYBRID_BEARER_TOKEN` securely, typically from the Cybrid Sandbox dashboard or Identity Provider, and store it as an environment variable or via a secrets manager.

import os
from cybrid_api_organization import Configuration, ApiClient
from cybrid_api_organization.api.organizations_api import OrganizationsApi
from cybrid_api_organization.exceptions import ApiException

# --- Configuration ---
# Authenticate using an Organization Bearer Token generated from the Cybrid Sandbox or Identity API.
# Never hardcode credentials in your source code.
# Get your Bearer Token (e.g., via OAuth Client Credentials Grant Flow) from Cybrid Identity Provider.
# Example: CYBRID_BEARER_TOKEN = os.environ.get('CYBRID_BEARER_TOKEN', 'YOUR_CYBRID_BEARER_TOKEN')

configuration = Configuration(
    host = os.environ.get('CYBRID_ORGANIZATION_API_URL', 'https://organization.sandbox.cybrid.app/api')
)

# The bearer token should be obtained securely (e.g., from an environment variable or secrets manager).
# This example assumes a pre-fetched bearer token.
BEARER_TOKEN = os.environ.get('CYBRID_BEARER_TOKEN', '') # Replace with actual token retrieval method

if not BEARER_TOKEN:
    print("WARNING: CYBRID_BEARER_TOKEN environment variable not set. API calls may fail.")

configuration.access_token = BEARER_TOKEN

# Create an API client configuration
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = OrganizationsApi(api_client)

    try:
        # Get Organization details
        # The API often implicitly knows the organization from the bearer token.
        # Some endpoints might require a 'guid' if managing multiple organizations
        # or if the token is not organization-scoped.
        organization = api_instance.get_organization()
        print("Successfully fetched Organization details:")
        print(f"Name: {organization.name}")
        print(f"GUID: {organization.guid}")
        print(f"Created At: {organization.created_at}")

    except ApiException as e:
        print(f"Exception when calling OrganizationsApi->get_organization: {e}")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

view raw JSON →