Version 2

Version 2 is deprecated since April 2020.

Please see API version 3 for more details about the current version.

Version 2 was the successor of version 1 of the XMR.to API, active from July 2017 till Apr 2020.

Compared to version 1, this API supports:

  • integrated addresses

  • zero-conf transactions

Version 2 supports Monero subaddresses.

Changelog

Date

Change

Apr 2020

Deprecated this API version.

Nov 2019

Added endpoint to partially pay an underpaid order. Added btc_amount_partial field to response of order_status_query.

Oct 2019

Added xmr_amount to order_create for XMR denominated amounts.

Sep 2019

Added btc_num_confirmations_threshold field to response of order_status_query.

Sep 2019

Added xmr_receiving_subaddress field to response of order_status_query.

Mar 2019

Added error codes for region blocking.

Jan 2019

Added pp_url field to the response of Bitcoin payment endpoint.

Dec 2018

Added new endpoint order_check_price.

Dec 2018

Added rate limitation on API endpoints.

Aug 2018

Added Terms of Service requirement.

Feb 2018

Added endpoint for paying Bitcoin payment requests.

Querying order parameters

API endpoint: https://xmr.to/api/v2/xmr2btc/order_parameter_query/

The order parameter endpoint supplies information about whether new orders can be created. In this case, this endpoint provides the current price, order limits, etc. for newly created orders.

Note

It is possible to query the status of existing orders even if the order parameter endpoint reports not available.

Request

Issue a GET request to query current order parameters.

Response

On success (HTTP code 200), the request returns the following JSON data:

{
    "lower_limit": <lower_order_limit_in_btc_as_float>,
    "price": <price_of_1_xmr_in_btc_as_offered_by_service_as_float>,
    "upper_limit": <upper_order_limit_in_btc_as_float>,
    "zero_conf_enabled": <true_if_zero_conf_is_enabled_as_boolean>,
    "zero_conf_max_amount": <up_to_this_amount_zero_conf_is_possible_as_float>
}

Fields should be self-explanatory.

Errors

On failure, one of the following errors is returned:

  • XMRTO-ERROR-001

  • XMRTO-ERROR-007

  • XMRTO-ERROR-008

  • XMRTO-ERROR-012

  • XMRTO-ERROR-014

For error details see the List of all error codes section.

Rate limitation

It is possible to request the endpoint up to 3 times per second.

Example

Request

curl https://xmr.to/api/v2/xmr2btc/order_parameter_query/

or

http https://xmr.to/api/v2/xmr2btc/order_parameter_query/

Response

{
    "price": 0.017666,
    "upper_limit": 20.0,
    "lower_limit": 0.002,
    "zero_conf_enabled": true,
    "zero_conf_max_amount": 0.1
}

Creating a new order

API endpoint: https://xmr.to/api/v2/xmr2btc/order_create/

The order creation endpoint allows to create a new order at the current price. The user has to supply a bitcoin destination address and amount to create the order.

The amount can be supplied either in Bitcoin (btc_amount) or in Monero (xmr_amount).

Note

Please use the order_check_price API endpoint if you only want to check the price for a specific Bitcoin/Monero amount.

Request

Issue a POST request to create a new order supplying the following parameters:

{
    "btc_amount": <requested_amount_in_btc_as_float>,
    "btc_dest_address": <requested_destination_address_as_string>
}

or

{
    "xmr_amount": <requested_amount_in_xmr_as_float>,
    "btc_dest_address": <requested_destination_address_as_string>
}

Note

Make sure that btc_amount or xmr_amount amount is inside the possible limits for an order. These limits can be queried using the order_parameter_query endpoint.

Response

On success (HTTP code 201, “created”), the request returns the following JSON data:

{
    "state": "TO_BE_CREATED",
    "btc_amount": <requested_amount_in_btc_as_float>,
    "btc_dest_address": <requested_destination_address_as_string>,
    "uuid": <unique_order_identifier_as_12_character_string>
}

The field state reflects the state of an order. If state is TO_BE_CREATED in the response, the order has been registered for creation and you can use the order uuid to start querying the order’s status. All other fields should be self-explanatory.

Note

Even though the order can be created by specifying an amount in XMR, the response will always return the amount in BTC based on the availabe rate at the time of the request.

