Intro

Due to rising interest in the Bitcoin payment system, its integration became more than desirable on many sites. How do you integrate sending and receiving payments more efficiently? If you are intrigued about this, you've arrived at the place you wanted. This article will cover Bitcoin integration by using examples on Python and Django frameworks.

Why Cryptsy?

Cryptsy is a cryptocurrency exchange stock. Once registered in the system, you can trade and exchange more than 160 cryptocurrencies. One of the advantages of choosing this system is support for multiple currencies as well as a simple and clean API.

Cryptsy API example

Cryptsy API supports the sending of funds in any currency. To work with Cryptsy API you will need a simple Cryptsy class which can be taken from here

Some API usage examples

To start work with Cryptsy you need to get API keys from your profile settings page (https://www.cryptsy.com/users/settings):

Cryptsy Account Settings

You’ll need Publickey, PrivateKey and TradeKey.

Send amount function wrapper over class:

def make_payment(self,
            address,
            amount,
            currency_id,
            public_id,
            private_key,
            trade_key,
            notification_token,
):
"""
Args:
    address: address of the recipient wallet
    amount: the total amount to be sent
    currency_id: all currency id list can be taken from here https://api.cryptsy.com/api/v2/currencies
Cryptsy Specific args. Values can be taken from cryptsy account:
    public_id: Your public id
    private_key: Your private key
    trade_key: Your trade key
    notification_token: Notification token URL
"""
cryptsy = Cryptsy(public_key, private_key)
result = cryptsy.withdraw(
    trade_key,
    address,
    amount,
    notification_token,
    currency_id
)

How to get balances with currencies?

#### Initialize cryptsy instance by using public and private keys
#### And make connection to cryptsy API
cryptsy = Cryptsy(
    cryptsy_credential.publickey,
    cryptsy_credential.privatekey
)

#### Get currencies from cryptsy API
response = requests.get('https://api.cryptsy.com/api/v2/currencies')
currencies = response.json()

#### Get balance list from user account
balances = cryptsy.balances()['data']['available']

balances_with_currencies = []

for i, currency in enumerate(currencies['data']):
    if balances[currency['id']] > 0:
        tmp = currency['id'], '%s (%s)' % (
            currency['code'],
            balances[currency['id']]
        )
        balances_with_currencies.append(tmp)

Now we are using Cryptsy on http://infty.xyz , an idea generator and accelerator. One can fund an idea with a comment, and Cryptsy turned out a good solution at first. But it also has some drawbacks crucual for this project: they changed the policy or something, and now, only the approved addresses are allowed.

Apart from this, Crytpsy is cool, and if the part with approved addresses is not essential for your site, you definitely should choose it becase:
It’s very secure
It supports lots of different currencies

So, if you decide to have Cryptsy integrated, we are here to help you to do it, or even better, just to do it for you;)


Author:

Ali Aliev

Software developer

Vim enthusiast and Payment integration expert

2015-10-05