MilaCoins provide a payment gateway and business wallet that allows merchants to automate the processes of accepting cryptocurrency payments and payouts from their customers, as well as making currency exchange transactions and receiving data on the transaction history and account balance status for reporting. developer also can call MilaCoins API directly over HTTPS using JSON requests.
In addition to the Production environment, MilaCoins also provides developers with a test environment, also known as Sandbox. The SandBox environment is exactly like the Production environment. The only difference between the Production and Sandbox environment is that the latter uses test networks (testnets).
The Sandbox Environment and the Production Environment are independent environments and are not connected to each other in any way.
Sandbox Base URL - https://sandbox-api.milacoins.com
Production Base URL - https://api.milacoins.com
All API requests must be made over HTTPS, Please note that plain HTTP will be refused. You must include your X-headers in all requests.
The X-headers:
X-api-key
an API Key that you generate in our backoffice
X-Sig
signature of the request in the hex format (See "Signing a request" below)
X-time
number of seconds since Unix Epoch in UTC
The value of the X-Sig
is generated by a sha256 HMAC algorithm with a secret key. It contains the following information:
GET | POST
/transactions?from=2020-1-1&to=2022-1-1
GET
requests, don't include itExample of the string to be signed to get a signature Header Aka X-sig: 1618832932.344GET/transactions/?from=2020-1-1&to=2022-1-1
const axios = require('axios'),
baseUrl = process.env.MILACOINS_BASE_URL,
apiKey = process.env.MILACOINS_API_KEY,
secretKey = process.env.MILACOINS_SECRET_KEY;
async request(endPoint, { method = 'GET', body } = {}) {
const options = {
url: `${baseUrl}/${endPoint}`,
method,
data: body,
headers: {}
},
time = Math.round(Date.now() / 1000),
hmacSha256 = crypto.createHmac('sha256', secretKey);
hmacSha256.update(
time + options.method.toUpperCase() + endPoint
);
if (options.data) {
options.data = JSON.stringify(options.data);
hmacSha256.update(Buffer.from(options.data, 'utf-8'));
}
options.headers.Accept = 'application/json';
options.headers['Content-Type'] = 'application/json';
options.headers['X-api-key'] = apiKey;
options.headers['X-time'] = time;
options.headers['X-Sig'] = hmacSha256.digest('hex');
try {
const { data } = await axios(options);
return data;
} catch (err) {
if (err.response && err.response.data) throw err.response.data;
else throw new Error('unknown error');
}
}
MilaCoins maintains server-side API libraries in various programming languages that are available via popular package managers.
To install the NPM Package, go to https://www.npmjs.com/package/milauth
To install the Python Package, go to https://pypi.org/project/milauth
To download the Postman collection (v2.1), click-here
For more instructions on Postman, please visit this section.
Request Query string:
Field | Description |
---|---|
limit | Limit of documents for response. default:100 , max:500 |
page | Page-numbering is based on the value of |
Response (JSON):
Field | Type | Description |
---|---|---|
count | Number | |
limit | Number | |
skip | Number | |
docs | Array (objects) | |
--id | String | |
--status | Number | |
--ip | String | |
--method | String | |
--uri | String | |
--device | Any | |
--headers | Any | |
--location | Any | |
--body | Any | |
--params | Any | |
--query | Any | |
--response | Any | |
--error | String | |
--createdAt | String |
Request Parameters (URL):
Field | Type | Required |
---|---|---|
id | string | Required |
Response (JSON):
Field | Type | Description |
---|---|---|
id | String | |
status | Number | |
ip | String | |
method | String | |
uri | String | |
device | Any | |
headers | Any | |
location | Any | |
body | Any | |
params | Any | |
query | Any | |
response | Any | |
error | String | |
createdAt | String |
Response (JSON):
Field | Type | Description |
---|---|---|
currencies | Array (string) |
Response (JSON):
Field | Type | Description |
---|---|---|
wallets | Array (string) |
Request Body (JSON):
Field | Type | Required | Description |
---|---|---|---|
wallet | string | Required | Wallet (currency code ISO 4217) you wish to receive payments to. options: click here |
amount | number | Required | Invoice amount. (number) |
currency | string | Required | Invoice currency. (ISO 4217), options: click here |
externalID | string | No | Name of the customer or contains unique record identifiers from your system |
expiredAt | string | No | Invoice expiration Time |
Response (JSON):
Field | Type | Description |
---|---|---|
id | String | |
wallet | String | |
amount | Number | |
currency | String | |
externalID | String | |
url | String | |
expiredAt | Number | |
createdAt | Number |
Request Body (JSON):
Field | Type | Required | Description |
---|---|---|---|
wallet | string | Required | Wallet (currency code ISO 4217) you wish to receive payments to. options: click here |
amount | number | Required | Invoice amount. (number) |
currency | string | Required | Invoice currency. (ISO 4217) options: click here |
externalID | string | No | Name of the customer or contains unique record identifiers from your system |
cancelUrl | string | Required | Redirect url on cancel payment or error, include {INVOICE_ID} and {EXTERNAL_ID} in the URL to dynamically pass through parameters |
completedUrl | string | Required | Redirect url on complete payment, include {INVOICE_ID} and {EXTERNAL_ID} in the URL to dynamically pass through parameters |
callbackUrl | string | No | Callback url to get events, include {EVENT} ,{INVOICE_ID} and {EXTERNAL_ID} in the URL to dynamically pass through parameters. events options: cancel,complete |
customerEmail | string | No | Customer Email, will show on the payment page |
customerLastName | string | No | Customer Last Name, will show on the payment page |
customerFirstName | string | No | Customer First Name, will show on the payment page |
Response (JSON):
Field | Type | Description |
---|---|---|
id | String | |
wallet | String | |
amount | Number | |
currency | String | |
externalID | String | |
url | String | |
expiredAt | Number | |
createdAt | Number |
Request Query string:
Field | Description |
---|---|
limit | Limit of documents for response. default:100 , max:500 |
page | Page-numbering is based on the value of |
from | ISO 8601 date format. |
to | ISO 8601 date format. |
wallet | Wallet currency code (ISO 4217). |
externalID | Customer name or contains unique record identifiers from your system. |
status | Status or list of statuses separate by comma. example: (new,completed) emun: init,completed,invalid,new,waitingForConfirmation,underPaid,overPaid,paidLate. |
type | Valid values: |
Response (JSON):
Field | Type | Description |
---|---|---|
count | Number | |
limit | Number | |
skip | Number | |
docs | Array (objects) | |
--id | String | |
--receiptID | Number | |
--type | String | |
--status | String | |
--refund | Object | |
-- --id | String | |
-- --status | String | |
-- --network | String | |
-- --amount | Number | |
-- --agent | String | |
-- --createdAt | String | |
-- --address | String | |
-- --txID | String | |
--invoiceCurrency | String | |
--invoiceAmount | Number | |
--wallet | String | |
--walletCredited | Number | |
--network | String | |
--networkAmountReceived | Number | |
--exchangeRate | Object | |
-- --base | String | |
-- --quote | String | |
-- --rate | Number | |
--address | String | |
--txs | Array (string) | |
--externalID | String | |
--customer | Object | |
-- --firstName | String | |
-- --lastName | String | |
String | ||
--createdAt | String |
Request Parameters (URL):
Field | Type | Required |
---|---|---|
id | string | Required |
Response (JSON):
Field | Type | Description |
---|---|---|
id | String | |
receiptID | Number | |
type | String | |
status | String | |
refund | Object | |
--id | String | |
--status | String | |
--network | String | |
--amount | Number | |
--agent | String | |
--createdAt | String | |
--address | String | |
--txID | String | |
invoiceCurrency | String | |
invoiceAmount | Number | |
wallet | String | |
walletCredited | Number | |
network | String | |
networkAmountReceived | Number | |
exchangeRate | Object | |
--base | String | |
--quote | String | |
--rate | Number | |
address | String | |
txs | Array (string) | |
externalID | String | |
customer | Object | |
--firstName | String | |
--lastName | String | |
String | ||
createdAt | String |
MilaCoins API uses HTTP status to indicate the success or failure responses. Status that bigger then 400 will indicate has error.
{
"requestID": "62d956eda0a3bf0730f5fd18",
"name": "DOCUMENT_NOT_FOUND",
"message": "No Invoice found with that ID (id:62d8df9142d15eaa837f8ace)",
"code": 1604
}
HTTP code | Error Code | Message | Description |
---|---|---|---|
401 | 1603 | Please provide a valid ID | PROVIDE_ID |
404 | 1604 | No Document found with that ID ("id") | DOCUMENT_NOT_FOUND |
401 | 1600 | Invalid "patch": "value". | DB_CAST |
401 | 1601 | Already exist. | DB_DUPLICATE |
401 | 1602 | Invalid input data. | DB_INVALID_INPUT |
404 | 404 | Not Found | NOT_FOUND |
429 | 4302 | Too many requests, please try again later. | LIMIT_ERROR |
403 | 4303 | X-time hadear is invalid: | INVALID_TIME |
403 | 4304 | Fail to Authentication: Check the api key, the secret key and the sign function | FAIL_TO_AUTH |
403 | 4301 | "ip" ip not allowed | IP_WHITE_LIST |
401 | 1001 | "filed name" Filed: Incorrect type, required: "type", but got:"type" | VALIDATION_REQUEST_INCORRECT_TYPE |
401 | 1002 | "filed name" Filed: not allowed on this request | VALIDATION_REQUEST_ALLOWED_FILED |
401 | 1003 | "filed name" Filed: is required | VALIDATION_REQUEST_FILED_REQUIRED |
401 | 1004 | "value" is not a valid enum value for filed "filed name". Valid values: "valid values list" | VALIDATION_REQUEST_ENUM_VALUE |
401 | 1005 | "status" is not a valid status. Valid statuses: "statuses list" | VALIDATION_REQUEST_ENUM_STATUS |
401 | 1006 | "wallet" is not a valid wallet. Valid wallets: "wallets list" | VALIDATION_REQUEST_ENUM_WALLETS |
401 | 1007 | "currency" is not a valid currency. Valid currencies: AED,MYR,BRL,EUR,USD,GBP,ILS,JPY,RUB,TRY,UAH,NZD | VALIDATION_REQUEST_ENUM_CURRENCY |
Postman is an API Collaboration Platform.
MilaCoins now offers Postman Collection for quick and easy usage of our REST APIs.
Open the Postman app.
Click the Import
button.
On the MilaCoins-API
on the left side-bar. When it’s open, in Variables
you'll need to set:
apiBaseUrl
Production / Sandbox environment.
api-key
generated from your profile.
secret-key
generated from your profile.