Errors

On failure, one of the following errors is returned:

  • XMRTO-ERROR-001

  • XMRTO-ERROR-002

  • XMRTO-ERROR-003

  • XMRTO-ERROR-004

  • XMRTO-ERROR-005

  • XMRTO-ERROR-012

  • XMRTO-ERROR-014

  • XMRTO-ERROR-015

For error details see the List of all error codes section.

Rate limitation

It is possible to request the endpoint up to 20 times per minute.

Example

In this example, we create an order for donating 0.1 BTC to the Monero developers (using Bitcoin, ironically).

Request

curl --data '{"btc_dest_address": "1FhnVJi2V1k4MqXm2nHoEbY5LV7FPai7bb", \
    "btc_amount": 0.1}' -H "Content-Type: application/json" https://xmr.to/api/v2/xmr2btc/order_create/

or

http --json https://xmr.to/api/v2/xmr2btc/order_create/ btc_dest_address=1FhnVJi2V1k4MqXm2nHoEbY5LV7FPai7bb btc_amount=0.1

Hint

Remember to set the HTTP Content-Type to application/json!

Response

{
    "state": "TO_BE_CREATED",
    "btc_amount": 0.1,
    "btc_dest_address": "1FhnVJi2V1k4MqXm2nHoEbY5LV7FPai7bb",
    "uuid": "xmrto-XCZEsu"
}

Creating a new order using a payment protocol URL

API endpoint: https://xmr.to/api/v2/xmr2btc/order_create_pp/

This alternative order creation endpoint allows to create a new order at the current price, but instead of providing an explicit address and amount, the user provides a BIP70 url that once fetched by XMR.to will provide the address and amount.

Request

Issue a POST request to create a new order supplying the following parameters:

{
    "pp_url": <payment_protocol_url>
}

Note

XMR.to is able to correct automatically URLs provided by users to the correct one serving a BIP70-protocol answer. For instance, values such as https://bitpay.com/invoice?id=xxx, bitcoin:?r=https://bitpay.com/i/xxx will be corrected to the correct one automatically (the correct one being for Bitpay: https://bitpay.com/i/KbMdd4EhnLXSbpWGKsaeo6.

Response

On success (HTTP code 201, “created”), the request returns the following JSON data:

{
    "state": "TO_BE_CREATED",
    "btc_amount": <requested_amount_in_btc_as_float>,
    "btc_dest_address": <requested_destination_address_as_string>,
    "uuid": <unique_order_identifier_as_12_character_string>,
    "pp_url": <payment_bip70_protocol_url>
}

The field state reflects the state of an order. If state is TO_BE_CREATED in the response, the order has been registered for creation and you can use the order uuid to start querying the order’s status. All other fields should be self-explanatory.

Errors

On failure, one of the following errors is returned:

  • XMRTO-ERROR-001

  • XMRTO-ERROR-002

  • XMRTO-ERROR-003

  • XMRTO-ERROR-004

  • XMRTO-ERROR-005

  • XMRTO-ERROR-010

  • XMRTO-ERROR-011

  • XMRTO-ERROR-012

  • XMRTO-ERROR-014

For error details see the List of all error codes section.

Rate limitation

It is possible to request the endpoint up to 20 times per minute.

Example

In this example, we create an order for donating 0.1 BTC to the Monero developers (using Bitcoin, ironically).

Request

curl --data '{"pp_url": "https://bitpay.com/invoice?id=<invoice_id>"}' -H "Content-Type: application/json" https://xmr.to/api/v2/xmr2btc/order_create_pp/

or

http --json https://xmr.to/api/v2/xmr2btc/order_create_pp/ pp_url="https://bitpay.com/invoice?id=<invoice_id>"

Hint

Remember to set the HTTP Content-Type to application/json!

Response

{
    "state": "TO_BE_CREATED",
    "btc_amount": 0.1,
    "btc_dest_address": "1FhnVJi2V1k4MqXm2nHoEbY5LV7FPai7bb",
    "uuid": "xmrto-XCZEsu",
    "pp_url": "https://bitpay.com/i/xxx"
}

Querying order status

API endpoint: https://xmr.to/api/v2/xmr2btc/order_status_query/

