Using the coins api transfers endpoint, It is possible to send funds to any phone # or email address. The receiving end does not need not to have a coins account or bitcoin address beforehand.
Prerequisites
- Your account must be business verified. For more information, you may contact [email protected].
- You have already created your API keys
- You will need to have sufficient balance in your wallet to send.
Authentication
In this example, we'll be using HMAC as the authentication method. The functions get_nonce and sign_request are further explained in the HMAC authentication tutorial.
Setting up the request
account is the ID of the source wallet from which the funds will be deducted from. It can be a PHP or BTC denominated wallet. To get a list of your accounts and balances, see this tutorial.
The target_address can be any phone number, email address, or bitcoin address.
The amount is denominated in the currency of the account wallet. for example, if you are sending out of a PHP denominated wallet, the amount will be denominated in peso. If the target address is a bitcoin wallet, the funds will be automatically converted.
import requests
import hmac_example
url = 'https://api.coins.asia/v3/transfers'
nonce = hmac_example.get_nonce()
body = {
# The source account to send from (this is your coins wallet)
'account': '2r45ab4123ebb298an201',
# the amount to send, denominated in the currency of
# the source account
'amount': 25,
# Where the funds will be sent to (Phone #, Email, or Bitcoin address)
'target_address': '[email protected]'
}
signature = hmac_example.sign_request(url, nonce, request_body=body)
headers = {
'ACCESS_SIGNATURE': signature,
'ACCESS_KEY': hmac_example.API_KEY,
'ACCESS_NONCE': nonce,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
data = json.dumps(body, separators=(',', ':'))
requests.post(url, headers=headers, data=data)
This request should return the following response:
{
"transfer": {
"id":"1bbq2393nbn01nba01abebl",
"account":"2r45ab4123ebb298an201",
"amount":"25",
"target_address":"[email protected]",
"payment": null,
"status":"pending",
"created_at":"2015-05-01T12:11:36.938Z"
}
}
This means that the transfer has been made from your account to [email protected]
.
If the destination email/phone # is not associated with a coins.ph user, the recipient will receive a message with instructions for collecting their funds. funds that are not collected within 14 days are credited back to the sender.