Skip to main content

A simple coinswitch (v1,v2) client api

Project description

A Simple python library for coinswitch

This is a simple library that uses coinswitch APIs. It is just a collection of utils to manipulate, interpret and simplify calls to their APIs

How to use

First install the package with pip

pip install coinswitchclient

Then be sure to have your API key. If not it defaults to a sandbox api key There are two major blocks inside this package:

  1. TransactionManager : it is a set of function that call the v2 instant API
  2. CoinSwitchV1Client : function that reflect the v1 coinswitch api
  3. CoinSwitchV2FixedClient : function that reflect the v2 fixed coinswitch api
  4. CoinSwitchV2InstantClient : function that reflect the v2 instant coinswitch api
  5. ApiResponse : an object that represent the reponse from coinswitch apis

You can find examples inside the test directory of this repo.

Usage of ApiResponse

You never have to crete this object, but it will be return by each api calls. Here is the global structure of an ApiResponse

{
  "success": true,
  "code": "",
  "data": "",
  "error": ""
}

The ApiResponse object provide simple method to access basic information

api_response.is_success() # returns a boolean
api_response.code() # return the code string in the "code" field
api_response.message() # returns the content of error or msg depending on the remote response
api_response.data() # return a dict object that represent the data

Please see https://developer.coinswitch.co/ for any information of the returned fields in the data message

Usage for TransactionManager

# import required modules and classes
from coinswitch_client.TransactionManager import TransactionManager
from coinswitch_client.APIClient import Address

# create an instance of the transaction manager
manager = TransactionManager(api_key="MY_API_KEY")

# Ask to convert 1 BTC to ETH with 
manager.convert('btc', 'eth', 1.0, Address('ETH_ADDRESS').json(),
                    Address('REFUND_ADDRESS').json())

#this function returns the response from the coinswitch api as a ApiResponse

Usage for CoinSwitchV1Client

It follows the https://developer.coinswitch.co/ apis Here is a simple usage though

from coinswitch_client.APIClient import CoinSwitchV1Client

client = CoinSwitchV1Client(api_key="MYKEY")
api_response = client.coins()
if api_response.is_success():
    print(api_response.data())

Usage for CoinSwitchV2InstantClient

It follows the https://developer.coinswitch.co/ apis Here is a simple usage though

from coinswitch_client.APIClient import CoinSwitchV2InstantClient

client = CoinSwitchV2InstantClient(api_key="MYKEY")
api_response = client.coins()
if api_response.is_success():
    print(api_response.data())

api_response = client.rates('btc', 'eth')
if api_response.is_success():
    print(api_response.data())

Usage for CoinSwitchV2FixedClient

It follows the https://developer.coinswitch.co/ apis Here is a simple usage though

from coinswitch_client.APIClient import CoinSwitchV2FixedClient

client = CoinSwitchV2FixedClient(api_key="MYKEY")
api_response = client.coins()
if api_response.is_success():
    print(api_response.data())

api_response = client.place_offer('btc', 'eth',quantity_from=1.0)
if api_response.is_success():
    print(api_response.data())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coinswitchclient-0.0.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

coinswitchclient-0.0.2-py2.py3-none-any.whl (6.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file coinswitchclient-0.0.2.tar.gz.

File metadata

  • Download URL: coinswitchclient-0.0.2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for coinswitchclient-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a87deab662e022cb6056cf40cf0c4b86a58acada6b8378a64ea52109bc2cfc9b
MD5 f24b12f0f1b7b7351f6693042d52d69e
BLAKE2b-256 4c682b97c81cebc216f254984a0e14958a4a12a9514b467079382030e2a1bac6

See more details on using hashes here.

File details

Details for the file coinswitchclient-0.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: coinswitchclient-0.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for coinswitchclient-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6282e1d8bfb5aa25f3ec5c427678e3675cb8b18a2a48d7110918b1d034891a1e
MD5 b05e2411b4b439047714864d3d87c546
BLAKE2b-256 c992142bd260f8b1e0265007a89df237514098c6ce4ddea9fefb77f39a3d4fbb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page