The order status endpoint allows users to query the status of an order, thereby obtaining payment details and order processing progress.

Request

Issue a POST request to query the status of a given order. You have to supply the order’s uuid in the request:

{
    "uuid": <unique_order_identifier_as_12_character_string>,
}

Response

On success (HTTP code 200), the request returns the following JSON data:

{
    "state": <order_state_as_string>,
    "btc_amount": <requested_amount_in_btc_as_float>,
    "btc_amount_partial": <partial_amount_in_btc_as_float>,
    "btc_dest_address": <requested_destination_address_as_string>,
    "uuid": <unique_order_identifier_as_12_character_string>
    "btc_num_confirmations": <btc_num_confirmations_as_integer>,
    "btc_num_confirmations_before_purge": <btc_num_confirmations_before_purge_as_integer>,
    "btc_num_confirmations_threshold": <btc_num_confirmations_threshold_as_integer>,
    "btc_transaction_id": <btc_transaction_id_as_string>,
    "created_at": <timestamp_as_string>,
    "expires_at": <timestamp_as_string>,
    "seconds_till_timeout": <seconds_till_timeout_as_integer>,
    "xmr_amount_total": <amount_in_xmr_for_this_order_as_float>,
    "xmr_amount_remaining": <amount_in_xmr_that_the_user_must_still_send_as_float>,
    "xmr_num_confirmations_remaining": <num_xmr_confirmations_remaining_before_bitcoins_will_be_sent_as_integer>,
    "xmr_price_btc": <price_of_1_xmr_in_btc_as_offered_by_service_as_float>,
    "xmr_receiving_subaddress": <xmr_subaddress_user_needs_to_send_funds_to_as_string>,
    "xmr_receiving_address": <xmr_old_style_address_user_can_send_funds_to_as_string>,
    "xmr_receiving_integrated_address": <xmr_integrated_address_user_needs_to_send_funds_to_as_string>,
    "xmr_recommended_mixin": <xmr_recommended_mixin_as_integer>,
    "xmr_required_amount": <xmr_amount_user_needs_to_send_as_float>, (deprecated)
    "xmr_required_payment_id_long": <xmr_payment_id_user_needs_to_include_when_using_old_stlye_address_as_string>
    "xmr_required_payment_id_short": <xmr_payment_id_included_in_integrated_address_as_string>
}

Note

The field btc_num_confirmations_before_purge is deprecated in favor of btc_num_confirmations_threshold. The field xmr_required_amount is deprecated in favor of xmr_amount_total. The field xmr_receiving_integrated_address is deprecated in favor of xmr_receiving_subaddress. The field xmr_required_payment_id_long is deprecated in favor of xmr_receiving_subaddress. The field xmr_required_payment_id_short is deprecated in favor of xmr_receiving_subaddress. The field xmr_receiving_address is deprecated in favor of xmr_receiving_subaddress.

Note

The field btc_amount_partial is added to allow partial payments of an underpaid order.

The user has to pay the order using the integrated address or the Monero subaddress. In case the user’s wallet does not support integrated addresses, the user can pay via the old-style address while specifying the long payment id.

Presence of some of these fields depend on state, which can take the following values:

Value

Meaning

TO_BE_CREATED

order creation pending

UNPAID

waiting for Monero payment by user

UNDERPAID

order partially paid

PAID_UNCONFIRMED

order paid, waiting for enough confirmations

PAID

order paid and sufficiently confirmed

BTC_SENT

bitcoin payment sent

TIMED_OUT

order timed out before payment was complete

In case the order cannot be found, the appropriate error is returned (see below).

All other fields should be self-explanatory.

Errors

On failure, one of the following errors is returned:

  • XMRTO-ERROR-006

  • XMRTO-ERROR-009

  • XMRTO-ERROR-012

  • XMRTO-ERROR-014

For error details see the List of all error codes section.

Rate limitation

It is possible to request the endpoint up to 3 times per second.

Example

Continuing from our previous example, we can query the order by supplying the order’s unique identifier uuid.

Request

curl --data '{"uuid": "xmrto-VkT2yM"}' -H "Content-Type: application/json" \
    https://xmr.to/api/v2/xmr2btc/order_status_query/

or

