SDK of CoinGate API for Python 3+
Project description
# CoinGate API SDK (API v2)
The repo contains Python 3 SDK for [CoinGate API v2](https://developer.coingate.com/docs/api-overview).
This is open source library is provided by [SociumNET](https://socium.net) team and it is used in some internal
projects.
## Installation
You can install the library using PIP:
`$ pip install coingate_api`
## Quick start
Try it:
```python
from coingate_api import CoingateAPI
api = CoingateAPI(auth_token='your-auth-token', environment='sandbox')
print(api.ping())
```
Only replace "your-auth-token" to your token from CoinGate of CoinGate sandbox
## How to
Default behavior of API uses retries for requests:
* 3 retries
* with back-off factor 0.2
* http statuses of response for retries: 500, 502, 504
You can change all these params by initialization of API client:
```python
from coingate_api import CoingateAPI
api = CoingateAPI(auth_token='your-auth-token', environment='sandbox',
retries=5, backoff_factor=0.5, status_forcelist=(500, 502, 504, 505))
```
#### Methods of API:
* `api.test_connection()` - tests authentication. Should return simple "OK"
* `api.ping()` - tests connection to server. Should return "pong"
* `api.exchange_rate(from_='EUR', to='USD')` - check documentation of API
* `api.exchange_rates()` - check documentation of API
* `api.ip_addresses()` - check documentation of API
* `api.orders(per_page=100, page=1, sort='created_at_desc', **kwargs)` - check documentation of API.
Values of kwargs can contain also `created_at_from` and `created_at_to`
* `api.checkout(order_id, pay_currency='BTC')` - check documentation of API
* `api.create_order(price_amount, price_currency, receive_currency, **kwargs)` - check documentation of API.
Values of kwargs can contain also `order_id`, `title`, `description`, `callback_url`, `cancel_url`, `success_url`, `token`
#### Exceptions
```python
from coingate_api import CoingateAPI, api_error
api = CoingateAPI(auth_token='your-auth-token', environment='sandbox')
try:
print(api.test_connection())
except api_error.APIError as e:
print(e)
```
Exceptions hierarchy:
* `APIError`
* `Unauthorized`
* `BadCredentials`
* `BadAuthToken`
* `AccountBlocked`
* `IPAddressIsNotAllowed`
* `NotFound`
* `PageNotFound`
* `RecordNotFound`
* `OrderNotFound`
* `UnprocessableEntity`
* `OrderIsNotValid`
* `RateLimitError`
* `InternalServerError` - notice that client will do retries for this error by default
## Contribution
You can be free to contribute in the project. You should only create PR with a short description what it is for and
what the problem can be solved by your PR.
The repo contains Python 3 SDK for [CoinGate API v2](https://developer.coingate.com/docs/api-overview).
This is open source library is provided by [SociumNET](https://socium.net) team and it is used in some internal
projects.
## Installation
You can install the library using PIP:
`$ pip install coingate_api`
## Quick start
Try it:
```python
from coingate_api import CoingateAPI
api = CoingateAPI(auth_token='your-auth-token', environment='sandbox')
print(api.ping())
```
Only replace "your-auth-token" to your token from CoinGate of CoinGate sandbox
## How to
Default behavior of API uses retries for requests:
* 3 retries
* with back-off factor 0.2
* http statuses of response for retries: 500, 502, 504
You can change all these params by initialization of API client:
```python
from coingate_api import CoingateAPI
api = CoingateAPI(auth_token='your-auth-token', environment='sandbox',
retries=5, backoff_factor=0.5, status_forcelist=(500, 502, 504, 505))
```
#### Methods of API:
* `api.test_connection()` - tests authentication. Should return simple "OK"
* `api.ping()` - tests connection to server. Should return "pong"
* `api.exchange_rate(from_='EUR', to='USD')` - check documentation of API
* `api.exchange_rates()` - check documentation of API
* `api.ip_addresses()` - check documentation of API
* `api.orders(per_page=100, page=1, sort='created_at_desc', **kwargs)` - check documentation of API.
Values of kwargs can contain also `created_at_from` and `created_at_to`
* `api.checkout(order_id, pay_currency='BTC')` - check documentation of API
* `api.create_order(price_amount, price_currency, receive_currency, **kwargs)` - check documentation of API.
Values of kwargs can contain also `order_id`, `title`, `description`, `callback_url`, `cancel_url`, `success_url`, `token`
#### Exceptions
```python
from coingate_api import CoingateAPI, api_error
api = CoingateAPI(auth_token='your-auth-token', environment='sandbox')
try:
print(api.test_connection())
except api_error.APIError as e:
print(e)
```
Exceptions hierarchy:
* `APIError`
* `Unauthorized`
* `BadCredentials`
* `BadAuthToken`
* `AccountBlocked`
* `IPAddressIsNotAllowed`
* `NotFound`
* `PageNotFound`
* `RecordNotFound`
* `OrderNotFound`
* `UnprocessableEntity`
* `OrderIsNotValid`
* `RateLimitError`
* `InternalServerError` - notice that client will do retries for this error by default
## Contribution
You can be free to contribute in the project. You should only create PR with a short description what it is for and
what the problem can be solved by your PR.
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
coingate_api-0.1.1.tar.gz
(4.2 kB
view details)
File details
Details for the file coingate_api-0.1.1.tar.gz
.
File metadata
- Download URL: coingate_api-0.1.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75eec266ed70644c767480218a7c5716b9c5b9282e7ba383431e8c2a3ad340c3 |
|
MD5 | 1b8692972363a51b2df1cb78a273b1ae |
|
BLAKE2b-256 | d0401551e4b0c351e81b3ae53381059f1c8c5427576d01c0fe75372bf4d34181 |