Skip to main content

Circle Platform Services - Python Client

PyPI version

WARNING: work in progress and subject to change

A python client and CLI for working with Circle Platform Services.

Installation

pip install cps-client

Usage

cps-client uses an enviroment variable to fetch your API key.

export CPS_API_KEY="<api-key>"

CLI

Installation provides a command line interface for interacting with CPS.

Usage: cps [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  configuration-get           Get global CPS configuration.
  subscription-create         Create a subscription.
  subscription-delete         Delete a subscription.
  subscriptions-get           Get a collection of subscriptions.
  transfer-create-blockchain  Create transfers from a wallet to blockchain...
  transfer-create-wallet      Create transfers from a wallet to another...
  transfer-get                Get info about transfers.
  transfers-get               Get collection of transfers.
  wallet-address-create       Create a new wallet address.
  wallet-addresses-get        Get a collection of wallet addresses.
  wallet-create               Create a new wallet.
  wallet-get                  Get a wallet.
  wallets-get                 Get a collection of wallets.

Library

You can also use cps-client as a library.

from cps_client import api

# you can get your own at https://my-sandbox.circle.com/
API_KEY="my-circle-sanbox-api-key" 

source = api.WalletLocation(walletid)
destination = api.BlockchainLocation(address, chain)
amount = api.Money(amount, currency)

cpsAPI = api.Client("https://api-sandbox.circle.com", API_KEY)
transfer = cpsAPI.create_transfer(source, destination, amount)

print(transfer)

"""
Output:

{
    "id": "b08478d5-a110-4b0e-9136-4b9d94601c65",
    "source": {
        "type": "wallet",
        "id": "1000004286"
    },
    "destination": {
        "type": "blockchain",
        "address": "0x71715Da6ADa699e3a1a5C2664A55fF3D179c86EE",
        "chain": "ETH"
    },
    "amount": {
        "amount": "0.05",
        "currency": "USD"
    },
    "status": "complete",
    "transactionHash": "0x52176702740c8720d77ade3f20014396a4a2eb13d09dd1e6bffcc6f209a45326"
}
"""

Development

Fork this repo and do the following to get setup:

# clone the repository and add upstream so you can fetch the latest changes
git clone git@github.com:<your-username>/cps-client-python.git
git remote add upstream git@github.com:belljustin/cps-client-python.git

# create a virtualenv
cd cps-client-python
virtualenv -p python3 venv
source venv/bin/activate

# install the project in editable mode
pip install -e .

Now, as long as you're using the virtualenv, you can use cps-client with all the edits you've made including running the cli tool.

To test, you'll need a CPS API key. You can get this by signing up for the sandbox here: https://my-sandbox.circle.com/. To run the cli and integration tests, this needs to exist as an environment variable named $CPS_API_KEY

You can then run all the integration tests via the make file:

make integration

or run individual tests with the python unittest command, e.g:

python -m unittest tests.integration.test_integration.TestBasic.test_get_wallet_addresses

To submit a contribution, open a pull request against the master branch on upstream.

Release files for cps-client 0.1.13

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

Source distribution (sdist)

Source distribution for cps-client 0.1.13
File Size Uploaded
cps_client-0.1.13.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cps-client 0.1.13
File Interpreter ABI Platform
cps_client-0.1.13-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / cps_client-0.1.13.tar.gz

Download URL cps_client-0.1.13.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
903a2bb94f3a04be2ec75a4506d008f27a2b3e7c96bb976e242ac2d7e426fec9
BLAKE2b-256 checksum
How to use checksums
dd6aa6a75bb92b434fb3ef524b9b1a6c2e04f44068457c0fd95a15584d103f78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / cps_client-0.1.13-py3-none-any.whl

Download URL cps_client-0.1.13-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c32130590f259c65e122fea452c80e450180c2687d4d3971ec11c11c1bd8efb
BLAKE2b-256 checksum
How to use checksums
56bfcc27403e81019d761953135ddeea31fd394153ffc7f28753e326ff3a71d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.1.13 This release

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

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