http --json https://xmr.to/api/v2/xmr2btc/order_status_query/ uuid=xmrto-VkT2yM

Response

The response gives the current status of the order:

{
    "xmr_price_btc": 0.01760396,
    "uuid": "xmrto-XCZEsu",
    "state_str": "UNPAID",
    "btc_amount": 0.1,
    "btc_amount_partial": 0,
    "btc_dest_address": "1FhnVJi2V1k4MqXm2nHoEbY5LV7FPai7bb",
    "xmr_required_amount": 5.68054,
    "xmr_receiving_subaddress": "83BGzCTthheE2KxNTBPnPJjJUthYPfDfCf3ENSVQcpga8RYSxNz9qCz1qp9MLye9euMjckGi11cRdeVGqsVqTLgH8w5fJ1D",
    "xmr_receiving_address": "44TVPcCSHebEQp4LnapPkhb2pondb2Ed7GJJLc6TkKwtSyumUnQ6QzkCCkojZycH2MRfLcujCM7QR1gdnRULRraV4UpB5n4",
    "xmr_receiving_integrated_address": "4EAAQR1vtv7EQp4LnapPkhb2pondb2Ed7GJJLc6TkKwtSyumUnQ6QzkCCkojZycH2MRfLcujCM7QR1gdnRULRraV64LYEHMdkJa7XDQruC",
    "xmr_required_payment_id_long": "356620a8410a4c683eda9b43fdc7fa531b721d70856c95994636361aafbda052",
    "xmr_required_payment_id_short": "3caca930a471a739",
    "created_at": "2017-07-01T08:11:27Z"
    "expires_at": "2017-07-01T08:26:27Z",
    "seconds_till_timeout": 857,
    "xmr_amount_total": 5.68,
    "xmr_amount_remaining": 5.68,
    "xmr_num_confirmations_remaining": -1,
    "xmr_recommended_mixin": 4,
    "btc_num_confirmations_before_purge": 144,
    "btc_num_confirmations_threshold": 144,
    "btc_num_confirmations": 0,
    "btc_transaction_id": ""
}

In this example, the next step would require the user to pay 5.68 XMR to the (integrated) Monero address 4EAAQR….

As of September 2019, instead of paying to the integrated Monero address, the user can also pay to the provided Monero subaddress.

In case the user’s wallet does not support integrated addresses, the user can pay via the old-style address 44TVPc… while providing the (long) payment ID 356620….

Note

The payment must be made before the order expires, in this case, inside 857 seconds.

Note

The field xmr_required_amount is deprecated in favor of xmr_amount_total. The field xmr_receiving_integrated_address is deprecated in favor of xmr_receiving_subaddress. The field xmr_required_payment_id_long is deprecated in favor of xmr_receiving_subaddress. The field xmr_required_payment_id_short is deprecated in favor of xmr_receiving_subaddress. The field xmr_receiving_address is deprecated in favor of xmr_receiving_subaddress.

Note

The field btc_amount_partial is added to allow partial payments of an underpaid order.

Order partial payment

API endpoint: https://xmr.to/api/v2/xmr2btc/order_partial_payment/

The order partial payment endpoint allows users to partially pay an underpaid order, thereby confirming that less BTC will arrive at the destination address.

Request

Issue a POST request to partially pay an underpaid order. You have to supply the order’s uuid in the request:

{
    "uuid": <unique_order_identifier_as_12_character_string>,
}

Response

On success (HTTP code 200), the request does not return any more data.

The order needs to be underpaid (state is UNDERPAID), in oder to confirm a partial payment for this very order.

To get information on the updated order please trigger order_status_query again.

The user has to pay the order using the integrated address or the Monero subaddress. In case the user’s wallet does not support integrated addresses, the user can pay via the old-style address while specifying the long payment id.

In case the order cannot be found, the appropriate error is returned (see below).

The value of btc_amount_partial will be 0 for every order state but UNDERPAID. In case the orderis UNDERPAID, btc_amount_partial will be populated with the appropriate BTC amount according to the XMR amount paid and your personal rate.

Errors

On failure, one of the following errors is returned:

  • XMRTO-ERROR-006

  • XMRTO-ERROR-009

  • XMRTO-ERROR-012

  • XMRTO-ERROR-014

