### HTTP Request Example for getMe Source: https://help.send.tg/en/articles/10279948-crypto-pay-api This example demonstrates how to make a GET request to the /api/getMe endpoint. Ensure your API token is included in the 'Crypto-Pay-API-Token' header. ```http GET /api/getMe HTTP/1.1 Host: pay.crypt.bot Crypto-Pay-API-Token: 123456789:AAzQcZWQqQAbsfgPnOLr4FHC8Doa4L7KryC ``` -------------------------------- ### Authorization Example Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Example of how to authorize your app and make an API request using the Crypto-Pay-API-Token header. ```APIDOC ## Authorizing your app First, you need to create a new app and get API token. Open [@CryptoBot](http://t.me/CryptoBot?start=pay) ([@CryptoTestnetBot](http://t.me/CryptoTestnetBot?start=pay) for testnet), go to **[Crypto Pay](https://t.me/CryptoBot?start=pay)** and tap **Create App** to get API Token. All queries to Crypto Pay API must be served over **HTTPS**. Use either [URL query string](https://en.wikipedia.org/wiki/Query_string) or *application/json* or *application/x-www-form-urlencoded* or *multipart/form-data* for passing parameters. API Token must be passed in the header parameter `Crypto-Pay-API-Token`. URL must be presented in this form: `%`. ### Request Example ```http GET /api/getMe HTTP/1.1 Host: pay.crypt.bot Crypto-Pay-API-Token: 123456789:AAzQcZWQqQAbsfgPnOLr4FHC8Doa4L7KryC ``` ``` -------------------------------- ### getBalance Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Use this method to get balances of your app. Requires no parameters. Returns array of Balance. ```APIDOC ## getBalance ### Description Use this method to get balances of your app. Requires no parameters. Returns array of Balance. ### Method GET ### Endpoint /getBalance ``` -------------------------------- ### getInvoices Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Use this method to get invoices created by your app. On success, returns array of Invoice. ```APIDOC ## getInvoices ### Description Use this method to get invoices created by your app. On success, returns array of Invoice. ### Method GET ### Endpoint /getInvoices ### Parameters #### Query Parameters - **asset** (String) - Optional - Cryptocurrency alphabetic code. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC” (and “JET” for testnet). Defaults to all currencies. - **fiat** (String) - Optional - Fiat currency code. Supported fiat currencies: “USD”, “EUR”, “RUB”, “BYN”, “UAH”, “GBP”, “CNY”, “KZT”, “UZS”, “GEL”, “TRY”, “AMD”, “THB”, “INR”, “BRL”, “IDR”, “AZN”, “AED”, “PLN” and “ILS". Defaults to all currencies. - **invoice_ids** (String) - Optional - List of invoice IDs separated by comma. - **status** (String) - Optional - Status of invoices to be returned. Available statuses: “active” and “paid”. Defaults to all statuses. - **offset** (Number) - Optional - Offset needed to return a specific subset of invoices. Defaults to 0. - **count** (Number) - Optional - Number of invoices to be returned. Values between 1-1000 are accepted. Defaults to 100. ``` -------------------------------- ### getMe Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Tests the app's authentication token and returns basic information about the app. Requires no parameters. ```APIDOC ## getMe ### Description Use this method to test your app's authentication token. Requires no parameters. On success, returns basic information about an app. ### Method GET or POST ### Endpoint /getMe ``` -------------------------------- ### createInvoice Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Creates a new invoice with specified details. Supports various optional parameters for currency, amount, description, and payment options. ```APIDOC ## createInvoice ### Description Use this method to create a new invoice. On success, returns an object of the created **[invoice](#h_51387755f0).** ### Method POST ### Endpoint /createInvoice ### Parameters #### Request Body - **currency_type** (String) - Optional - Type of the price, can be “crypto” or “fiat”. Defaults to *crypto*. - **asset** (String) - Optional - Required if *currency_type* is “crypto”. Cryptocurrency alphabetic code. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC”. - **fiat** (String) - Optional - Required if *currency_type* is “fiat”. Fiat currency code. Supported fiat currencies: “USD”, “EUR”, “RUB”, “BYN”, “UAH”, “GBP”, “CNY”, “KZT”, “UZS”, “GEL”, “TRY”, “AMD”, “THB”, “INR”, “BRL”, “IDR”, “AZN”, “AED”, “PLN” and “ILS". - **accepted_assets** (String) - Optional - List of cryptocurrency alphabetic codes separated comma. Assets which can be used to pay the invoice. Available only if *currency_type* is “fiat”. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC” (and “JET” for testnet). Defaults to all currencies. - **amount** (String) - Amount of the invoice in float. For example: *`125.50`* - **swap_to** (String) - Optional - The asset that will be attempted to be swapped into after the user makes a payment (the swap is not guaranteed). Supported assets: "USDT", "TON", "TRX", "ETH", "SOL", "BTC", "LTC". - **description** (String) - Optional - Description for the invoice. User will see this description when they pay the invoice. Up to 1024 characters. - **hidden_message** (String) - Optional - Text of the message which will be presented to a user after the invoice is paid. Up to 2048 characters. - **paid_btn_name** (String) - Optional - Label of the button which will be presented to a user after the invoice is paid. Supported names: `viewItem` – “View Item”, `openChannel` – “View Channel”, `openBot` – “Open Bot”, `callback` – “Return”. - **paid_btn_url** (String) - Optional - Required if *paid_btn_name* is specified. URL opened using the button which will be presented to a user after the invoice is paid. You can set any callback link (for example, a success link or link to homepage). Starts with *https* or *http*. - **payload** (String) - Optional - Any data you want to attach to the invoice (for example, user ID, payment ID, ect). Up to 4kb. - **allow_comments** (Boolean) - Optional - Allow a user to add a comment to the payment. Defaults to *true*. - **allow_anonymous** (Boolean) - Optional - Allow a user to pay the invoice anonymously. Defaults to *true*. - **expires_in** (Number) - Optional - You can set a payment time limit for the invoice in seconds. Values between 1-2678400 are accepted. ### Response #### Success Response (200) - **invoice** (Object) - The created invoice object. ``` -------------------------------- ### getTransfers Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Use this method to get transfers created by your app. On success, returns array of Transfer. ```APIDOC ## getTransfers ### Description Use this method to get transfers created by your app. On success, returns array of Transfer. ### Method GET ### Endpoint /getTransfers ### Parameters #### Query Parameters - **asset** (String) - Optional - Cryptocurrency alphabetic code. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC” (and “JET” for testnet). Defaults to all currencies. - **transfer_ids** (String) - Optional - List of transfer IDs separated by comma. - **spend_id** (String) - Optional - Unique UTF-8 transfer string. - **offset** (Number) - Optional - Offset needed to return a specific subset of transfers. Defaults to 0. - **count** (Number) - Optional - Number of transfers to be returned. Values between 1-1000 are accepted. Defaults to 100. ``` -------------------------------- ### createInvoice Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Creates a new invoice for a specified amount and currency. Supports fiat currency amounts and accepted assets. ```APIDOC ## POST /api/createInvoice ### Description Creates a new invoice for a specified amount and currency. Supports fiat currency amounts and accepted assets. ### Method POST ### Endpoint /api/createInvoice ### Parameters #### Query Parameters - **currency_type** (string) - Required - The type of currency for the invoice (e.g., 'crypto', 'fiat'). - **fiat** (string) - Optional - The fiat currency code if `currency_type` is 'fiat' (e.g., 'USD', 'EUR'). - **accepted_assets** (string) - Optional - A comma-separated list of crypto assets that can be used to pay the invoice. ### Request Example ```json { "amount": 10, "currency_type": "fiat", "fiat": "USD", "accepted_assets": "BTC,ETH" } ``` ### Response #### Success Response (200) - **invoice_id** (string) - The unique identifier for the created invoice. - **status** (string) - The current status of the invoice. - **amount** (number) - The amount of the invoice. - **currency_type** (string) - The type of currency used for the invoice. - **fiat** (string) - The fiat currency code if applicable. - **accepted_assets** (array) - The list of accepted crypto assets. - **bot_invoice_url** (string) - The URL to the invoice for payment. - **expiration_date** (string) - The date and time when the invoice expires. #### Response Example ```json { "invoice_id": "inv_12345abcde", "status": "awaiting_payment", "amount": 10, "currency_type": "fiat", "fiat": "USD", "accepted_assets": ["BTC", "ETH"], "bot_invoice_url": "https://pay.crypt.bot/i/inv_12345abcde", "expiration_date": "2024-03-15T10:00:00Z" } ``` ``` -------------------------------- ### getChecks Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Use this method to get checks created by your app. On success, returns array of Check. ```APIDOC ## getChecks ### Description Use this method to get checks created by your app. On success, returns array of Check. ### Method GET ### Endpoint /getChecks ### Parameters #### Query Parameters - **asset** (String) - Optional - Cryptocurrency alphabetic code. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC” (and “JET” for testnet). Defaults to all currencies. - **check_ids** (String) - Optional - List of check IDs separated by comma. - **status** (String) - Optional - Status of check to be returned. Available statuses: “active” and “activated”. Defaults to all statuses. - **offset** (Number) - Optional - Offset needed to return a specific subset of check. Defaults to 0. - **count** (Number) - Optional - Number of check to be returned. Values between 1-1000 are accepted. Defaults to 100. ``` -------------------------------- ### getStats Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Retrieves application statistics. Optional parameters allow specifying a date range for the statistics. ```APIDOC ## getStats ### Description Use this method to get app statistics. ### Method GET ### Endpoint /getStats ### Parameters #### Query Parameters - **start_at** (String) - Optional - Date from which to start calculating statistics in ISO 8601 format. Defaults to current date minus 24 hours. - **end_at** (String) - Optional - The date on which to finish calculating statistics in ISO 8601 format. Defaults to current date. ### Response #### Success Response (200) On success, returns [AppStats](#h_9446aa26c6). ``` -------------------------------- ### getStats Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Retrieves statistics for the application, such as total revenue and number of invoices. ```APIDOC ## GET /api/getStats ### Description Retrieves statistics for the application, such as total revenue and number of invoices. ### Method GET ### Endpoint /api/getStats ### Response #### Success Response (200) - **revenue** (number) - Total revenue generated. - **invoices_count** (integer) - The total number of invoices created. - **paid_invoices_count** (integer) - The number of invoices that have been paid. #### Response Example ```json { "revenue": 1500.75, "invoices_count": 120, "paid_invoices_count": 105 } ``` ``` -------------------------------- ### createCheck Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Use this method to create a new check. On success, returns an object of the created check. ```APIDOC ## createCheck ### Description Use this method to create a new check. On success, returns an object of the created check. ### Method POST ### Endpoint /createCheck ### Parameters #### Request Body - **asset** (String) - Required - Cryptocurrency alphabetic code. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC” (and “JET” for testnet). - **amount** (String) - Required - Amount of the check in float. For example: *`125.50`* - **pin_to_user_id** (Number) - Optional - ID of the user who will be able to activate the check. - **pin_to_username** (String) - Optional - A user with the specified username will be able to activate the check. ``` -------------------------------- ### getCurrencies Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Fetches a list of all supported fiat and cryptocurrency alphabetic codes. This method does not require any parameters. ```APIDOC ## getCurrencies ### Description Use this method to get a list of supported currencies. ### Method GET ### Endpoint /getCurrencies ### Parameters This method requires no parameters. ### Response #### Success Response (200) Returns a list of fiat and cryptocurrency alphabetic codes. ``` -------------------------------- ### Balance Object Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Represents the available and on-hold balance for a specific cryptocurrency. ```APIDOC ## Balance Object Represents the balance for a specific cryptocurrency. ### Fields - **currency_code** (String) - Cryptocurrency alphabetic code. Supported: "USDT", "TON", "BTC", "ETH", "LTC", "BNB", "TRX", "USDC" (and "JET" for testnet). - **available** (String) - Total available amount in float. - **onhold** (String) - Unavailable amount currently on hold in float. ``` -------------------------------- ### Check Object Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Represents a cryptocurrency check, which can be activated by a user. ```APIDOC ## Check Object Represents a cryptocurrency check. ### Fields - **check_id** (Number) - Unique ID for this check. - **hash** (String) - Hash of the check. - **asset** (String) - Cryptocurrency alphabetic code. Supported: "USDT", "TON", "BTC", "ETH", "LTC", "BNB", "TRX", "USDC" (and "JET" for testnet). - **amount** (String) - Amount of the check in float. - **bot_check_url** (String) - URL to provide to the user to activate the check. - **status** (String) - Status of the check, can be "active" or "activated". - **created_at** (String) - Date the check was created in ISO 8601 format. - **activated_at** (String) - Date the check was activated in ISO 8601 format. ``` -------------------------------- ### ExchangeRate Object Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Provides information about the current exchange rate between two currencies. ```APIDOC ## ExchangeRate Object Provides information about the current exchange rate. ### Fields - **is_valid** (Boolean) - *True* if the received rate is up-to-date. - **is_crypto** (Boolean) - *True* if the source currency is a cryptocurrency. - **is_fiat** (Boolean) - *True* if the source currency is a fiat currency. - **source** (String) - Source asset. Supported cryptocurrencies: "USDT", "TON", "BTC", "ETH", "LTC", "BNB", "TRX", "USDC". - **target** (String) - Target currency. Supported fiat currencies: "USD", "EUR", "RUB", "BYN", "UAH", "GBP", "CNY", "KZT", "UZS", "GEL", "TRY", "AMD", "THB", "INR", "BRL", "IDR", "AZN", "AED", "PLN", "ILS". - **rate** (String) - The current rate of the *source* asset valued in the *target* currency. ``` -------------------------------- ### getExchangeRates Source: https://help.send.tg/en/articles/10279948-crypto-pay-api Retrieves the exchange rates for all supported currencies. This method does not require any parameters. ```APIDOC ## getExchangeRates ### Description Use this method to get exchange rates of supported currencies. ### Method GET ### Endpoint /getExchangeRates ### Parameters This method requires no parameters. ### Response #### Success Response (200) Returns an array of [ExchangeRate](#h_532277de9c). ```