API documentation

Our API follows REST principles and exchanges data in JSON. When invoking each endpoint, we suggest you set the application/json header with UTF-8 charset (Content-Type: application/json; charset = utf-8).

Endpoints fall into two categories:

  • public ones (no authorization needed) 
  • private ones (authorization required)

If you need to call the private endpoints, please reach out to our customer support team to request an authorization token {api_key}.

To authorize, attach the HTTP header Authorization: Bearer {api_key} to your request.

The base URL of the API is:
/api/{endpoint}

The descriptions of all available endpoints are listed below.

 

GET /status

A public endpoint that reports whether the service is up and running.

Request:
/api/status

Response:
{
     "status": "ok",
     "timestamp": 1649143742,
     "datetime": "2022-04-05T07:29:02+00:00"
}

Response parameters:
Name: status
Type: text
Description: ok - service active

Name: timestamp
Type: integer
Description: Current server time

Name: datetime
Type: datetime
Description: Current server time in ISO 8601 format

 

GET /validateAddress/{btc_address}

A public endpoint that verifies whether a given bitcoin address is correctly formed.

Request:
/api/validateAddress/n3PdePLBgEeTYk4nAhcbehsnjvr1i3LyYS

Response:
{
     "result": "true"
}

Response parameters:
Name: result
Type: boolean
Description: 
true - BTC address is valid
false - BTC address is invalid

 

POST /createTransaction

A private endpoint that initiates a brand new transaction.

Request:
/api/createTransaction

Request parameters:
{
     "delay":"1", 
     "payouts":[
          “mr9if7VDsVfEZ1qUo2u3trv6rU9eH7Yx4u",
          "mia3h2FdYvR2LbDR1to9u6TC62hiTbDKM9"
     ],
     "refCode":"qljncygz"
}