For error details see the List of all error codes section.

Rate limitation

It is possible to request the endpoint up to 3 times per second.

Example

Continuing from our previous example, imagine the order xmrto-VkT2yM was underpaid with 5 XMR. Remember you had to pay 5.68 XMR?

In this case xmr_amount_remaining will change to 0.68 XMR while btc_amount_partial will return approximately 0.088 BTC - Your personal rate stays the same, xmr_price_btc=0.01760396. You will see the updated order information with the next post to order_status_query.

You now have the option to partially pay your order by supplying the order’s unique identifier uuid to the endpoint.

Request

curl --data '{"uuid": "xmrto-VkT2yM"}' -H "Content-Type: application/json" \
    https://xmr.to/api/v2/xmr2btc/order_partial_payment/

or

http --json https://xmr.to/api/v2/xmr2btc/order_partial_payment/ uuid=xmrto-VkT2yM

Response

The response gives no detailed information. However, the next call to order_status_query returns the current/updated status of the order.

Note

A partial payment must be made before the order expires.

Note

The field btc_amount_partial is added to allow partial payments of an underpaid order.

Querying order price

API endpoint: https://xmr.to/api/v2/xmr2btc/order_check_price/

The order status endpoint allows users to query the recent price for a given amount in BTC/XMR.

Request

Issue a POST request to query the price of a BTC/XMR amount. You can supply either the amount of BTC btc_amount or the amount of XMR xmr_amount in the request:

{
    "btc_amount": <requested_amount_in_btc_as_float>
}

or

{
    "xmr_amount": <requested_amount_in_xmr_as_float>
}

Note

Make sure that btc_amount or xmr_amount amount is inside the possible limits for an order. These limits can be queried using the order_parameter_query endpoint.

Response

On success (HTTP code 200), the request returns the following JSON data:

{
    "btc_amount": <requested_amount_in_btc_as_float>,
    "xmr_amount_total": <amount_in_xmr_for_this_order_as_float>,
    "xmr_num_confirmations_remaining": <num_xmr_confirmations_remaining_before_bitcoins_will_be_sent_as_integer>,
    "xmr_price_btc": <price_of_1_xmr_in_btc_as_offered_by_service_as_float>
}

Errors

On failure, one of the following errors is returned:

  • XMRTO-ERROR-004

  • XMRTO-ERROR-005

  • XMRTO-ERROR-007

  • XMRTO-ERROR-009

  • XMRTO-ERROR-012

  • XMRTO-ERROR-014

For error details see the List of all error codes section.

Rate limitation

It is possible to request the endpoint once every 3 seconds.

Example

Imagine we want to check the recent price for an order including the payment of 0.15 BTC.

or

Imagine we want to check the recent price for an order including the payment of 10 XMR.

Request

curl --data '{"btc_amount": 0.15}' -H "Content-Type: application/json" \
    https://xmr.to/api/v2/xmr2btc/order_check_price/

or

http --json https://xmr.to/api/v2/xmr2btc/order_check_price/ btc_amount=0.15

Imagine we want to check the recent price for an order including the payment of 10 XMR.

curl --data '{"xmr_amount": 10}' -H "Content-Type: application/json" \
    https://xmr.to/api/v2/xmr2btc/order_check_price/

or

http --json https://xmr.to/api/v2/xmr2btc/order_check_price/ xmr_amount=10

Response

The response gives the current price for the order (when paying 0.15 BTC):

{
    "btc_amount": 0.15,
    "xmr_amount_total": 21.4185,,
    "xmr_num_confirmations_remaining": 1,
    "xmr_price_btc": 0.00700329
}

In this example, the order including the payment of 0.15 BTC would require the user to pay 21.4185 XMR.

The response gives the current price for the order (when paying 10 XMR):

{
    "btc_amount": 0.0701264,,
    "xmr_amount_total": 10,
    "xmr_num_confirmations_remaining": 0,
    "xmr_price_btc": 0.00701264
}

In this example, the order including the payment of 10 XMR would result in an order that eventually pays 0.0701264 BTC to the destination address.

Note

Even though the price can be queried by specifying an amount in XMR, the response will always return the amount in BTC based on the availabe rate at the time of the request.