Python implementation of CryptAPI's payment gateway
Python >= 3.0
Requests >= 2.20
pip install python-cryptapifrom cryptapi import CryptAPIHelperfrom cryptapi import CryptAPIHelper
ca = CryptAPIHelper(coin, myAddress, callbackUrl, params, cryptapiParams)
address = ca.get_address()['address_in']Where:
coinis the coin you wish to use, from CryptAPI's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...).myAddressis your own crypto address, where your funds will be sent to.callbackUrlis the URL that will be called upon payment.paramsis any parameter you wish to send to identify the payment, such as{orderId: 1234}.cryptapiParamsparameters that will be passed to CryptAPI _(check which extra parameters are available here: https://docs.cryptapi.io/#operation/create).addressis the newly generated address, that you will show your users in order to receive payments.
Once your customer makes a payment, CryptAPI will send a callback to your
callbackUrl. This callback information is by default inGETbut you can se it toPOSTby settingpost: 1incryptapiParams. The parameters sent by CryptAPI in this callback can be consulted here: https://docs.cryptapi.io/#operation/confirmedcallbackget
from cryptapi import CryptAPIHelper
ca = CryptAPIHelper(coin, myAddress, callbackUrl, params, cryptapiParams)
data = ca.get_logs()Same parameters as before, the
datareturned can b e checked here: https://docs.cryptapi.io/#operation/logs
from cryptapi import CryptAPIHelper
ca = CryptAPIHelper(coin, myAddress, callbackUrl, params, cryptapiParams)
###
qr_code = ca.get_qrcode(value, size)For object creation, same parameters as before. You must first call ``getAddress` as this method requires the payment address to have been created.
For QR Code generation:
valueis the value requested to the user in the coin to which the request was done. Optional, can be empty if you don't wish to add the value to the QR Code.sizeSize of the QR Code image in pixels. Optional, leave empty to use the default size of 512.
Response is an object with
qr_code(base64 encoded image data) andpayment_uri(the value encoded in the QR), see https://docs.cryptapi.io/#operation/qrcode for more information.
from cryptapi import CryptAPIHelper
ca = CryptAPIHelper(coin, myAddress, callbackUrl, params, cryptapiParams)
fees = ca.get_estimate(coin, addresses, priority)Where:
coinis the coin you wish to check, from CryptAPI's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...)addressesThe number of addresses to forward the funds to. Optional, defaults to 1.priorityConfirmation priority, (check this article to learn more about it). Optional, defaults todefault.
Response is an object with
estimated_costandestimated_cost_usd, see https://docs.cryptapi.io/#operation/estimate for more information.
from cryptapi import CryptAPIHelper
ca = CryptAPIHelper(coin, myAddress, callbackUrl, params, cryptapiParams)
conversion = ca.get_conversion(value, from_coin)Where:
cointhe target currency to convert to, from CryptAPI's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...)valuevalue to convert infrom.from_coincurrency to convert from, FIAT or crypto.
Response is an object with
value_coinandexchange_rate, see https://docs.cryptapi.io/#operation/convert for more information.
from cryptapi import CryptAPIHelper
supportedCoins = CryptAPIHelper.get_supported_coins()Response is an array with all supported coins.
Need help?
Contact us @ https://cryptapi.io/contacts/
- Initial Release
- Minor fixes
- Minor fixes
- Minor fixes
- Minor fixes
- Minor fixes
- Improve error handling
- Minor improvements
