Clear and concise CoinsPro API library written in Python for coins.ph
- Blocking / synchronous & AsyncIO Compatible
- Full HMAC Authentication
- Full implementation of API data models & enums
- Type-hinted
- Minimal Third-party Dependencies (
dataclasses-json
,aiohttp
) - REST Endpoints:
- Un-authenticated:
- HMAC Authenticated:
- Wallet Endpoints:
- Account endpoints:
- Test New Order
- New Order
- Query Order
- Cancel Order
- Cancel All Open Orders on a Symbol
- Get Current Open Orders
- Get Order History
- Get Account Information
- Get Account Trade List
- Withdraw (To Coins.ph Account)
- Get Deposit order history(deposit order which deposit from coins_ph to exchange)
- Get Withdraw Order History (withdrawal order which withdraw from exchange to coins_ph)
- Get Trade Fee
- Request a Payment
- Get Payment Request
- Cancel payment request
- Send reminder for payment request
- API Key Authenticated:
- WebSocket Stream:
- User Data Event Stream:
- Asyncio Client
- Blocking Client
- Data Models:
For precision purposes, we store decimals as python standard Decimal
objects, this is to prevent any inherent
rounding errors. These Decimal
objects should then be cast into a float
or an int
in order to do arithmetic
operations.
- Rate limit management
- Enums for symbols (would require frequent updates)
import os
from cpro.client.rest import BlockingHTTPClient, AsyncIOHTTPClient, APICredentials
from cpro.models.rest.request import CoinsInformationRequest
from cpro.models.rest.response import CoinsInformationResponse
from cpro.models.rest.endpoints import APIEndpoints
credentials = APICredentials(
api_key=os.getenv("API_KEY"),
api_secret=os.getenv("API_SECRET")
)
# blocking/non-async example:
client = BlockingHTTPClient(credentials)
response: CoinsInformationResponse = APIEndpoints.GET_ALL_USER_COINS.execute(
client,
CoinsInformationRequest()
)
# non-blocking/async example:
async_client = AsyncIOHTTPClient(credentials)
response: CoinsInformationResponse = await APIEndpoints.GET_ALL_USER_COINS.execute_async(
# diff: ^^^^^ ^^^^^^
client,
CoinsInformationRequest()
)
# >>> response: CoinsInformationResponse(coins=[Coin(coin='PHP', name='PHP', ... )])
NOTE: Guide assumes you have the repository locally cloned.
Running tests:
- Install required test dependencies:
pip install -e "cpro.py[test]"
- **Create a
./tests/.env
file with your API key and secret, example in./tests/.env.example
** - Run unit tests
python -m pytest
Made as a submission for Coins.ph Hackathon 2023 ❤️
Project start: August 9, 2023