### Install BitGo SDK (All Coins) Source: https://developers.bitgo.com/guides/get-started/sdk/install Installs the main BitGo SDK package, which provides the primary entry point for API functionality and registering coins. ```bash # Main entry point for API functionality npm install bitgo ``` -------------------------------- ### Install TypeScript Globally Source: https://developers.bitgo.com/guides/get-started/sdk/install Installs the TypeScript compiler globally using npm, allowing you to use the `tsc` command in your terminal. ```bash npm install -g typescript ``` -------------------------------- ### Install Project Dependencies Source: https://developers.bitgo.com/guides/get-started/sdk/install Installs essential Node.js packages for your project, including `axios` for HTTP requests, `zod` for schema validation, `cuid` for unique ID generation, `dotenv` for environment variables, and `readline` for command-line input. ```bash npm install axios zod cuid dotenv readline ``` -------------------------------- ### Install BitGo Express Source: https://developers.bitgo.com/guides/get-started/intro This snippet demonstrates how to install BitGo Express, a server that provides the same functionality as the BitGo JavaScript SDK for applications not written in JavaScript. ```bash npm install --save bitgo-express ``` -------------------------------- ### Get Token Constants API 500 Response Source: https://developers.bitgo.com/api/stablecoin.v1.token Example of a server error response (500) from the Get Token Constants API. ```JSON {} ``` -------------------------------- ### Get Token Constants API 400 Response Source: https://developers.bitgo.com/api/stablecoin.v1.token Example of a client error response (400) from the Get Token Constants API. ```JSON {} ``` -------------------------------- ### Initialize BitGo SDK Instance Source: https://developers.bitgo.com/guides/get-started/sdk/install Demonstrates how to import and initialize the BitGo SDK in a JavaScript project, creating an instance to interact with BitGo services. ```javascript import { BitGo } from 'bitgo'; const sdk = new BitGo(); ``` -------------------------------- ### Install BitGo JavaScript SDK Source: https://developers.bitgo.com/guides/get-started/intro This snippet shows how to install the BitGo JavaScript SDK, which allows programmatic interaction with the BitGo platform for applications written in JavaScript. ```bash npm install --save bitgo ``` -------------------------------- ### Get Token Constants API 200 Response Source: https://developers.bitgo.com/api/stablecoin.v1.token Example of a successful response (200) from the Get Token Constants API, returning the trust account wallet ID. ```JSON { "trustAccountWalletId": "fake_trust_go_account_id" } ``` -------------------------------- ### Get Block Lists - 400 Response Source: https://developers.bitgo.com/api/V1GetBlockListsRoute This is an example of a bad request response (HTTP 400) for the get block list endpoint. It typically indicates that the request parameters were invalid or missing. ```json {} ``` -------------------------------- ### BitGo API 400 Bad Request Response Example Source: https://developers.bitgo.com/api/stablecoin.v1.enterprise This is an example of a 400 Bad Request response from the BitGo API. An empty JSON object typically indicates that the request was malformed or missing required parameters, but the specific error details are not provided in this minimal example. ```json {} ``` -------------------------------- ### Configure .env File for BitGo SDK Source: https://developers.bitgo.com/guides/get-started/sdk/install Sets up the environment variables required for the BitGo SDK, including access token, environment, passphrase, enterprise ID, and BitGo Express URL. ```dotenv ACCESS_TOKEN= ENV=test WALLET_PASSPHRASE= ENTERPRISE_ID= BITGO_EXPRESS_URL= ``` -------------------------------- ### Get Client Connection - Unauthorized Response Source: https://developers.bitgo.com/api/v1ClientConnectionGetRoute This code block illustrates a 401 Unauthorized error response. This error is returned when the request is not authorized, for example, if the caller is not a member of the specified enterprise. ```json { "error": "string" } ``` -------------------------------- ### Close Position Request Response Example Source: https://developers.bitgo.com/api/trade.margin.positions.close This is an example of a successful (200 OK) response when fetching the details of a close position request. It includes the request ID, status, currencies involved, and relevant timestamps. ```JSON { "closePositionsRequestId": "b2c3d4e5-f6g7-8901-bcde-f23456789012", "status": "pending", "currencies": [ "BTC", "ETH" ], "createdAt": "2024-01-15T11:00:00.000Z", "updatedAt": "2024-01-15T11:00:00.000Z" } ``` -------------------------------- ### Initialize Lightning Wallet with BitGo Source: https://developers.bitgo.com/guides/wallets/lightning/self-custody Initializes a Lightning wallet by setting environment variables for host, coin, wallet ID, access token, passphrase, enterprise ID, and express host. It then makes a POST request to the BitGo API's 'initwallet' endpoint with the wallet label, passphrase, and express host. ```bash export BITGO_EXPRESS_HOST="" export COIN="tlntbc" export WALLET_ID="" export ACCESS_TOKEN="" export PASSPHRASE="" export ENTERPRISE_ID="" export EXPRESS_HOST="" curl -X POST \ http://$BITGO_EXPRESS_HOST/api/v2/$COIN/wallet/$WALLETID/initwallet \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -d '{ "label": "'"$LABEL"'", "passphrase": "'"$PASSPHRASE"'", "expressHost": "'"$EXPRESS_HOST"'" # Provides additional security by binding macaroons to the Express server IP (recommended) }' ``` -------------------------------- ### POST /bitgo/v1/allocations Request Example Source: https://developers.bitgo.com/guides/go-network/off-exchange-settlement/partner/allocate This snippet demonstrates a sample request body for the POST /bitgo/v1/allocations endpoint. It includes essential parameters like allocationId, amount, clientId, connectionId, partnersConnectionId, and partnersClientId. ```json { "allocationId": "alloc_123abc", "amount": { "currency": "BTC", "quantity": "1000000" }, "clientId": "client_456def", "connectionId": "conn_789ghi", "partnersConnectionId": "partner_conn_012jkl", "partnersClientId": "partner_client_345mno" } ``` -------------------------------- ### Get Level1 Order Book Error Response (JSON) Source: https://developers.bitgo.com/api/trade.products Provides an example of an error response when attempting to retrieve the level 1 order book. Includes error message, error name, and request ID for debugging. ```json { "error": "invalid permission", "errorName": "backend:common:forbidden", "reqId": "d41d4d21e63d63b293caf55f2a739a79" } ``` -------------------------------- ### BitGo API 404 Not Found Response Example Source: https://developers.bitgo.com/api/stablecoin.v1.enterprise This is an example of a 404 Not Found response from the BitGo API. An empty JSON object suggests that the requested resource could not be located, but further details about the missing resource are not included in this basic representation. ```json {} ``` -------------------------------- ### Get Wallet Details using BitGo SDK Source: https://developers.bitgo.com/guides/wallets/view/balances This snippet demonstrates how to initialize the BitGo API, register a coin, and retrieve wallet details using the SDK. It requires environment variables for the BitGo environment, access token, and wallet ID. ```javascript import * as dotenv from "dotenv"; import {EnvironmentName} from "bitgo"; import {BitGoAPI} from "@bitgo/sdk-api"; import {Tbtc4} from "@bitgo/sdk-coin-btc"; dotenv.config(); const bitgo = new BitGoAPI({ env: process.env.ENV as EnvironmentName, accessToken: process.env.TESTNET_ACCESS_TOKEN }); const coin = 'tbtc4'; bitgo.register(coin, Tbtc4.createInstance); const walletId = process.env.WALLET_ID; async function main() { const wallet = await bitgo.coin(coin).wallets().get({id: walletId}); console.dir(wallet._wallet); } main().catch((err) => console.error(err)); ``` -------------------------------- ### Create Enterprise Listing - cURL Source: https://developers.bitgo.com/guides/go-network/counterparties This cURL command creates a new enterprise listing in the global directory. It requires an access token and a public description for the enterprise. The response includes details about the newly created listing. ```bash export ACCESS_TOKEN="" export DESCRIPTION="" curl -X POST \ https://app.bitgo-test.com/api/address-book/v1/listing/global \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -d '{"description": "'$DESCRIPTION'"}' ``` -------------------------------- ### Get Stellar Token Transfer Details API Route Source: https://developers.bitgo.com/coins/stellar-tokens This example shows the HTTP GET request format to retrieve detailed information about a specific Stellar token transfer. It requires the token name, wallet ID, and transfer ID as path parameters. ```HTTP GET /api/v2/txlm:BST-GBQTIOS3XGHB7LVYGBKQVJGCZ3R4JL5E4CBSWJ5ALIJUHBKS6263644L/wallet/5a13adcab70f2c284fdd9682db5e6d64/transfer/5b612d25c9067f2a1db11a15f165989e ``` -------------------------------- ### Create and Retrieve Wallet Address using BitGo SDK Source: https://developers.bitgo.com/guides/wallets/create/addresses This snippet demonstrates how to initialize the BitGo SDK, generate a new wallet, and then create a new address for that wallet. It also shows how to retrieve an existing wallet by its ID. The code handles potential asynchronous operations and logs the resulting address details. ```JavaScript const { BitGo } = require('bitgo'); // Fill in with actual access token const accessToken = ''; // Initialize the SDK const bitgo = new BitGo({ accessToken: accessToken, env: 'custom', customRootURI: 'https://app.bitgo.com', }); // Create the wallet const { wallet } = await bitgo.coin('tbtc4').wallets().generateWallet({ label: 'my hot Wallet', passphrase: 'VerySecurePassword1234', enterprise: '5612c2beeecf83610b621b90964448cd' }); // Or Alternatively you can get an existing wallet const walletId = '63bc8506e014900008265c65363245f4' const existingWallet = await bitgo.coin('tbtc4').wallets().get({ id: walletId }); // use the appropriate wallet instance to create new address const address = await wallet.createAddress({ walletVersion: 3, // Required for ECDSA assets, such as ETH and MATIC }); console.log(JSON.stringify(address, undefined, 2)); ``` -------------------------------- ### Retrieve Transfer Details API Endpoint Example Source: https://developers.bitgo.com/coins/test-ethereum-terc20-tokens This example shows an HTTP GET request to the BitGo API to retrieve detailed information about a specific ERC20 token transfer. It requires the token name, wallet ID, and transfer ID. ```http GET /api/v2/terc/wallet/5a13adcab70f2c284fdd9682db5e6d64/transfer/5b612d25c9067f2a1db11a15f165989e ``` -------------------------------- ### Organization Details Response (JSON) Source: https://developers.bitgo.com/guides/crypto-as-a-service/organization This JSON response provides details about an enterprise, including its ID, name, organization ID, and associated wallets. It is a partial response highlighting key organization information. ```JSON { "id": "62c5ae8174ac860007aff138a2d74df7", "name": "Prestige Worldwide", "type": "Other", "organizationId": "62c5ae8174ac860007aff1555ffb960d", "wallets": [] } ``` -------------------------------- ### BitGo API 500 Internal Server Error Response Example Source: https://developers.bitgo.com/api/stablecoin.v1.enterprise This is an example of a 500 Internal Server Error response from the BitGo API. An empty JSON object indicates a server-side problem prevented the request from being fulfilled, without providing specific error diagnostics. ```json {} ``` -------------------------------- ### Default Error Response for Level2 Order Book Source: https://developers.bitgo.com/api/products Example of a default error response from the Level2 Order Book API, indicating an invalid permission issue. ```JSON { "error": "invalid permission", "errorName": "backend:common:forbidden", "reqId": "d41d4d21e63d63b293caf55f2a739a79" } ``` -------------------------------- ### Run BitGo Express Docker Container Source: https://developers.bitgo.com/guides/get-started/express/install This command runs the BitGo Express Docker container, exposing port 3080 for communication. The `-it` flags allow interactive mode and allocate a pseudo-TTY. ```bash docker run -it -p 3080:3080 bitgo/express:latest ``` -------------------------------- ### Create Listing Entry for Go Account - cURL Source: https://developers.bitgo.com/guides/go-network/counterparties This cURL command creates a listing entry for a Go Account within an enterprise listing. It requires an access token, wallet ID, and a public description. The entry is marked as public, allowing discoverability for connections. ```bash export ACCESS_TOKEN="" export WALLET_ID="" export DESCRIPTION="" curl -X POST \ https://app.bitgo-test.com/api/address-book/v1/listing/entry/global \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -d '{ \ "walletId": "'$WALLET_ID'", \ "description": "'$DESCRIPTION'", \ "public": true \ }' ``` -------------------------------- ### Successful Settlement Response (200 OK) Source: https://developers.bitgo.com/api/V1GetSettlementByIdRoute Example JSON response for a successful retrieval of settlement data. It includes arrays for approval requests and settlement transfers, along with various metadata. ```JSON { "approvalRequests": [ { "approvedAt": "2019-08-24", "createdAt": "2019-08-24", "updatedAt": "2019-08-24", "id": "string", "accountId": "string", "status": "acknowledged", "payload": "string", "signature": "string" } ], "settlementTransfers": [ { "createdAt": "2019-08-24", "updatedAt": "2019-08-24", "id": "string", "sourceTradingAccountId": "string", "destinationTradingAccountId": "string", "currency": "string", "quantity": "string", "txIds": [ "string" ] } ], "requesterAccountName": "string", "finalizedAt": "2019-08-24", "createdAt": "2019-08-24", "updatedAt": "2019-08-24", "id": "string", "externalId": "string", "notation": "string", "requesterAccountId": "string", "status": "canceled", "type": "direct" } ``` -------------------------------- ### Configure BitGo SDK for Production Source: https://developers.bitgo.com/guides/get-started/environments When using the BitGo SDK, specify the production environment by passing an environment option. This ensures your application interacts with the live BitGo services. ```javascript const bitgo = new BitGo({ env: 'prod' }); ``` -------------------------------- ### Successful Level2 Order Book Response Source: https://developers.bitgo.com/api/products Example of a successful response from the Level2 Order Book API, showing the order book for BTC-USD with bid and ask prices and sizes. ```JSON { "time": {}, "product": "BTC-USD", "bids": [ [ "7090.96", "1.253433" ] ], "asks": [ [ "7090.97", "25.23881" ] ] } ``` -------------------------------- ### List Supported Assets API Request Source: https://developers.bitgo.com/api/stablecoin.v1 This snippet shows how to make a GET request to the BitGo API to retrieve a list of supported stablecoin assets. It includes example query parameters for filtering the results. ```HTTP GET /api/stablecoin/v1/assets?ids=d1c27189-764c-4197-af06-e2623658f410&token=eth:usd1&chain=eth&isIssuedByBitgo=true ``` -------------------------------- ### Get Wallet Balance with All Stellar Tokens Source: https://developers.bitgo.com/coins/stellar-tokens Retrieve all token details associated with a Stellar wallet, including balance, pending approvals, policies, and webhooks. This is achieved by setting the 'allTokens' parameter to true in specific API calls. The example shows how to expand balance information. ```HTTP {{baseUrl}}/api/v2/xlm/wallet/{walletId}}?expandBalance=true&allTokens=true ``` -------------------------------- ### Sample Scope ID JSON Response Source: https://developers.bitgo.com/guides/policies/create This is an example of the JSON response received after successfully listing scopes. It includes scope details like ID, name, label, description, and associated conditions. ```json { "scopes": [ { "id": "c8234a0f-7722-44d7-bedc-bfded7bd24a7", "name": "wallet.segregated", "label": "Wallet", "description": "A BitGo Wallet", "conditions": [ { "name": "wallet.type", "label": "Wallet Type", "description": "Allows creating a Condition based on the Wallet Type", "status": "ACTIVE", "parameters": [ { "name": "walletType", "label": "Type", "description": "The Wallet Type", "type": "ENUMERATED", "required": "ALWAYS", "allowMultiple": true, "values": [ { "value": "custodial", "label": "Custody Wallet", "description": "A custody wallet" }, { "value": "hot", "label": "Hot Wallet", "description": "A hot wallet" }, { "value": "cold", "label": "Self-custody cold wallet", "description": "A cold wallet" }, { "value": "trading", "label": "Go Account", "description": "A trading wallet" } ] } ] }, { "name": "wallet.ids", "label": "Single Wallet", "description": "Allows creating a Condition based on the Wallet Id", "status": "ACTIVE", "parameters": [ { "name": "walletId", "label": "Wallet Id", "description": "The Wallet Ids", "type": "BITGO_WALLET_ID", "required": "ALWAYS", "allowMultiple": false, "values": [] } ] }, { "name": "wallet.all", "label": "All wallets in my enterprise", "description": "Applies to All Wallets", "status": "ACTIVE", "parameters": [] } ] } ] } ``` -------------------------------- ### Get Settlement by ID (HTTP GET) Source: https://developers.bitgo.com/api/V1GetSettlementByIdRoute This snippet shows the HTTP GET request to retrieve a specific settlement by its ID. It includes the necessary path parameters for enterprise, account, and settlement identification. ```HTTP GET `/api/clearing/v1/enterprise/{enterpriseId}/account/{accountId}/settlement/{settlementId}` ``` -------------------------------- ### Add User to Enterprise - cURL Example Source: https://developers.bitgo.com/guides/crypto-as-a-service/organization This cURL command demonstrates how to add users with 'admin' permissions to an enterprise. It requires the enterprise ID and an access token for authentication. The request body specifies the permission level and a list of usernames to be added. ```cURL export ENTERPRISE_ID="" export ACCESS_TOKEN="" curl -X POST \ "https://app.bitgo-test.com/api/v2/enterprise/$ENTERPRISE_ID/user" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -d '{ "permission": "admin", "usernames": [ "user1@example.com", "user2@example.com", "user3@example.com" ]' } ``` -------------------------------- ### POST /bitgo/v1/allocations 200 Response Example Source: https://developers.bitgo.com/guides/go-network/off-exchange-settlement/partner/allocate This snippet shows a successful (200 OK) response from the POST /bitgo/v1/allocations endpoint. It includes allocation details and optionally a rejectionReason. ```json { "allocationId": "alloc_123abc", "amount": { "currency": "BTC", "quantity": "1000000" }, "clientId": "client_456def", "connectionId": "conn_789ghi", "partnersClientId": "partner_client_345mno", "partnersConnectionId": "partner_conn_012jkl", "partnersAllocationId": "my_alloc_id_789" } ``` -------------------------------- ### BitGo API Success Response Example Source: https://developers.bitgo.com/api/stablecoin.v1.enterprise This JSON object represents a successful API call within the BitGo platform, likely for a mint transaction. It includes details about the source and destination assets, amounts, wallet IDs, user ID, transaction hashes, order history, and the overall status of the operation. ```json { "fromAssetId": "08c1271e-b15d-4af8-8929-f75383903da4", "fromAmount": "500", "toAssetId": "49ff49ea-3355-4717-bbb0-5e8f5cae2202", "toAmount": "5000000", "destinationType": "go_account", "sourceWalletId": "67bc4b038f5408faefbfc8edcf6e6577", "destinationWalletId": "67bc4b038f5408faefbfc8edcf6e6577", "destinationAddress": "default_address", "userId": "677cfdceca8396cf5f7534ddeb8d11e3", "clientDepositTxHash": "512f64d10b5f358f6dbf3303f90013cfa46006b02a03282456d6bd6432cc5daf", "orderHistories": [ { "status": "created", "timestamp": "2025-04-04T09:25:48.216Z" } ], "transactions": [ { "txId": "512f64d10b5f358f6dbf3303f90013cfa46006b02a03282456d6bd6432cc5daf", "orderId": "95bdbd9c-9cdc-41a4-ae70-165387b7aa51", "assetId": "08c1271e-b15d-4af8-8929-f75383903da4", "type": "clientDeposit", "sender": "client", "senderType": "go_account", "senderId": "67bc4b038f5408faefbfc8edcf6e6577", "sendAmount": "500", "receiver": "trust", "receiverType": "go_account", "receiverId": "6698e670115059e2efe672436a3aea3b", "receiveAmount": "500", "status": "confirmed", "createdAt": "2025-04-04T09:26:21.600Z", "updatedAt": "2025-04-04T09:26:21.600Z", "pendingApprovalId": "string" } ], "metadata": "string", "createdAt": "2025-04-04T09:25:48.216Z", "updatedAt": "2025-04-04T09:55:09.136Z", "id": "95bdbd9c-9cdc-41a4-ae70-165387b7aa51", "type": "mint", "status": "fulfilled", "enterpriseId": "67bc4ae090e8af8f9b412d3d67e85252" } ``` -------------------------------- ### Configure BitGo Express API for Production Source: https://developers.bitgo.com/guides/get-started/environments When running the BitGo Express API, use the command-line flag to specify the production environment. This is crucial for directing traffic to the correct BitGo services. ```bash node express.js -e prod ``` -------------------------------- ### Download Wallet Recovery Wizard from GitHub Source: https://developers.bitgo.com/guides/wallets/recover Instructions on how to download the Wallet Recovery Wizard software. The software is available for download from the official GitHub repository. ```Documentation 1. Download the Wallet Recovery Wizard This software is available for you to download from our GitHub repository. ``` -------------------------------- ### Get Signing Payload 409 Response Source: https://developers.bitgo.com/api/v1PartnerExtDepositsSigningGetRoute The 409 Conflict response for the Get Signing Payload API call. ```json { "error": "string" } ``` -------------------------------- ### Create Listing Entry Response - JSON Source: https://developers.bitgo.com/guides/go-network/counterparties This JSON object details the created listing entry for a Go Account. It includes the entry's ID, associated wallet ID, coin type, description, and discoverability status. ```json { "id": "string", "walletId": "string", "coin": "string", "type": "GO_ACCOUNT", "description": "string", "discoverable": true, "featured": true, "createdAt": "string", "updatedAt": "string" } ``` -------------------------------- ### Get Signing Payload 404 Response Source: https://developers.bitgo.com/api/v1PartnerExtDepositsSigningGetRoute The 404 Not Found response for the Get Signing Payload API call. ```json { "error": "string" } ```