Skip to main content

CryptAPI's Python Library

Python implementation of CryptAPI's payment gateway

Requirements:

Python >= 3.0
Requests >= 2.20

Install

pip install python-cryptapi

on pypi or on GitHub

Usage

Importing in your project file

from cryptapi import CryptAPIHelper

Generating a new Address

from cryptapi import CryptAPIHelper

ca = CryptAPIHelper(coin, myAddress, callbackUrl, params, cryptapiParams)

address = ca.get_address()['address_in']

Where:

  • coin is the coin you wish to use, from CryptAPI's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...).
  • myAddress is your own crypto address, where your funds will be sent to.
  • callbackUrl is the URL that will be called upon payment.
  • params is any parameter you wish to send to identify the payment, such as {orderId: 1234}.
  • cryptapiParams parameters that will be passed to CryptAPI _(check which extra parameters are available here: https://docs.cryptapi.io/#operation/create).
  • address is the newly generated address, that you will show your users in order to receive payments.

Getting notified when the user pays

Once your customer makes a payment, CryptAPI will send a callback to your callbackUrl. This callback information is by default in GET but you can se it to POST by setting post: 1 in cryptapiParams. The parameters sent by CryptAPI in this callback can be consulted here: https://docs.cryptapi.io/#operation/confirmedcallbackget

Checking the logs of a request

from cryptapi import CryptAPIHelper

ca = CryptAPIHelper(coin, myAddress, callbackUrl, params, cryptapiParams)

data = ca.get_logs()

Same parameters as before, the data returned can b e checked here: https://docs.cryptapi.io/#operation/logs

Generating a QR code

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:

  • value is 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.
  • size Size 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) and payment_uri (the value encoded in the QR), see https://docs.cryptapi.io/#operation/qrcode for more information.

Estimating transaction fees

from cryptapi import CryptAPIHelper

ca = CryptAPIHelper(coin, myAddress, callbackUrl, params, cryptapiParams)

fees = ca.get_estimate(coin, addresses, priority)

Where:

  • coin is the coin you wish to check, from CryptAPI's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...)
  • addresses The number of addresses to forward the funds to. Optional, defaults to 1.
  • priority Confirmation priority, (check this article to learn more about it). Optional, defaults to default.

Response is an object with estimated_cost and estimated_cost_usd, see https://docs.cryptapi.io/#operation/estimate for more information.

Converting between coins and fiat

from cryptapi import CryptAPIHelper

ca = CryptAPIHelper(coin, myAddress, callbackUrl, params, cryptapiParams)

conversion = ca.get_conversion(value, from_coin)

Where:

  • coin the target currency to convert to, from CryptAPI's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...)
  • value value to convert in from.
  • from_coin currency to convert from, FIAT or crypto.

Response is an object with value_coin and exchange_rate, see https://docs.cryptapi.io/#operation/convert for more information.

Getting supported coins

from cryptapi import CryptAPIHelper

supportedCoins = CryptAPIHelper.get_supported_coins()

Response is an array with all supported coins.

Help

Need help?
Contact us @ https://cryptapi.io/contacts/

Changelog

1.0.0

  • Initial Release

1.0.1

  • Minor fixes

1.0.2

  • Minor fixes

1.0.3

  • Minor fixes

1.0.4

  • Minor fixes

1.0.5

  • Minor fixes
  • Improve error handling

1.0.6

  • Minor improvements

Release files for python-cryptapi 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-cryptapi 1.0.6
File Size Uploaded
python-cryptapi-1.0.6.tar.gz 4.3 kB Details

Release files / python-cryptapi-1.0.6.tar.gz

Download URL python-cryptapi-1.0.6.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
67f8148ca2b1a1d791f345b8b1d6d7a735ca64e417e3739df24aa72db1d199dd
BLAKE2b-256 checksum
How to use checksums
66ff465d1459d070d0aa32e7255a7ffa9d1cc1c854b6f8288d48730056e51d1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release history Release notifications | RSS feed

This release

1.0.6 This release

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page