Skip to content

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

  1. Request — your server calls get_rate with partner_id, project_id, currency_from, currency_to, and sign signature.
  2. Verification — the API verifies the signature and partner access to the project.
  3. Response — JSON with rate: how many units of currency_to correspond to one unit of currency_from.

Technical details

Endpointhttps://api.1payment.com/get_rate
MethodGET
Response formatJSON
AuthorizationAPI Key — used in sign signature generation

Request parameters

Required

ParameterTypeDescription
partner_idIntegerYour unique ID in the 1Payment system.
project_idIntegerProject identifier.
currency_fromStringSource currency (ISO code, e.g. usdt).
currency_toStringTarget currency (ISO code, e.g. rub).
signStringRequest 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&currency_to=rub&partner_id=1234&project_id=5678secret_key

Signature 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&currency_to=rub&partner_id=1234&project_id=5678
String for MD5: get_ratecurrency_from=usdt&currency_to=rub&partner_id=1234&project_id=5678
Expected signature: e6361ec42b5d5e2cee28968b4528e291
Signature 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
}
FieldTypeDescription
rateNumberConversion rate currency_from → currency_to.

Request error (400):

{
  "error_code": 2
}

error_code meanings — in Error codes (API).

Was this article helpful?