Exchange rate
The method returns the conversion rate between two currencies for the specified project. Use it before calculating payment or payout amounts in another currency.
HTTP request format is in API request format.
How it works
- Request — your server calls
get_ratewithpartner_id,project_id,currency_from,currency_to, andsignsignature. - Verification — the API verifies the signature and partner access to the project.
- Response — JSON with
rate: how many units ofcurrency_tocorrespond to one unit ofcurrency_from.
Technical details
| Endpoint | https://api.1payment.com/get_rate |
| Method | GET |
| Response format | JSON |
| Authorization | API Key — used in sign signature generation |
Request parameters
Required
| Parameter | Type | Description |
|---|---|---|
partner_id | Integer | Your unique ID in the 1Payment system. |
project_id | Integer | Project identifier. |
currency_from | String | Source currency (ISO code, e.g. usdt). |
currency_to | String | Target currency (ISO code, e.g. rub). |
sign | String | Request signature (see "Signature" section). |
Signature generation (sign)
Signature: MD5, lowercase (hex). General rules — API request format.
Formula:
MD5(get_rate + <parameters_without_sign_in_alphabetical_order_joined_by_&> + <API_KEY>)Example string before hashing:
get_ratecurrency_from=usdt¤cy_to=rub&partner_id=1234&project_id=5678secret_keySignature verification in the documentation
Signature check for {{method}}
Paste the request parameters (JSON), API key, and signature. The widget verifies them automatically.
Parameter string:
currency_from=usdt¤cy_to=rub&partner_id=1234&project_id=5678String for MD5:
get_ratecurrency_from=usdt¤cy_to=rub&partner_id=1234&project_id=5678Expected signature:
e6361ec42b5d5e2cee28968b4528e291Signature does not match
Request examples
const crypto = require('crypto');
const axios = require('axios');
async function getRate(apiKey, partnerId, projectId, currencyFrom, currencyTo) {
const params = {
partner_id: partnerId,
project_id: projectId,
currency_from: currencyFrom,
currency_to: currencyTo,
};
// 1. Сортировка параметров по алфавиту
const sortedKeys = Object.keys(params).sort();
const queryString = sortedKeys.map((key) => `${key}=${params[key]}`).join('&');
// 2. Подпись с префиксом get_rate
const baseString = `get_rate${queryString}${apiKey}`;
params.sign = crypto.createHash('md5').update(baseString).digest('hex');
// 3. GET-запрос
const response = await axios.get('https://api.1payment.com/get_rate', { params });
return response.data;
}
const apiKey = process.env.ONEPAYMENT_API_KEY;
getRate(apiKey, 1234, 5678, 'usdt', 'rub').then(console.log);API response
Successful response (200):
{
"rate": 72.44
}| Field | Type | Description |
|---|---|---|
rate | Number | Conversion rate currency_from → currency_to. |
Request error (400):
{
"error_code": 2
}error_code meanings — in Error codes (API).