### Install Dependencies and Build Project Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/CONTRIBUTING.md Installs project dependencies using Yarn and builds the project output files into the 'dist/' directory. This is the initial setup step for the repository. ```shell $ yarn $ yarn build ``` -------------------------------- ### Add and Run TypeScript Examples Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/CONTRIBUTING.md Demonstrates how to add new TypeScript example files to the 'examples/' directory and execute them using the 'tsn' command. This allows testing SDK functionality with custom scenarios. ```typescript // add an example to examples/.ts #!/usr/bin/env -S npm run tsn -T … ``` ```shell $ chmod +x examples/.ts # run the example against your api $ yarn tsn -T examples/.ts ``` -------------------------------- ### Install SDK from Git Repository Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/CONTRIBUTING.md Provides instructions for installing the Dinari API SDK directly from its GitHub repository using npm. This is useful for using the SDK in other projects without publishing. ```shell $ npm install git+ssh://git@github.com:dinaricrypto/dinari-api-sdk-typescript.git ``` -------------------------------- ### Install Dinari API SDK Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Installs the Dinari API SDK using npm. This is the first step to integrate the Dinari API into your project. ```sh npm install @dinari/api-sdk ``` -------------------------------- ### Run Mock Server for Tests Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/CONTRIBUTING.md Details how to set up a mock server using Prism against an OpenAPI specification file. This is a prerequisite for running the repository's tests, simulating API responses. ```shell $ npx prism mock path/to/your/openapi.yml ``` -------------------------------- ### Run Repository Tests Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/CONTRIBUTING.md Executes the test suite for the Dinari API SDK. This command assumes the mock server setup is complete or tests do not require it. ```shell $ yarn run test ``` -------------------------------- ### Publish NPM Package Manually Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/CONTRIBUTING.md Instructions for manually publishing the Dinari API SDK to npm. This involves setting the NPM_TOKEN environment variable and running a specific script. ```shell export NPM_TOKEN= $ bin/publish-npm ``` -------------------------------- ### Link Local SDK Repository Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/CONTRIBUTING.md Explains how to link a local clone of the Dinari API SDK repository to another project using Yarn or pnpm. This facilitates development and testing of the SDK against local applications. ```shell # Clone $ git clone https://www.github.com/dinaricrypto/dinari-api-sdk-typescript $ cd dinari-api-sdk-typescript # With yarn $ yarn link $ cd ../my-package $ yarn link @dinari/api-sdk # With pnpm $ pnpm link --global $ cd ../my-package $ pnpm link -—global @dinari/api-sdk ``` -------------------------------- ### Order Requests API Endpoints (TypeScript SDK) Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Provides methods for managing order requests within the Dinari API SDK. Includes creating, retrieving, and listing buy/sell orders (limit and market) and getting fee quotes. ```APIDOC Order Requests API Endpoints: client.v2.accounts.orderRequests.retrieve(orderRequestID, { ...params }) - GET /api/v2/accounts/{account_id}/order_requests/{order_request_id} - Retrieves a specific order request. - Parameters: - orderRequestID: The ID of the order request to retrieve. - { ...params }: Optional query parameters. - Returns: OrderRequest object. client.v2.accounts.orderRequests.list(accountID, { ...params }) - GET /api/v2/accounts/{account_id}/order_requests - Lists all order requests for a given account. - Parameters: - accountID: The ID of the account. - { ...params }: Optional query parameters. - Returns: OrderRequestListResponse object. client.v2.accounts.orderRequests.createLimitBuy(accountID, { ...params }) - POST /api/v2/accounts/{account_id}/order_requests/limit_buy - Creates a limit buy order request. - Parameters: - accountID: The ID of the account. - { ...params }: Order details for the limit buy order. - Returns: OrderRequest object. client.v2.accounts.orderRequests.createLimitSell(accountID, { ...params }) - POST /api/v2/accounts/{account_id}/order_requests/limit_sell - Creates a limit sell order request. - Parameters: - accountID: The ID of the account. - { ...params }: Order details for the limit sell order. - Returns: OrderRequest object. client.v2.accounts.orderRequests.createMarketBuy(accountID, { ...params }) - POST /api/v2/accounts/{account_id}/order_requests/market_buy - Creates a market buy order request. - Parameters: - accountID: The ID of the account. - { ...params }: Order details for the market buy order. - Returns: OrderRequest object. client.v2.accounts.orderRequests.createMarketSell(accountID, { ...params }) - POST /api/v2/accounts/{account_id}/order_requests/market_sell - Creates a market sell order request. - Parameters: - accountID: The ID of the account. - { ...params }: Order details for the market sell order. - Returns: OrderRequest object. client.v2.accounts.orderRequests.getFeeQuote(accountID, { ...params }) - POST /api/v2/accounts/{account_id}/order_requests/fee_quote - Retrieves a fee quote for a potential order request. - Parameters: - accountID: The ID of the account. - { ...params }: Details required for fee calculation. - Returns: OrderRequestGetFeeQuoteResponse object. ``` -------------------------------- ### Lint and Format Code Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/CONTRIBUTING.md Commands to check code style using ESLint and format code using Prettier. 'yarn lint' checks for issues, while 'yarn fix' automatically resolves them. ```shell $ yarn lint $ yarn fix ``` -------------------------------- ### Configure Request Timeouts Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Details on setting request timeouts, which default to 1 minute. Examples show how to configure a global timeout and override it per request. Timeouts trigger an APIConnectionTimeoutError and are subject to retries. ```typescript const client = new Dinari({ timeout: 20 * 1000, // 20 seconds (default is 1 minute) }); await client.v2.marketData.stocks.list({ timeout: 5 * 1000, }); ``` -------------------------------- ### Using Undocumented Request Parameters Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Demonstrates how to use `// @ts-expect-error` to include undocumented parameters in requests. The SDK sends these extra values as-is, either in the query string for GET requests or in the request body for other HTTP methods. ```typescript client.v2.marketData.stocks.list({ // ... // @ts-expect-error baz is not yet public baz: 'undocumented option', }); ``` -------------------------------- ### Configuring Proxies for Bun Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Shows how to set up a proxy for Bun runtime by specifying the proxy URL directly in the `fetchOptions.proxy` property. ```typescript import Dinari from '@dinari/api-sdk'; const client = new Dinari({ fetchOptions: { proxy: 'http://localhost:8888', }, }); ``` -------------------------------- ### Initialize Dinari Client (JavaScript) Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Demonstrates how to initialize the Dinari client in JavaScript, specifying API keys and environment. It then shows a basic call to list stocks. ```js import Dinari from '@dinari/api-sdk'; const client = new Dinari({ apiKeyID: process.env['DINARI_API_KEY_ID'], // This is the default and can be omitted apiSecretKey: process.env['DINARI_API_SECRET_KEY'], // This is the default and can be omitted environment: 'sandbox', // defaults to 'production' }); const stocks = await client.v2.marketData.stocks.list(); ``` -------------------------------- ### Configuring Proxies for Deno Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Details how to configure a proxy for Deno by creating a custom `Deno.HttpClient` with proxy settings and passing it via `fetchOptions.client`. ```typescript import Dinari from 'npm:@dinari/api-sdk'; const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } }); const client = new Dinari({ fetchOptions: { client: httpClient, }, }); ``` -------------------------------- ### Configuring Proxies for Node.js Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Demonstrates how to configure a proxy for Node.js environments using `undici.ProxyAgent` by passing it within `fetchOptions.dispatcher`. ```typescript import Dinari from '@dinari/api-sdk'; import * as undici from 'undici'; const proxyAgent = new undici.ProxyAgent('http://localhost:8888'); const client = new Dinari({ fetchOptions: { dispatcher: proxyAgent, }, }); ``` -------------------------------- ### Customizing Fetch Client (SDK Instance) Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Shows how to pass a custom `fetch` function directly to the Dinari client constructor, allowing for instance-specific network request configurations without altering the global scope. ```typescript import Dinari from '@dinari/api-sdk'; import fetch from 'my-fetch'; const client = new Dinari({ fetch }); ``` -------------------------------- ### Configuring Fetch Options Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Illustrates how to provide custom `fetch` options, such as headers or request configurations, during client instantiation. These options can be overridden by request-specific options. ```typescript import Dinari from '@dinari/api-sdk'; const client = new Dinari({ fetchOptions: { // `RequestInit` options }, }); ``` -------------------------------- ### File Upload Methods Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Illustrates various ways to upload files using the Dinari SDK, including Node.js streams, browser File API, fetch Responses, and a custom `toFile` helper. ```ts import fs from 'fs'; import Dinari, { toFile } from '@dinari/api-sdk'; const client = new Dinari(); // Using Node.js fs.createReadStream await client.v2.entities.kyc.document.upload('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { entity_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', document_type: 'GOVERNMENT_ID', file: fs.createReadStream('/path/to/file'), }); // Using browser File API await client.v2.entities.kyc.document.upload('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { entity_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', document_type: 'GOVERNMENT_ID', file: new File(['my bytes'], 'file'), }); // Using fetch Response await client.v2.entities.kyc.document.upload('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { entity_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', document_type: 'GOVERNMENT_ID', file: await fetch('https://somesite/file'), }); // Using the toFile helper with Buffer await client.v2.entities.kyc.document.upload('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { entity_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', document_type: 'GOVERNMENT_ID', file: await toFile(Buffer.from('my bytes'), 'file'), }); // Using the toFile helper with Uint8Array await client.v2.entities.kyc.document.upload('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { entity_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', document_type: 'GOVERNMENT_ID', file: await toFile(new Uint8Array([0, 1, 2]), 'file'), }); ``` -------------------------------- ### Customizing Fetch Client (Global Polyfill) Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Explains how to replace the default global `fetch` function with a custom implementation, such as one from a specific library, to control network request behavior. ```typescript import fetch from 'my-fetch'; globalThis.fetch = fetch; ``` -------------------------------- ### V2 Orders API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Provides methods for interacting with V2 orders, including listing orders. Requires parameters for filtering and pagination. ```APIDOC client.v2.listOrders({ ...params }) -> V2ListOrdersResponse - Lists orders for the authenticated user. - Parameters: - { ...params }: An object containing query parameters for filtering and pagination (e.g., limit, offset, status). - Returns: - V2ListOrdersResponse: A response object containing a list of orders. ``` -------------------------------- ### Typed Dinari Client Usage (TypeScript) Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Shows how to use the Dinari client in TypeScript, leveraging type definitions for request parameters and response fields for better developer experience and type safety. ```ts import Dinari from '@dinari/api-sdk'; const client = new Dinari({ apiKeyID: process.env['DINARI_API_KEY_ID'], // This is the default and can be omitted apiSecretKey: process.env['DINARI_API_SECRET_KEY'], // This is the default and can be omitted environment: 'sandbox', // defaults to 'production' }); const stocks: Dinari.V2.MarketData.StockListResponse = await client.v2.marketData.stocks.list(); ``` -------------------------------- ### Use Custom Logger Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Shows how to integrate a custom logger, such as pino, with the Dinari API SDK. The `logLevel` option still governs which messages are sent to the custom logger. ```typescript import Dinari from '@dinari/api-sdk'; import pino from 'pino'; const logger = pino(); const client = new Dinari({ logger: logger.child({ name: 'Dinari' }), logLevel: 'debug', // Send all messages to pino, allowing it to filter }); ``` -------------------------------- ### KYC Management API (Dinari API SDK) Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Manages Know Your Customer (KYC) processes for entities. This includes retrieving KYC status, initiating managed checks via a URL, and submitting KYC data for verification. ```APIDOC APIDOC --- title: KYC Management description: Manages Know Your Customer (KYC) processes for entities. This includes retrieving KYC status, initiating managed checks via a URL, and submitting KYC data for verification. # KYC Operations ## Retrieve KYC Information **Method:** GET **Path:** `/api/v2/entities/{entity_id}/kyc` **Description:** Retrieves the KYC information for a specific entity. **Parameters:** - `entityID` (string): The unique identifier of the entity. **Returns:** - `KYCInfo`: An object containing the KYC status and details for the entity. **Example:** ```typescript client.v2.entities.kyc.retrieve(entityID) ``` ## Create Managed KYC Check **Method:** POST **Path:** `/api/v2/entities/{entity_id}/kyc/url` **Description:** Creates a managed KYC check for an entity, typically returning a URL for external processing. **Parameters:** - `entityID` (string): The unique identifier of the entity. **Returns:** - `KYCCreateManagedCheckResponse`: An object containing details for the managed KYC check, potentially including a URL. **Example:** ```typescript client.v2.entities.kyc.createManagedCheck(entityID) ``` ## Submit KYC Data **Method:** POST **Path:** `/api/v2/entities/{entity_id}/kyc` **Description:** Submits KYC data for an entity for verification. **Parameters:** - `entityID` (string): The unique identifier of the entity. - `params` (object): An object containing the KYC data to submit. **Returns:** - `KYCInfo`: An object containing the updated KYC status and details. **Example:** ```typescript client.v2.entities.kyc.submit(entityID, { ...params }) ``` # KYC Document Operations ## Retrieve KYC Document **Method:** GET **Path:** `/api/v2/entities/{entity_id}/kyc/{kyc_id}/document` **Description:** Retrieves a specific KYC document associated with a KYC process. **Parameters:** - `kycID` (string): The unique identifier of the KYC process. - `params` (object): Optional parameters for the retrieval. **Returns:** - `DocumentRetrieveResponse`: An object containing the retrieved KYC document data. **Example:** ```typescript client.v2.entities.kyc.document.retrieve(kycID, { ...params }) ``` ## Upload KYC Document **Method:** POST **Path:** `/api/v2/entities/{entity_id}/kyc/{kyc_id}/document` **Description:** Uploads a KYC document for a specific KYC process. **Parameters:** - `kycID` (string): The unique identifier of the KYC process. - `params` (object): An object containing the document data or file to upload. **Returns:** - `KYCDocument`: An object representing the uploaded KYC document. **Example:** ```typescript client.v2.entities.kyc.document.upload(kycID, { ...params }) ``` # Types Used: - `KYCData`: Represents data fields for KYC. - `KYCInfo`: Represents the overall KYC status and information for an entity. - `KYCCreateManagedCheckResponse`: Response structure for creating a managed KYC check. - `KYCDocument`: Represents a single KYC document. - `KYCDocumentType`: Represents the type of a KYC document. - `DocumentRetrieveResponse`: Response structure for retrieving a KYC document. ``` -------------------------------- ### Account Management API (Dinari API SDK) Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Manages user accounts, including retrieving account details, deactivating accounts, fetching balances, dividends, interest payments, and portfolio information. Also supports minting sandbox tokens. ```APIDOC APIDOC --- title: Account Management description: Manages user accounts, including retrieving account details, deactivating accounts, fetching balances, dividends, interest payments, and portfolio information. Also supports minting sandbox tokens. # Account Operations ## Retrieve Account Details **Method:** GET **Path:** `/api/v2/accounts/{account_id}` **Description:** Retrieves the details of a specific account. **Parameters:** - `accountID` (string): The unique identifier of the account. **Returns:** - `Account`: An object containing the account's details. **Example:** ```typescript client.v2.accounts.retrieve(accountID) ``` ## Deactivate Account **Method:** POST **Path:** `/api/v2/accounts/{account_id}/deactivate` **Description:** Deactivates a specific account. **Parameters:** - `accountID` (string): The unique identifier of the account. **Returns:** - `Account`: The deactivated account object. **Example:** ```typescript client.v2.accounts.deactivate(accountID) ``` ## Get Cash Balances **Method:** GET **Path:** `/api/v2/accounts/{account_id}/cash` **Description:** Retrieves the cash balances for a specific account. **Parameters:** - `accountID` (string): The unique identifier of the account. **Returns:** - `AccountGetCashBalancesResponse`: An object containing the cash balances. **Example:** ```typescript client.v2.accounts.getCashBalances(accountID) ``` ## Get Dividend Payments **Method:** GET **Path:** `/api/v2/accounts/{account_id}/dividend_payments` **Description:** Retrieves dividend payment history for a specific account. **Parameters:** - `accountID` (string): The unique identifier of the account. - `params` (object): Optional parameters for filtering or pagination. **Returns:** - `AccountGetDividendPaymentsResponse`: An object containing dividend payment records. **Example:** ```typescript client.v2.accounts.getDividendPayments(accountID, { ...params }) ``` ## Get Interest Payments **Method:** GET **Path:** `/api/v2/accounts/{account_id}/interest_payments` **Description:** Retrieves interest payment history for a specific account. **Parameters:** - `accountID` (string): The unique identifier of the account. - `params` (object): Optional parameters for filtering or pagination. **Returns:** - `AccountGetInterestPaymentsResponse`: An object containing interest payment records. **Example:** ```typescript client.v2.accounts.getInterestPayments(accountID, { ...params }) ``` ## Get Portfolio **Method:** GET **Path:** `/api/v2/accounts/{account_id}/portfolio` **Description:** Retrieves the investment portfolio for a specific account. **Parameters:** - `accountID` (string): The unique identifier of the account. **Returns:** - `AccountGetPortfolioResponse`: An object containing the account's portfolio details. **Example:** ```typescript client.v2.accounts.getPortfolio(accountID) ``` ## Mint Sandbox Tokens **Method:** POST **Path:** `/api/v2/accounts/{account_id}/faucet` **Description:** Mints sandbox tokens for a specific account, typically for testing purposes. **Parameters:** - `accountID` (string): The unique identifier of the account. - `params` (object): Parameters for the token minting request. **Returns:** - `void`: Indicates the operation was successful. **Example:** ```typescript client.v2.accounts.mintSandboxTokens(accountID, { ...params }) ``` # Wallet Operations ## Connect Internal Wallet **Method:** POST **Path:** `/api/v2/accounts/{account_id}/wallet/internal` **Description:** Connects or configures an internal wallet for an account. **Parameters:** - `accountID` (string): The unique identifier of the account. - `params` (object): Parameters for connecting the internal wallet. **Returns:** - `Wallet`: The connected wallet object. **Example:** ```typescript client.v2.accounts.wallet.connectInternal(accountID, { ...params }) ``` ## Get Account Wallet **Method:** GET **Path:** `/api/v2/accounts/{account_id}/wallet` **Description:** Retrieves the wallet information associated with an account. **Parameters:** - `accountID` (string): The unique identifier of the account. **Returns:** - `Wallet`: The account's wallet object. **Example:** ```typescript client.v2.accounts.wallet.get(accountID) ``` # External Wallet Operations ## Connect External Wallet **Method:** POST **Path:** `/api/v2/accounts/{account_id}/wallet/external` **Description:** Connects an external wallet to an account. **Parameters:** - `accountID` (string): The unique identifier of the account. - `params` (object): Parameters for connecting the external wallet. **Returns:** - `Wallet`: The connected wallet object. **Example:** ```typescript client.v2.accounts.wallet.external.connect(accountID, { ...params }) ``` ## Get External Wallet Nonce **Method:** GET **Path:** `/api/v2/accounts/{account_id}/wallet/external/nonce` **Description:** Retrieves a nonce for signing messages with an external wallet. **Parameters:** - `accountID` (string): The unique identifier of the account. - `params` (object): Optional parameters for the nonce request. **Returns:** - `ExternalGetNonceResponse`: An object containing the nonce and related information. **Example:** ```typescript client.v2.accounts.wallet.external.getNonce(accountID, { ...params }) ``` # Types Used: - `Chain`: Represents blockchain network information. - `AccountGetCashBalancesResponse`: Response for fetching cash balances. - `AccountGetDividendPaymentsResponse`: Response for fetching dividend payments. - `AccountGetInterestPaymentsResponse`: Response for fetching interest payments. - `AccountGetPortfolioResponse`: Response for fetching portfolio details. - `Wallet`: Represents wallet information. - `WalletChainID`: Represents a blockchain network identifier for a wallet. - `ExternalGetNonceResponse`: Response for fetching a nonce for external wallet operations. ``` -------------------------------- ### EIP-155 Stock Order Requests (TypeScript SDK) Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Handles EIP-155 specific order requests for stocks within the Dinari API SDK, including preparing and creating proxied orders. ```APIDOC EIP-155 Stock Order Requests API Endpoints: client.v2.accounts.orderRequests.stocks.eip155.createProxiedOrder(accountID, { ...params }) - POST /api/v2/accounts/{account_id}/order_requests/stocks/eip155 - Creates a proxied order request using EIP-155 signing. - Parameters: - accountID: The ID of the account. - { ...params }: Order details and EIP-155 signing parameters. - Returns: OrderRequest object. client.v2.accounts.orderRequests.stocks.eip155.prepareProxiedOrder(accountID, { ...params }) - POST /api/v2/accounts/{account_id}/order_requests/stocks/eip155/prepare - Prepares a proxied order request for EIP-155 signing. - Parameters: - accountID: The ID of the account. - { ...params }: Details for preparing the proxied order. - Returns: Eip155PrepareProxiedOrderResponse object. ``` -------------------------------- ### Configure Logging Level Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Explains how to control the verbosity of SDK logs using the `logLevel` option or the `DINARI_LOG` environment variable. Available levels range from 'debug' to 'off'. ```typescript import Dinari from '@dinari/api-sdk'; const client = new Dinari({ logLevel: 'debug', // Show all log messages }); ``` -------------------------------- ### V2 Market Data Stocks API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Provides comprehensive methods for accessing stock market data, including listing stocks, retrieving current prices, quotes, dividends, historical prices, and news. Requires stock identifiers and optional parameters for specific data retrieval. ```APIDOC client.v2.marketData.stocks.list({ ...params }) -> StockListResponse - Lists available stocks with optional filtering and pagination. - Parameters: - { ...params }: An object containing query parameters for filtering and pagination. - Returns: - StockListResponse: A response object containing a list of stocks. ``` ```APIDOC client.v2.marketData.stocks.retrieveCurrentPrice(stockID) -> StockRetrieveCurrentPriceResponse - Retrieves the current trading price for a specific stock. - Parameters: - stockID: The unique identifier for the stock. - Returns: - StockRetrieveCurrentPriceResponse: An object containing the current price data. ``` ```APIDOC client.v2.marketData.stocks.retrieveCurrentQuote(stockID) -> StockRetrieveCurrentQuoteResponse - Retrieves the current quote information for a specific stock. - Parameters: - stockID: The unique identifier for the stock. - Returns: - StockRetrieveCurrentQuoteResponse: An object containing the current quote data. ``` ```APIDOC client.v2.marketData.stocks.retrieveDividends(stockID) -> StockRetrieveDividendsResponse - Retrieves dividend information for a specific stock. - Parameters: - stockID: The unique identifier for the stock. - Returns: - StockRetrieveDividendsResponse: An object containing dividend data. ``` ```APIDOC client.v2.marketData.stocks.retrieveHistoricalPrices(stockID, { ...params }) -> StockRetrieveHistoricalPricesResponse - Retrieves historical price data for a specific stock. - Parameters: - stockID: The unique identifier for the stock. - { ...params }: An object containing query parameters for date range and interval. - Returns: - StockRetrieveHistoricalPricesResponse: An object containing historical price data. ``` ```APIDOC client.v2.marketData.stocks.retrieveNews(stockID, { ...params }) -> StockRetrieveNewsResponse - Retrieves news articles related to a specific stock. - Parameters: - stockID: The unique identifier for the stock. - { ...params }: An object containing query parameters for filtering news. - Returns: - StockRetrieveNewsResponse: An object containing news articles. ``` -------------------------------- ### Handling API Errors Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Demonstrates how to catch and handle API errors thrown by the Dinari SDK. It shows how to check the error type and access properties like status code, name, and headers. ```ts const stocks = await client.v2.marketData.stocks.list().catch(async (err) => { if (err instanceof Dinari.APIError) { console.log(err.status); // 400 console.log(err.name); // BadRequestError console.log(err.headers); // {server: 'nginx', ...} } else { throw err; } }); ``` -------------------------------- ### Order Management API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Provides methods for retrieving, listing, and cancelling orders, as well as fetching order fulfillments. Supports various order types and statuses. ```APIDOC GET /api/v2/accounts/{account_id}/orders/{order_id} client.v2.accounts.orders.retrieve(orderID, { ...params }) -> Order Retrieves a specific order by its ID. Parameters: - orderID: The unique identifier of the order. - params: Optional query parameters. Returns: - Order: Details of the retrieved order. ``` ```APIDOC GET /api/v2/accounts/{account_id}/orders client.v2.accounts.orders.list(accountID, { ...params }) -> OrderListResponse Lists all orders for a given account. Parameters: - accountID: The identifier of the account. - params: Optional query parameters for filtering and pagination. Returns: - OrderListResponse: A list of orders and associated metadata. ``` ```APIDOC POST /api/v2/accounts/{account_id}/orders/{order_id}/cancel client.v2.accounts.orders.cancel(orderID, { ...params }) -> Order Cancels a specific order. Parameters: - orderID: The unique identifier of the order to cancel. - params: Optional parameters for cancellation. Returns: - Order: The updated order status after cancellation. ``` ```APIDOC GET /api/v2/accounts/{account_id}/orders/{order_id}/fulfillments client.v2.accounts.orders.getFulfillments(orderID, { ...params }) -> OrderGetFulfillmentsResponse Retrieves the fulfillments for a specific order. Parameters: - orderID: The unique identifier of the order. - params: Optional query parameters. Returns: - OrderGetFulfillmentsResponse: Details of the order's fulfillments. ``` -------------------------------- ### Make Undocumented Requests Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Provides guidance on making requests to undocumented API endpoints using HTTP verbs like `client.post`. Client options such as retries and timeouts are respected for these custom requests. ```typescript await client.post('/some/path', { body: { some_prop: 'foo' }, query: { some_query_arg: 'bar' }, }); ``` -------------------------------- ### Access Raw Response Data Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Demonstrates how to access the underlying `Response` object from the `fetch` API. The `.asResponse()` method provides the raw response, while `.withResponse()` returns both the parsed data and the raw response. ```typescript const client = new Dinari(); const response = await client.v2.marketData.stocks.list().asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); const { data: stocks, response: raw } = await client.v2.marketData.stocks.list().withResponse(); console.log(raw.headers.get('X-My-Header')); console.log(stocks); ``` -------------------------------- ### V2 Entities API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Handles entity management, including creation, updating, listing, and retrieving entities by ID or the current authenticated entity. Supports various parameters for filtering and operations. ```APIDOC client.v2.entities.create({ ...params }) -> Entity - Creates a new entity. - Parameters: - { ...params }: An object containing the data for the new entity. - Returns: - Entity: The newly created entity object. ``` ```APIDOC client.v2.entities.update(entityID, { ...params }) -> Entity - Updates an existing entity. - Parameters: - entityID: The unique identifier for the entity to update. - { ...params }: An object containing the updated data for the entity. - Returns: - Entity: The updated entity object. ``` ```APIDOC client.v2.entities.list({ ...params }) -> EntityListResponse - Lists entities with optional filtering and pagination. - Parameters: - { ...params }: An object containing query parameters for filtering and pagination. - Returns: - EntityListResponse: A response object containing a list of entities. ``` ```APIDOC client.v2.entities.retrieveByID(entityID) -> Entity - Retrieves a specific entity by its unique identifier. - Parameters: - entityID: The unique identifier for the entity. - Returns: - Entity: The requested entity object. ``` ```APIDOC client.v2.entities.retrieveCurrent() -> Entity - Retrieves the current authenticated entity. - Parameters: - None - Returns: - Entity: The current entity object. ``` -------------------------------- ### V2 Market Data API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Enables retrieval of market data, specifically market hours. This method fetches the trading hours for markets. ```APIDOC client.v2.marketData.retrieveMarketHours() -> MarketDataRetrieveMarketHoursResponse - Retrieves the market hours for all supported markets. - Parameters: - None - Returns: - MarketDataRetrieveMarketHoursResponse: An object containing market hours data. ``` -------------------------------- ### V2 Entities Accounts API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Manages accounts associated with entities, allowing creation and listing of accounts for a given entity. Supports optional parameters for filtering. ```APIDOC client.v2.entities.accounts.create(entityID) -> Account - Creates a new account for a specific entity. - Parameters: - entityID: The unique identifier for the entity to which the account belongs. - Returns: - Account: The newly created account object. ``` ```APIDOC client.v2.entities.accounts.list(entityID, { ...params }) -> AccountListResponse - Lists accounts associated with a specific entity. - Parameters: - entityID: The unique identifier for the entity. - { ...params }: An object containing query parameters for filtering and pagination. - Returns: - AccountListResponse: A response object containing a list of accounts for the entity. ``` -------------------------------- ### V2 Market Data Stocks Splits API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Manages stock split information, allowing listing of all splits or splits for a specific stock. Requires optional parameters for filtering. ```APIDOC client.v2.marketData.stocks.splits.list({ ...params }) -> SplitListResponse - Lists all stock splits with optional filtering. - Parameters: - { ...params }: An object containing query parameters for filtering splits. - Returns: - SplitListResponse: A response object containing a list of stock splits. ``` ```APIDOC client.v2.marketData.stocks.splits.listForStock(stockID, { ...params }) -> SplitListForStockResponse - Lists stock splits for a specific stock. - Parameters: - stockID: The unique identifier for the stock. - { ...params }: An object containing query parameters for filtering splits. - Returns: - SplitListForStockResponse: A response object containing splits for the specified stock. ``` -------------------------------- ### Withdrawal Requests API Endpoints (TypeScript SDK) Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Provides methods for managing withdrawal requests within the Dinari API SDK, including creating, retrieving, and listing withdrawal operations. ```APIDOC Withdrawal Requests API Endpoints: client.v2.accounts.withdrawalRequests.create(accountID, { ...params }) - POST /api/v2/accounts/{account_id}/withdrawal_requests - Creates a new withdrawal request. - Parameters: - accountID: The ID of the account from which to withdraw. - { ...params }: Withdrawal details, including amount, currency, and destination. - Returns: WithdrawalRequest object. client.v2.accounts.withdrawalRequests.retrieve(withdrawalRequestID, { ...params }) - GET /api/v2/accounts/{account_id}/withdrawal_requests/{withdrawal_request_id} - Retrieves a specific withdrawal request. - Parameters: - withdrawalRequestID: The ID of the withdrawal request to retrieve. - { ...params }: Optional query parameters. - Returns: WithdrawalRequest object. client.v2.accounts.withdrawalRequests.list(accountID, { ...params }) - GET /api/v2/accounts/{account_id}/withdrawal_requests - Lists all withdrawal requests for a given account. - Parameters: - accountID: The ID of the account. - { ...params }: Optional query parameters for filtering or pagination. - Returns: WithdrawalRequestListResponse object. ``` -------------------------------- ### Order Fulfillment Query API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Provides methods to retrieve specific order fulfillments or query a list of fulfillments based on various criteria. ```APIDOC GET /api/v2/accounts/{account_id}/order_fulfillments/{order_fulfillment_id} client.v2.accounts.orderFulfillments.retrieve(orderFulfillmentID, { ...params }) -> Fulfillment Retrieves a specific order fulfillment by its ID. Parameters: - orderFulfillmentID: The unique identifier of the order fulfillment. - params: Optional query parameters. Returns: - Fulfillment: Details of the retrieved order fulfillment. ``` ```APIDOC GET /api/v2/accounts/{account_id}/order_fulfillments client.v2.accounts.orderFulfillments.query(accountID, { ...params }) -> OrderFulfillmentQueryResponse Queries and lists order fulfillments for a given account. Parameters: - accountID: The identifier of the account. - params: Optional query parameters for filtering and pagination. Returns: - OrderFulfillmentQueryResponse: A list of order fulfillments and associated metadata. ``` -------------------------------- ### EIP-155 Stock Order API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Handles stock order operations specifically for EIP-155 transactions, including fee quoting and order preparation. ```APIDOC POST /api/v2/accounts/{account_id}/orders/stocks/eip155/fee_quote client.v2.accounts.orders.stocks.eip155.getFeeQuote(accountID, { ...params }) -> Eip155GetFeeQuoteResponse Requests a fee quote for an EIP-155 stock order. Parameters: - accountID: The identifier of the account. - params: Parameters required for fee calculation (e.g., order details). Returns: - Eip155GetFeeQuoteResponse: The estimated fee for the transaction. ``` ```APIDOC POST /api/v2/accounts/{account_id}/orders/stocks/eip155/prepare client.v2.accounts.orders.stocks.eip155.prepareOrder(accountID, { ...params }) -> Eip155PrepareOrderResponse Prepares an EIP-155 stock order for submission. Parameters: - accountID: The identifier of the account. - params: Details of the stock order to prepare. Returns: - Eip155PrepareOrderResponse: Information needed to finalize and submit the order. ``` -------------------------------- ### List Withdrawals API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Retrieves a list of all withdrawals associated with a specific account. Supports optional parameters for filtering or pagination. Returns a WithdrawalListResponse object. ```APIDOC GET /api/v2/accounts/{account_id}/withdrawals Lists all withdrawals for a given account. Parameters: - account_id: The ID of the account. - params: Optional query parameters for filtering or pagination. Returns: WithdrawalListResponse object. ``` -------------------------------- ### Configure Request Retries Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/README.md Learn how to set the maximum number of automatic retries for API requests. This includes configuring the default for all requests and overriding it for specific calls. Default retries are 2 with exponential backoff for specific error types. ```javascript const client = new Dinari({ maxRetries: 0, // default is 2 }); await client.v2.marketData.stocks.list({ maxRetries: 5, }); ``` -------------------------------- ### Retrieve Withdrawal API Source: https://github.com/dinaricrypto/dinari-api-sdk-typescript/blob/main/api.md Fetches details for a specific withdrawal using its unique identifier. Requires the account ID and withdrawal ID as parameters. Returns a Withdrawal object. ```APIDOC GET /api/v2/accounts/{account_id}/withdrawals/{withdrawal_id} Retrieves a specific withdrawal by its ID. Parameters: - account_id: The ID of the account. - withdrawal_id: The ID of the withdrawal to retrieve. - params: Optional query parameters. Returns: Withdrawal object. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.