### Quick Start Example Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/COMPLETION_REPORT.txt Illustrates basic setup and usage of the Cybrid Bank API client for a quick start. ```typescript import { CybridBankApi } from "@cybrid/bank-api-typescript"; const api = new CybridBankApi({ // Configuration options // e.g., apiKey: "YOUR_API_KEY", // apiSecret: "YOUR_API_SECRET", // baseUrl: "https://api.cybrid.com" }); async function main() { try { const accounts = await api.accounts.listAccounts({ // Query parameters }); console.log(accounts); } catch (error) { console.error("Error fetching accounts:", error); } } main(); ``` -------------------------------- ### Get All Examples Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/README.md Use grep to extract all examples from the markdown files. This command retrieves the example code along with the 5 lines following it, useful for understanding code usage. ```bash # Get all examples grep -A 5 "Example:" *.md ``` -------------------------------- ### Complete Onboarding Workflow Example Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/COMPLETION_REPORT.txt Illustrates a multi-step process for customer onboarding, including creating a customer, opening an account, and setting up initial funding. This example showcases chaining multiple API calls to achieve a complex business workflow. ```typescript async function completeOnboarding(customerData: any) { try { const newCustomer = await apiClient.customers.create(customerData); const newAccount = await apiClient.accounts.create({ customerId: newCustomer.id, type: 'CHECKING' }); // Further steps like setting up initial deposit, KYC, etc. console.log('Onboarding complete for customer:', newCustomer.id, 'with account:', newAccount.id); return { customer: newCustomer, account: newAccount }; } catch (error) { console.error('Onboarding failed:', error); throw error; } } ``` -------------------------------- ### Install Cybrid Bank API TypeScript Client Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/00-getting-started.md Install the Cybrid Bank API TypeScript client using npm. Ensure you use the correct version specified. ```bash npm install @cybrid/cybrid-api-bank-typescript@0.129.577 ``` -------------------------------- ### Generate Single HTML Document Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/README.md Use pandoc to convert a single markdown file into an HTML document. This is useful for generating documentation for specific guides, like the getting started guide. ```bash # Or single document pandoc 00-getting-started.md -o getting-started.html ``` -------------------------------- ### Install Published Package Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/README.md Install the published version of the Cybrid API Bank TypeScript package using npm. ```bash npm install @cybrid/cybrid-api-bank-typescript@0.129.577 --save ``` -------------------------------- ### TypeScript Import Example Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/COMPLETION_REPORT.txt Provides a clear example of how to import specific classes or types from the Cybrid API Bank TypeScript library. Correct imports are necessary to use the library's functionalities. ```typescript import { CybridBankApiClient, AccountType, Customer } from '@cybrid/api-bank-typescript'; // Now you can use CybridBankApiClient, AccountType, and Customer in your code. ``` -------------------------------- ### Install Unpublished Package Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/README.md Install an unpublished version of the package from a local path. This is not recommended for production use. ```bash npm install PATH_TO_GENERATED_PACKAGE --save ``` -------------------------------- ### Generate Bearer Token using Organization Credentials Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/README.md This example shows how to generate a Bearer Token using Organization credentials. The 'scope' parameter is different from the Bank credentials example and should be set according to your organization's needs. ```bash # When using Organization credentials set `scope` to 'organizations:read organizations:write organization_applications:read organization_applications:write organization_applications:execute banks:read banks:write banks:execute bank_applications:read bank_applications:write bank_applications:execute users:read users:write users:execute counterparties:read counterparties:pii:read customers:read customers:pii:read accounts:read prices:read quotes:execute quotes:read trades:execute trades:read transfers:read transfers:write transfers:execute external_bank_accounts:read external_bank_accounts:pii:read external_wallets:read workflows:read deposit_addresses:read deposit_bank_accounts:read invoices:read subscriptions:read subscriptions:write subscriptions:execute subscription_events:read subscription_events:execute identity_verifications:read identity_verifications:pii:read identity_verifications:execute persona_sessions:execute sardine_sessions:execute plans:execute plans:read executions:execute executions:read files:read files:pii:read files:execute' ``` -------------------------------- ### Async/Await Pattern Example Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/COMPLETION_REPORT.txt Shows the usage of async/await syntax for managing asynchronous API calls. ```typescript import { CybridBankApi } from "@cybrid/bank-api-typescript"; const api = new CybridBankApi({ // Configuration options }); async function getAccounts() { try { const accounts = await api.accounts.listAccounts({ // Query parameters }); return accounts; } catch (error) { console.error("Error fetching accounts:", error); throw error; } } getAccounts().then(accounts => { console.log(accounts); }); ``` -------------------------------- ### Create Customer and Start Identity Verification Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/12-identity-verifications-api.md Initiates the creation of a new customer and immediately starts the identity verification process for them. This workflow is useful when a new user signs up and requires verification. ```typescript const customersApi = new CustomersBankApi(config); customersApi.createCustomer({ postCustomerBankModel: { type: 'individual', bank_guid: 'bank-123' } }).pipe( switchMap(customer => { return identityApi.createIdentityVerification({ postIdentityVerificationBankModel: { type: 'persona', customer_guid: customer.guid } }).pipe( map(verification => ({ customer, verification })) ); }) ).subscribe(({ customer, verification }) => { console.log('Customer created and verification started'); }); ``` -------------------------------- ### Middleware Usage Example Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/COMPLETION_REPORT.txt Demonstrates how to integrate custom middleware into the API client's request pipeline. ```typescript import { CybridBankApi, ApiMiddleware } from "@cybrid/bank-api-typescript"; const customMiddleware: ApiMiddleware = { // Example: Log request details before sending preRequest: async (request) => { console.log(`Making request to: ${request.url}`); return request; }, // Example: Log response details after receiving postResponse: async (response) => { console.log(`Received response with status: ${response.status}`); return response; } }; const api = new CybridBankApi({ // Configuration options middleware: [customMiddleware] }); // Now, any API call made through this instance will use the custom middleware. ``` -------------------------------- ### GET /api/assets Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md Lists available assets. ```APIDOC ## GET /api/assets ### Description Lists available assets. ### Method GET ### Endpoint /api/assets ``` -------------------------------- ### List Workflows with Filtering Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/18-workflows-api.md Retrieves a paginated list of workflows, with options to filter by bank GUID or customer GUID. This requires the 'workflows:read' scope. Default pagination is 10 records per page. ```typescript workflowsApi.listWorkflows({ bankGuid: 'bank-123' }).subscribe( result => { result.objects.forEach(wf => console.log(wf.type)); } ); ``` -------------------------------- ### Create Account Response Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md This is a successful response when creating an account. It includes the account's unique identifier, type, asset, name, bank GUID, customer GUID, platform balance, creation and update timestamps, and current state. ```json { "guid": "account-123", "type": "trading", "asset": "BTC", "name": "Account Name", "bank_guid": "bank-123", "customer_guid": "customer-123", "platform_balance": 1.5, "created_at": "2024-01-01T00:00:00Z", "updated_at": "2024-01-02T00:00:00Z", "state": "created" } ``` -------------------------------- ### Payment Instructions Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/README.md APIs to create, get, and list payment instructions for invoices. ```APIDOC ## POST /api/payment_instructions ### Description Create a new payment instruction for an invoice. ### Method POST ### Endpoint /api/payment_instructions ### Parameters #### Request Body - **invoiceId** (string) - Required - The ID of the invoice for which to create a payment instruction. - **(object)** - Required - Payment instruction details. ### Response #### Success Response (201) - **(object)** - Details of the created payment instruction. ``` ```APIDOC ## GET /api/payment_instructions ### Description List payment instructions. ### Method GET ### Endpoint /api/payment_instructions ### Parameters #### Query Parameters - **invoiceId** (string) - Optional - Filter by invoice ID. - **limit** (integer) - Optional - The maximum number of payment instructions to return. - **offset** (integer) - Optional - The number of payment instructions to skip before returning results. ### Response #### Success Response (200) - **(array)** - A list of payment instructions. ``` -------------------------------- ### Workflows Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/README.md APIs to create, get, and list workflows. ```APIDOC ## POST /api/workflows ### Description Create a new workflow. ### Method POST ### Endpoint /api/workflows ### Parameters #### Request Body - **(object)** - Required - Workflow creation details. ### Response #### Success Response (201) - **(object)** - Details of the created workflow. ``` ```APIDOC ## GET /api/workflows ### Description List existing workflows. ### Method GET ### Endpoint /api/workflows ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of workflows to return. - **offset** (integer) - Optional - The number of workflows to skip before returning results. ### Response #### Success Response (200) - **(array)** - A list of workflows. ``` -------------------------------- ### Assets Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/README.md Get a list of assets supported by the platform (ex: BTC, ETH). ```APIDOC ## GET /api/assets ### Description Retrieve a list of all assets supported by the platform. ### Method GET ### Endpoint /api/assets ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of assets to return. - **offset** (integer) - Optional - The number of assets to skip before returning results. ### Response #### Success Response (200) - **(array)** - A list of supported assets. ``` -------------------------------- ### Get Invoice by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/13-invoices-api.md Retrieves a specific invoice using its unique GUID. This method requires the invoice's GUID as a parameter. ```typescript invoicesApi.getInvoice({ invoiceGuid: 'invoice-123' }).subscribe( invoice => { console.log('Amount:', invoice.amount); console.log('Status:', invoice.state); } ); ``` -------------------------------- ### Create Customer and Accounts Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/04-customers-api.md This example shows how to create a new customer and then concurrently create multiple accounts (e.g., trading and fiat) for that customer using `forkJoin` for parallel execution. ```typescript // After customer creation, create accounts customersApi.createCustomer({ postCustomerBankModel: { type: 'individual', bank_guid: 'bank-123' } }).pipe( switchMap(customer => { // Create BTC and USD accounts return forkJoin([ accountsApi.createAccount({ postAccountBankModel: { type: 'trading', asset: 'BTC', customer_guid: customer.guid } }), accountsApi.createAccount({ postAccountBankModel: { type: 'fiat', asset: 'USD', customer_guid: customer.guid } }) ]); }) ).subscribe(([btcAccount, usdAccount]) => { console.log('Accounts created'); }); ``` -------------------------------- ### Get External Bank Account by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/16-external-bank-accounts-api.md Retrieves a specific external bank account using its unique GUID. Requires the 'external_bank_accounts:read' scope. The GUID is a mandatory parameter for this operation. ```typescript bankAccountsApi.getExternalBankAccount({ externalBankAccountGuid: 'eba-123' }).subscribe( account => console.log('Account holder:', account.account_holder_name) ); ``` -------------------------------- ### Initialize Configuration with Basic Settings Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/01-runtime.md Use this snippet to create a basic Configuration instance with a specified base path and access token. ```typescript import { Configuration } from '@cybrid/cybrid-api-bank-typescript'; // Basic configuration const config = new Configuration({ basePath: 'https://bank.production.cybrid.app', accessToken: 'your-bearer-token' }); ``` -------------------------------- ### Get Deposit Address by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/17-deposit-addresses-api.md Retrieves a specific deposit address using its unique GUID. Requires the 'deposit_addresses:read' scope. ```typescript depositApi.getDepositAddress({ depositAddressGuid: 'da-123' }).subscribe( address => console.log('Address:', address.address) ); ``` -------------------------------- ### Create and List Sandbox Banks Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/03-banks-api.md Demonstrates the workflow for creating a new sandbox bank and then listing all sandbox banks. It shows how to use the `createBank` and `listBanks` methods sequentially. ```APIDOC ## Create and List Sandbox Banks ### Description This workflow shows how to create a new sandbox bank and then list all existing sandbox banks. It utilizes the `createBank` method to instantiate a new bank and then `listBanks` to retrieve a collection of sandbox banks. ### Method POST (for createBank), GET (for listBanks) ### Endpoint `/banks` (for createBank), `/banks` (for listBanks) ### Parameters #### Request Body (createBank) - **postBankBankModel** (object) - Required - The model for creating a new bank. - **type** (string) - Required - Bank type (e.g., 'sandbox'). - **name** (string) - Required - Bank name. #### Query Parameters (listBanks) - **type** (string) - Optional - Filter banks by type (e.g., 'sandbox'). ### Request Example (createBank) ```json { "postBankBankModel": { "type": "sandbox", "name": "Development Bank" } } ``` ### Response (createBank) - **guid** (string) - Unique bank identifier - **type** (string) - Bank type (sandbox, production) - **name** (string) - Bank name - **display_name** (string) - Display name for UI - **organization_guid** (string) - Parent organization - **created_at** (string) - ISO8601 creation timestamp - **updated_at** (string) - ISO8601 last update timestamp ### Response Example (listBanks) ```json { "paging": { "total": 10 }, "objects": [ { "guid": "bank-123", "type": "sandbox", "name": "Development Bank", "display_name": "Development Bank", "organization_guid": "org-abc", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ] } ``` ``` -------------------------------- ### GET /api/invoices/{invoice_guid} Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md Retrieves a specific invoice by its GUID. ```APIDOC ## GET /api/invoices/{invoice_guid} ### Description Retrieves a specific invoice by its GUID. ### Method GET ### Endpoint /api/invoices/{invoice_guid} #### Path Parameters - **invoice_guid** (string) - Required - The unique GUID of the invoice. ``` -------------------------------- ### GET /api/transfers/{transfer_guid} Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md Retrieves the details of a specific transfer using its GUID. ```APIDOC ## GET /api/transfers/{transfer_guid} ### Description Retrieves the details of a specific transfer using its GUID. ### Method GET ### Endpoint /api/transfers/{transfer_guid} ### Parameters #### Path Parameters - **transfer_guid** (string) - Required - The unique identifier of the transfer to retrieve. ### Response #### Success Response (200) - **guid** (string) - The unique identifier for the transfer. - **customer_guid** (string) - The GUID of the customer associated with the transfer. - **account_guid** (string) - The GUID of the account used for the transfer. - **asset** (string) - The asset being transferred (e.g., 'BTC'). - **amount** (string) - The amount transferred. - **state** (string) - The current state of the transfer (e.g., 'pending'). - **side** (string) - The direction of the transfer (e.g., 'sender'). - **created_at** (string) - The timestamp when the transfer was created. #### Response Example ```json { "guid": "transfer-123", "customer_guid": "customer-123", "account_guid": "account-123", "asset": "BTC", "amount": "1.0", "state": "pending", "side": "sender", "created_at": "2024-01-01T00:00:00Z" } ``` ``` -------------------------------- ### Initialize PricesBankApi Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/06-prices-api.md Instantiate the PricesBankApi with configuration. Ensure you have the necessary configuration object. ```typescript import { PricesBankApi } from '@cybrid/cybrid-api-bank-typescript'; const pricesApi = new PricesBankApi(config); ``` -------------------------------- ### Import Core Models, API Classes, and Configuration Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/22-types-reference.md Demonstrates how to import core data models, API client classes, and configuration utilities from the SDK. Essential for setting up API interactions. ```typescript // Core models import type { AccountBankModel, PostAccountBankModel, BankBankModel, CustomerBankModel, QuoteBankModel, TradeBankModel, TransferBankModel, PriceBankModel } from '@cybrid/cybrid-api-bank-typescript'; // API classes import { AccountsBankApi, BanksBankApi, CustomersBankApi, QuotesBankApi, TradesBankApi } from '@cybrid/cybrid-api-bank-typescript'; // Configuration import { Configuration, BaseAPI } from '@cybrid/cybrid-api-bank-typescript'; ``` -------------------------------- ### GET /api/trades/{trade_guid} Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md Retrieves the details of a specific trade using its GUID. ```APIDOC ## GET /api/trades/{trade_guid} ### Description Retrieves the details of a specific trade using its GUID. ### Method GET ### Endpoint /api/trades/{trade_guid} ### Parameters #### Path Parameters - **trade_guid** (string) - Required - The unique identifier of the trade to retrieve. ### Response #### Success Response (200) - **guid** (string) - The unique identifier for the trade. - **customer_guid** (string) - The GUID of the customer associated with the trade. - **account_guid** (string) - The GUID of the account used for the trade. - **symbol** (string) - The trading symbol (e.g., BTC-USD). - **side** (string) - The direction of the trade (e.g., 'buy'). - **state** (string) - The current state of the trade (e.g., 'pending'). - **deliver_amount** (string) - The amount to be delivered. - **deliver_currency** (string) - The currency of the amount to be delivered. - **receive_amount** (string) - The amount to be received. - **receive_currency** (string) - The currency of the amount to be received. - **price** (string) - The price at which the trade was executed. - **created_at** (string) - The timestamp when the trade was created. #### Response Example ```json { "guid": "trade-123", "customer_guid": "customer-123", "account_guid": "account-123", "symbol": "BTC-USD", "side": "buy", "state": "pending", "deliver_amount": "50000.00", "deliver_currency": "USD", "receive_amount": "1.0", "receive_currency": "BTC", "price": "50000", "created_at": "2024-01-01T00:00:00Z" } ``` ``` -------------------------------- ### GET /api/quotes/{quote_guid} Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md Retrieve a specific quote using its unique GUID. ```APIDOC ## GET /api/quotes/{quote_guid} ### Description Retrieve a specific quote using its unique GUID. ### Method GET ### Endpoint /api/quotes/{quote_guid} ### Parameters #### Path Parameters - **quote_guid** (string) - Required - The unique identifier of the quote to retrieve. ``` -------------------------------- ### Real-world Workflow Example (Fund Transfer) Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/COMPLETION_REPORT.txt Illustrates a multi-step real-world workflow for executing a fund transfer using the API. ```typescript import { CybridBankApi } from "@cybrid/bank-api-typescript"; const api = new CybridBankApi({ // Configuration options }); async function executeTransfer() { try { // 1. Create a transfer instruction const transferInstruction = await api.transfers.createTransferInstruction({ sourceAccountId: "acc_123", destinationAccountId: "acc_456", amount: "100.00", currency: "USD" }); // 2. Execute the transfer const transfer = await api.transfers.executeTransfer(transferInstruction.id); console.log("Transfer executed successfully:", transfer); } catch (error) { console.error("Transfer execution failed:", error); } } executeTransfer(); ``` -------------------------------- ### Complete User Onboarding Flow Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/00-getting-started.md Implement a full user onboarding process, including customer creation, identity verification, and account setup. This asynchronous function orchestrates multiple API calls. ```typescript async function onboardCustomer(bankGuid: string) { const customersApi = new CustomersBankApi(config); const accountsApi = new AccountsBankApi(config); const identityApi = new IdentityVerificationsBankApi(config); // 1. Create customer const customer = await customersApi.createCustomer({ postCustomerBankModel: { type: 'individual', bank_guid: bankGuid } }).toPromise(); // 2. Start KYC verification const verification = await identityApi.createIdentityVerification({ postIdentityVerificationBankModel: { type: 'persona', customer_guid: customer.guid } }).toPromise(); // 3. Create accounts (trading and fiat) const [tradingAccount, fiatAccount] = await Promise.all([ accountsApi.createAccount({ postAccountBankModel: { type: 'trading', asset: 'BTC', name: 'Bitcoin Trading', customer_guid: customer.guid } }).toPromise(), accountsApi.createAccount({ postAccountBankModel: { type: 'fiat', asset: 'USD', name: 'USD Account', customer_guid: customer.guid } }).toPromise() ]); return { customer, verification, accounts: { tradingAccount, fiatAccount } }; } ``` -------------------------------- ### GET /api/banks/{bank_guid} Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md Retrieves details for a specific bank using its GUID. ```APIDOC ## GET /api/banks/{bank_guid} ### Description Retrieves a specific bank by its GUID. ### Method GET ### Endpoint /api/banks/{bank_guid} ### Parameters #### Path Parameters - **bank_guid** (string) - Required - The unique identifier for the bank. ### Response #### Success Response (200) - **guid** (string) - The unique identifier for the bank. - **type** (string) - The type of the bank. - **name** (string) - The name of the bank. - **organization_guid** (string) - The GUID of the organization the bank belongs to. - **created_at** (string) - Timestamp of bank creation. - **updated_at** (string) - Timestamp of last update. #### Response Example ```json { "guid": "bank-123", "type": "sandbox", "name": "Bank Name", "organization_guid": "org-123", "created_at": "2024-01-01T00:00:00Z", "updated_at": "2024-01-02T00:00:00Z" } ``` ``` -------------------------------- ### Basic TypeScript API Usage Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/COMPLETION_REPORT.txt Demonstrates the fundamental steps of importing, configuring, and making API calls using the TypeScript client. Ensure the client is properly configured with authentication details before making calls. ```typescript import { CybridBankApiClient } from '@cybrid/api-bank-typescript'; // Configure the client with your API key and base URL const apiClient = new CybridBankApiClient({ apiKey: 'YOUR_API_KEY', baseUrl: 'https://api.cybrid.com/v1' }); async function getCustomerAccounts(customerId: string) { try { // Make an API call to retrieve customer accounts const accounts = await apiClient.accounts.list({ customerId }); console.log('Customer Accounts:', accounts); return accounts; } catch (error) { console.error('Error fetching accounts:', error); throw error; } } ``` -------------------------------- ### GET /api/accounts/{account_guid} Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md Retrieves details for a specific account using its GUID. ```APIDOC ## GET /api/accounts/{account_guid} ### Description Retrieves a specific account by its GUID. ### Method GET ### Endpoint /api/accounts/{account_guid} ### Parameters #### Path Parameters - **account_guid** (string) - Required - The unique identifier for the account. ### Response #### Success Response (200) - **guid** (string) - Description of the account GUID. - **type** (string) - Type of the account. - **asset** (string) - Asset of the account. - **name** (string) - Name of the account. - **bank_guid** (string) - GUID of the bank. - **customer_guid** (string) - GUID of the customer. - **platform_balance** (number) - Current platform balance. - **created_at** (string) - Timestamp of account creation. - **updated_at** (string) - Timestamp of last update. - **state** (string) - Current state of the account. #### Response Example ```json { "guid": "account-123", "type": "trading", "asset": "BTC", "name": "Account Name", "bank_guid": "bank-123", "customer_guid": "customer-123", "platform_balance": 1.5, "created_at": "2024-01-01T00:00:00Z", "updated_at": "2024-01-02T00:00:00Z", "state": "created" } ``` ``` -------------------------------- ### Get Customer Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/04-customers-api.md Retrieves a specific customer's details using their unique GUID. ```APIDOC ## GET /customers/{customerGuid} ### Description Retrieves a customer by their unique GUID. ### Method GET ### Endpoint /customers/{customerGuid} ### Parameters #### Path Parameters - **customerGuid** (string) - Required - The unique identifier of the customer. ### Response #### Success Response (200) - **guid** (string) - Unique identifier for the customer - **type** (string) - Customer type - **bank_guid** (string) - Parent bank GUID - **label** (string) - Customer label/nickname #### Response Example ```json { "guid": "cust-abc123xyz", "type": "individual", "bank_guid": "bank-123", "label": "john_doe" } ``` ``` -------------------------------- ### Initialize Configuration with Middleware and Token Function Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/01-runtime.md This snippet demonstrates initializing the Configuration with custom middleware and an access token retrieval function. The middleware can intercept and modify requests before they are sent. ```typescript import { Configuration } from '@cybrid/cybrid-api-bank-typescript'; // With middleware const config = new Configuration({ basePath: 'https://bank.production.cybrid.app', middleware: [{ pre(request) { request.headers = { ...request.headers, 'X-Custom-Header': 'value' }; return request; } }], accessToken: () => { return getToken(); } }); ``` -------------------------------- ### getWorkflow Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/18-workflows-api.md Retrieves a specific workflow by its unique identifier (GUID). Use this method to get details about an existing workflow. ```APIDOC ## GET /workflows/{workflowGuid} ### Description Retrieves a specific workflow by its unique identifier (GUID). Use this method to get details about an existing workflow. ### Method GET ### Endpoint /workflows/{workflowGuid} ### Parameters #### Path Parameters - **workflowGuid** (string) - Required - Workflow GUID ### Response #### Success Response (200) - **guid** (string) - The unique identifier of the workflow. - **type** (string) - The type of the workflow. - **bank_guid** (string) - The GUID of the bank associated with the workflow. #### Response Example { "guid": "workflow-123", "type": "transfer", "bank_guid": "bank-123" } ``` -------------------------------- ### Get Payment Instruction Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/14-payment-instructions-api.md Retrieves a specific payment instruction using its unique GUID. Requires the 'invoices:read' scope. ```typescript paymentsApi.getPaymentInstruction({ paymentInstructionGuid: 'pi-123' }).subscribe( instruction => console.log('Payment method:', instruction.type) ); ``` -------------------------------- ### Initialize BaseAPI with Configuration Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/01-runtime.md Instantiate the BaseAPI class with a custom Configuration object, specifying details like the base path and access token. ```typescript import { AccountsBankApi, Configuration } from '@cybrid/cybrid-api-bank-typescript'; const config = new Configuration({ basePath: 'https://bank.production.cybrid.app', accessToken: 'your-token' }); const accountsApi = new AccountsBankApi(config); ``` -------------------------------- ### Get Identity Verification by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/12-identity-verifications-api.md Retrieves a specific identity verification using its unique identifier. Requires 'identity_verifications:read' scope. ```typescript identityApi.getIdentityVerification({ identityVerificationGuid: 'verification-123' }).subscribe( verification => { console.log('State:', verification.state); console.log('Outcome:', verification.outcome); } ); ``` -------------------------------- ### Get a Single Account by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/02-accounts-api.md Retrieves a single account using its unique identifier. Ensure you have the 'accounts:read' scope. Handles 'Account not found' errors. ```typescript accountsApi.getAccount({ accountGuid: 'account-123' }).subscribe( account => { console.log('Account:', account.name); console.log('Asset:', account.asset); console.log('Balance:', account.platform_balance); console.log('Created:', account.created_at); }, error => { if (error.status === 404) { console.error('Account not found'); } } ); ``` -------------------------------- ### Get Payment Instruction Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/14-payment-instructions-api.md Retrieves a specific payment instruction using its unique identifier (GUID). This allows fetching details of a previously created payment instruction. ```APIDOC ## GET /payment-instructions/{paymentInstructionGuid} ### Description Retrieves a payment instruction by GUID. ### Method GET ### Endpoint /payment-instructions/{paymentInstructionGuid} ### Parameters #### Path Parameters - **paymentInstructionGuid** (string) - Required - Payment instruction GUID ### Response #### Success Response (200) - **PaymentInstructionBankModel** - Payment instruction details ``` -------------------------------- ### Initialize and List Assets Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/05-assets-api.md Initializes the AssetsBankApi and retrieves a list of assets, logging their codes and names. Ensure you have the necessary configuration and scope (`prices:read`). ```typescript import { AssetsBankApi } from '@cybrid/cybrid-api-bank-typescript'; const assetsApi = new AssetsBankApi(config); assetsApi.listAssets({ perPage: 100 }).subscribe( result => { result.objects.forEach(asset => { console.log(`${asset.code}: ${asset.name}`); }); } ); ``` -------------------------------- ### Retrieve File Metadata using FilesBankApi Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/19-files-api.md Use this snippet to get metadata for a specific file using its GUID. This operation requires the file's unique identifier and the 'files:read' scope. ```typescript filesApi.getFile({ fileGuid: 'file-123' }).subscribe( file => console.log('Filename:', file.filename) ); ``` -------------------------------- ### Retrieve External Wallet by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/15-external-wallets-api.md Fetches details of a specific external wallet using its unique GUID. Requires the 'external_wallets:read' scope. The GUID is the only parameter needed for the request. ```typescript walletsApi.getExternalWallet({ externalWalletGuid: 'wallet-123' }).subscribe( wallet => console.log('Address:', wallet.address) ); ``` -------------------------------- ### Import and Configure Cybrid API Client Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/00-getting-started.md Import necessary classes and configure the API client with your base path and access token. This setup is required before making any API calls. ```typescript import { Configuration, AccountsBankApi, CustomersBankApi, BanksBankApi } from '@cybrid/cybrid-api-bank-typescript'; const config = new Configuration({ basePath: 'https://bank.production.cybrid.app', accessToken: 'your-bearer-token' }); const accountsApi = new AccountsBankApi(config); const customersApi = new CustomersBankApi(config); const banksApi = new BanksBankApi(config); ``` -------------------------------- ### listWorkflows Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/18-workflows-api.md Retrieves a paginated list of workflows. This method can be filtered by bank GUID or customer GUID. ```APIDOC ## GET /workflows ### Description Retrieves a paginated list of workflows. This method can be filtered by bank GUID or customer GUID. ### Method GET ### Endpoint /workflows ### Parameters #### Query Parameters - **page** (number) - Optional - Page number (default: 1) - **perPage** (number) - Optional - Records per page (default: 10) - **bankGuid** (string) - Optional - Filter by bank - **customerGuid** (string) - Optional - Filter by customer ### Response #### Success Response (200) - **objects** (array) - An array of workflow objects. - **guid** (string) - The unique identifier of the workflow. - **type** (string) - The type of the workflow. - **bank_guid** (string) - The GUID of the bank associated with the workflow. #### Response Example { "objects": [ { "guid": "workflow-abc", "type": "transfer", "bank_guid": "bank-123" } ] } ``` -------------------------------- ### Use async/await with toPromise() for Asynchronous Operations Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/00-getting-started.md This example shows how to use async/await with the toPromise() method to handle asynchronous API calls, including creating a customer and multiple accounts concurrently using Promise.all. ```typescript async function setupCustomer(bankGuid: string) { try { // Create customer const customer = await customersApi.createCustomer({ postCustomerBankModel: { type: 'individual', bank_guid: bankGuid } }).toPromise(); // Create accounts const [btcAccount, usdAccount] = await Promise.all([ accountsApi.createAccount({ postAccountBankModel: { type: 'trading', asset: 'BTC', name: 'BTC Account', customer_guid: customer.guid } }).toPromise(), accountsApi.createAccount({ postAccountBankModel: { type: 'fiat', asset: 'USD', name: 'USD Account', customer_guid: customer.guid } }).toPromise() ]); return { customer, btcAccount, usdAccount }; } catch (error) { console.error('Setup failed:', error); throw error; } } ``` -------------------------------- ### Build and Compile TypeScript Sources Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/README.md Use these npm commands to install dependencies and build the TypeScript sources into JavaScript. ```bash npm install npm run build ``` -------------------------------- ### Retrieve a Workflow by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/18-workflows-api.md Fetches a specific workflow using its unique GUID. This operation requires the 'workflows:read' scope. ```typescript workflowsApi.getWorkflow({ workflowGuid: 'workflow-123' }).subscribe( workflow => console.log('Type:', workflow.type) ); ``` -------------------------------- ### Create Customer and Initiate Identity Verification Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/04-customers-api.md This snippet demonstrates the process of creating a new individual customer and then immediately initiating an identity verification for them. It uses RxJS operators like `tap` and `switchMap` to chain these operations. ```typescript let customerGuid: string; // 1. Create customer customersApi.createCustomer({ postCustomerBankModel: { type: 'individual', bank_guid: 'bank-123', label: 'new_customer' } }).pipe( tap(c => customerGuid = c.guid), // 2. Create identity verification (see IdentityVerificationsApi) switchMap(customer => { return identityApi.createIdentityVerification({ postIdentityVerificationBankModel: { customer_guid: customer.guid, // ... verification details } }); }) ).subscribe( verification => console.log('Customer verified:', verification.guid) ); ``` -------------------------------- ### Create Customer Response (200 OK) Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md This is an example of a successful response when creating a customer. It includes the customer's unique identifier and timestamps. ```json { "guid": "customer-123", "type": "individual", "bank_guid": "bank-123", "label": "customer_label", "created_at": "2024-01-01T00:00:00Z", "updated_at": "2024-01-02T00:00:00Z" } ``` -------------------------------- ### Retrieve a Counterparty by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/11-counterparties-api.md Fetches a specific counterparty using its unique GUID. This operation requires the 'counterparties:read' scope. ```typescript counterpartiesApi.getCounterparty({ counterpartyGuid: 'cp-123' }).subscribe( cp => console.log('Counterparty:', cp.name) ); ``` -------------------------------- ### Create Plan Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md Creates a new plan. Requires 'plans:execute' scope. ```APIDOC ## POST /api/plans ### Description Creates a new plan. ### Method POST ### Endpoint /api/plans ### Scope plans:execute ``` -------------------------------- ### Retrieve Bank by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/03-banks-api.md Fetches a single bank's details using its unique GUID. Requires 'banks:read' scope. ```typescript banksApi.getBank({ bankGuid: 'bank-123' }).subscribe( bank => { console.log('Bank name:', bank.name); console.log('Type:', bank.type); console.log('Created:', bank.created_at); } ); ``` -------------------------------- ### Retrieve a Trade by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/09-trades-api.md Retrieves a specific trade object using its unique GUID. This is useful for checking the status or details of a trade. ```typescript tradesApi.getTrade({ tradeGuid: 'trade-123' }).subscribe( trade => { console.log('Trade state:', trade.state); if (trade.state === 'completed') { console.log('Received:', trade.receive_amount, trade.receive_currency); } } ); ``` -------------------------------- ### Create Customer Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/04-customers-api.md Creates a new individual customer. Requires customer type, bank GUID, and optionally a label. ```APIDOC ## POST /customers ### Description Creates a new customer. Currently supports 'individual' customer types. ### Method POST ### Endpoint /customers ### Parameters #### Request Body - **type** (string) - Required - Customer type; currently only 'individual' - **bank_guid** (string) - Required - Parent bank GUID - **label** (string) - Optional - Customer label/nickname ### Request Example ```json { "type": "individual", "bank_guid": "bank-123", "label": "john_doe" } ``` ### Response #### Success Response (200) - **guid** (string) - Unique identifier for the customer - **type** (string) - Customer type - **bank_guid** (string) - Parent bank GUID - **label** (string) - Customer label/nickname #### Response Example ```json { "guid": "cust-abc123xyz", "type": "individual", "bank_guid": "bank-123", "label": "john_doe" } ``` ``` -------------------------------- ### Create and List Sandbox Banks Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/03-banks-api.md Creates a new sandbox bank and then lists all sandbox banks. Requires the `banks:execute` scope for creation and `banks:read` for listing. ```typescript banksApi.createBank({ postBankBankModel: { type: 'sandbox', name: 'Development Bank' } }).pipe( switchMap(bank => { console.log('Bank created:', bank.guid); // List all sandbox banks return banksApi.listBanks({ type: 'sandbox' }); }) ).subscribe( result => { console.log('Total sandbox banks:', result.paging.total); result.objects.forEach(b => console.log(`- ${b.name}`)); } ); ``` -------------------------------- ### Create a New Trade Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/09-trades-api.md Executes a new trade using a previously created quote. Ensure you have a valid quote GUID and account GUID. ```typescript import { TradesBankApi } from '@cybrid/cybrid-api-bank-typescript'; const tradesApi = new TradesBankApi(config); // Execute trade with quote tradesApi.createTrade({ postTradeBankModel: { quote_guid: 'quote-123', account_guid: 'account-456' } }).subscribe( trade => { console.log('Trade executed:', trade.guid); console.log('State:', trade.state); console.log('Price:', trade.price); } ); ``` -------------------------------- ### Retrieve Customer by GUID Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/04-customers-api.md Fetches a specific customer's details using their unique GUID. This is useful for viewing individual customer information. ```typescript customersApi.getCustomer({ customerGuid: 'customer-123' }).subscribe( customer => { console.log('Customer type:', customer.type); console.log('Label:', customer.label); } ); ``` -------------------------------- ### Create Quote Response (200 OK) Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md An example of a successful response after creating a quote. It details the quote's parameters, including price and expiration. ```json { "guid": "quote-123", "symbol": "BTC-USD", "side": "buy", "deliver_amount": "50000.00", "deliver_currency": "USD", "receive_amount": "1.0", "receive_currency": "BTC", "price": "50000", "expires_at": "2024-01-01T00:15:00Z", "created_at": "2024-01-01T00:00:00Z" } ``` -------------------------------- ### Configure Request and Response Logging Middleware Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/01-runtime.md Illustrates how to set up a `Configuration` object with custom middleware to log outgoing requests (method and URL) and incoming responses (status code). ```typescript const loggingConfig = new Configuration({ basePath: 'https://bank.production.cybrid.app', accessToken: 'token', middleware: [{ pre(request) { console.log(`${request.method} ${request.url}`); return request; }, post(response) { console.log(`Response: ${response.status}`); return response; } }] }); const api = new AccountsBankApi(loggingConfig); ``` -------------------------------- ### Initialize AccountsBankApi Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/02-accounts-api.md Instantiate the AccountsBankApi with a configuration object, including the base path and authentication token. This is required before making any API calls. ```typescript import { AccountsBankApi, Configuration } from '@cybrid/cybrid-api-bank-typescript'; const config = new Configuration({ basePath: 'https://bank.production.cybrid.app', accessToken: 'your-bearer-token' }); const accountsApi = new AccountsBankApi(config); ``` -------------------------------- ### BaseAPI Constructor Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/01-runtime.md Initializes a BaseAPI instance. You can provide a custom Configuration object, otherwise, a default one is used. ```APIDOC ## constructor(configuration?: Configuration) ### Description Initializes BaseAPI instance with configuration. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Request Example ```typescript import { AccountsBankApi, Configuration } from '@cybrid/cybrid-api-bank-typescript'; const config = new Configuration({ basePath: 'https://bank.production.cybrid.app', accessToken: 'your-token' }); const accountsApi = new AccountsBankApi(config); ``` ### Response * None directly from constructor, returns `this` instance. ``` -------------------------------- ### GET /api/invoices Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/21-endpoints-reference.md Lists all invoices. ```APIDOC ## GET /api/invoices ### Description Lists all invoices. ### Method GET ### Endpoint /api/invoices ``` -------------------------------- ### Create-Read-List Pattern Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/INDEX.md Demonstrates the common Create-Read-List pattern for resources like Accounts, Banks, Customers, Quotes, Trades, Transfers, Counterparties, Invoices, Workflows, Files, and Plans. ```APIDOC ## Create-Read-List Pattern ### Description This pattern applies to resources that can be created, read individually, and listed in bulk. ### Methods - `createResource({ postResourceBankModel: {...} })`: Creates a new resource. - `getResource({ resourceGuid: '...' })`: Retrieves a specific resource by its GUID. - `listResources({ bankGuid?: '...', page?: 1, perPage?: 10 })`: Lists resources, with optional filtering by bank GUID and pagination. ### Resources Accounts, Banks, Customers, Quotes, Trades, Transfers, Counterparties, Invoices, Workflows, Files, Plans ``` -------------------------------- ### Create-Read-List-Update Pattern Source: https://github.com/cybrid-app/cybrid-api-bank-typescript/blob/main/_autodocs/INDEX.md Illustrates the Create-Read-List-Update pattern for resources that support modification after creation, including Banks, Customers, External Bank Accounts, and Transfers. ```APIDOC ## Create-Read-List-Update Pattern ### Description This pattern extends the CRL pattern to include the ability to update existing resources. ### Methods - `createResource({ postResourceBankModel: {...} })`: Creates a new resource. - `getResource({ resourceGuid: '...' })`: Retrieves a specific resource by its GUID. - `listResources({ bankGuid?: '...', page?: 1, perPage?: 10 })`: Lists resources, with optional filtering by bank GUID and pagination. - `updateResource({ resourceGuid: '...', patchResourceBankModel: {...} })`: Updates an existing resource. ### Resources Banks, Customers, External Bank Accounts, Transfers ```