Name: delay
Type: integer
Description: Transaction delay in hours (the transaction won't start until the delay interval is reached)

Name: payouts
Type: array
Description: List of BTC addresses and payouts in the following format [BTC_address => BTC_amount]

Name: refCode
Type: string
Description: Affiliate program code (optional)

Response:
{
     "id": "JEVG1TKFP4L95EDX",
     "status": "pending",
     "depositAddress": "tb1qmc2vcq6a427v6t83z8rnyg9ldf5k5p5uj2x4xv",
     "depositAmount": 0.00316,
     "payouts": {
          "mr9if7VDsVfEZ1qUo2u3trv6rU9eH7Yx4u": "0",
          "mia3h2FdYvR2LbDR1to9u6TC62hiTbDKM9": "0"
          },
     "fee": 0.00016,
     "delay": "1",
     "refCode": "qljncygz",
     "updated": "2022-05-05T08:56:05+00:00",
     "created": "2022-05-05T08:56:05+00:00",
     "signature": "zDQlfJHSJWtzw8yFwevs7KmiDZs15FVl01RbPwPt3bc="
}

Response parameters:
Name: id
Type: string
Description: Transaction ID

Name: status
Type: string
Description: Transaction status
- pending - waiting for deposit 
- confirming - deposit received, waiting for one confirmation
- processing - sending payment(s) to specified address(es)
- complete - transaction completed
- expired - transaction expired

Name: depositAddress
Type: string
Description: Deposit BTC address

Name: depositAmount
Type: decimal
Description: Deposit amount = amount of payouts + fees

Name: payouts
Type: array
Description: List of BTC addresses and payout amounts

Name: fee
Type: decimal
Description: Total amount of fees

Name: delay
Type: integer
Description: Transaction delay in hours

Name: refCode
Type: string
Description: Affiliate program code

Name: updated
Type: datetime
Description: Transaction update time in ISO 8601 format

Name: created
Type: datetime
Description: Transaction creation time in ISO 8601 format

Name: signature
Type: string
Description: Signature (explained below)

 

GET /transactions

A private endpoint that returns the full list of your transactions, ordered from the most recent to the oldest.

Request:
/api/transactions?limit=2&offset=0

Request parameters:
Name: limit
Type: integer
Description: Number of records returned, default = 30

Name: offset
Type: integer
Description: Paging offset, default = 0

Response:
{
     "transactions": [
          {
               "id": "Y9ANXDCJMHG2J6GD",
               "status": "pending",
               "depositAddress": "tb1qfhlu3acnqztwu2ep8mn446f8mfhkyt6u4xq2dd",
               "depositAmount": 0.00316,
               "payouts": {
                    "mr9if7VDsVfEZ1qUo2u3trv6rU9eH7Yx4u": "0.001",
                    "mia3h2FdYvR2LbDR1to9u6TC62hiTbDKM9": "0.002"
               },
               "fee": 0.00016,
               "delay": "1",
               "updated": "2022-05-05T08:52:52+00:00",
               "created": "2022-05-05T08:52:52+00:00"
          },
          {
               "id": "EEFU0IKT3BAJ1JOQ",
               "status": "expired",
               "depositAddress": "tb1qu80wgqucwvwxt3wdk8lyd4weuxn3vvy23et3p3",
               "payouts": {
                    "mx1HgMB1EG38bRtfH4tQwMGSvZXodbxdQ8": "0.005"
               },
               "fee": 0.0001,
               "delay": "0",
               "updated": "2022-04-29T11:46:05+00:00",
               "created": "2022-04-26T11:46:02+00:00"
          }
     ],
     "totalTransactions": 27,
     "limit": "2",
     "offset": 0
}

Response parameters:
Name: transactions
Type: array
Description: List of individual transactions (objects). See transaction details for more information.

Name: totalTransactions
Type: integer
Description: Number of all transactions

Name: limit
Type: integer
Description: Maximum number of records returned, default = 30

Name: offset
Type: integer
Description: Paging offset, default = 0

 

GET /transaction/{id}

A private endpoint used to fetch the full details of a specific transaction.

Request:
/api/transaction/Q96G3MSNW8MPQRTX

Response:
{
     "id": "Q96G3MSNW8MPQRTX",
     "status": "complete",
     "depositAddress": "tb1q0pkwdj3pqdp587yrc8sus876kccn5tq577ce5x",
     "depositAmount": "0.0062244",
     “depositTxid": "80bb6cda5036ce277598d949d2e4b3771c56b31ba77b757bf9753a370f16c99",
     "payouts": {
          "mfuAKvSsAMrC7gjbEEb521uc1myeF9BSsc": "0.006"
     },
     "txid": "0ea6f3a702a368ed09830d959f1c82b7d8f65f53a783965514380e123fc8ca4e",
     "fee": 0.0002244,
     "delay": "0",
     "updated": "2022-04-28T09:46:11+00:00",
     "created": "2022-04-28T09:42:41+00:00"
}

Response parameters:
Name: id
Type: string
Description: Transaction ID

Name: status
Type: string
Description: Transaction status:
- pending - waiting for payment (deposit)
- confirming - payment received, waiting for one confirmation
- processing - sending payments to specified addresses
- complete - transaction completed 
- expired - transaction expired

Name: depositAddress
Type: string
Description: Deposit BTC address

Name: depositAmount
Type: decimal
Description: BTC deposit amount received

Name: depositTxid
Type: string
Description: TXID of the received deposit

Name: payouts
Type: array
Description: List of BTC addresses and payouts

Name: txid
Type: string
Description: Withdrawal transaction TXID

Name: fee
Type: decimal
Description: Total amount of fees

Name: delay
Type: integer
Description: Delay of the transaction in hours

Name: refCode
Type: string
Description: Affiliate program reference code

Name: updated
Type: datetime
Description: Transaction status update time in ISO 8601 format

Name: created
Type: datetime
Description: Transaction creation time in ISO 8601 format

Name: signature
Type: string
Description: Signature (explained below)

 

Signature

Every transaction carries a "signature" field that guarantees the payload is genuine and was not tampered with.

Alongside the authorization token {api_key}, our support team will also issue you a private key {secret_key}. With this secret key you can confirm the "authenticity" of every response you receive.

Signature calculation:
$secret_key = {secret_key};
$transaction_details = 
{
     "id": "Q96G3MSNW8MPQRTX",
     "status": "complete",
     "depositAddress": "tb1q0pkwdj3pqdp587yrc8sus876kccn5tq577ce5x",
     "depositAmount": "0.0062244",
     “depositTxid": "80bb6cda5036ce277598d949d2e4b3771c56b31ba77b757bf9753a370f16c99",
     "payouts": {
          "mfuAKvSsAMrC7gjbEEb521uc1myeF9BSsc": "0.006"
     },
     "txid": "0ea6f3a702a368ed09830d959f1c82b7d8f65f53a783965514380e123fc8ca4e",
     "fee": 0.0002244,
     "delay": "0",
     "updated": "2022-04-28T09:46:11+00:00",
     "created": "2022-04-28T09:42:41+00:00"
};

$signature = base64_encode(hash_hmac('sha256', implode('|', array_map(function($a) { return is_array($a) ? implode(',', array_keys($a)).','.implode(',', $a) : $a; }, array_values($transaction_details))), $secret_key, TRUE));

Important: keep the parameter order exactly as it appears in the response. The "signature" field itself is excluded from the calculation.

 

Error codes

When a call completes without issues, the server replies with HTTP 200 OK.

ERROR response:
{
     "code": 400,
     "description": "Invalid JSON data."
}

Response parameters:
Name: code
Type: integer
Description: Error code that matches the HTTP codes
- 400 - bad request (validation error)
- 401 - missing / invalid API key
- 403 - blocked account / API
- 404 - service (endpoint) does not exist
- 503 - service is temporarily unavailable

Name: description
Type: string
Description: Error description

Mix Bitcoins (3% fee)
When you use whir, you accept our Privacy policy.