Skip to main content

coinblockpro

A toy server written in Sanic to mimic an online currency exchange, with REST and websocket APIs.

Installation

coinblockpro is available on the Python Package Index (PyPI).

pip install coinblockpro

Run

The bash script run_cbp_server is placed in the user's bin when the package is installed. Running:

./run_cbp_server

will produce output like the following:

[2020-10-05 19:19:37 +0100] [34227] [INFO] Creating ticker db at /tmp/tickers.db.
[2020-10-05 19:19:37 +0100] [34227] [INFO] Created db.
[2020-10-05 19:19:37 +0100] [34227] [INFO] Running websocket server.
[2020-10-05 19:19:37 +0100] [34227] [INFO] Goin' Fast @ http://0.0.0.0:8001
[2020-10-05 19:19:37 +0100] [34227] [INFO] Starting modulation coroutine.
[2020-10-05 19:19:37 +0100] [34227] [INFO] Starting worker [34227]
[2020-10-05 19:19:38 +0100] [34228] [INFO] Running REST server.
[2020-10-05 19:19:38 +0100] [34228] [INFO] Goin' Fast @ http://0.0.0.0:8000
[2020-10-05 19:19:38 +0100] [34228] [INFO] Starting worker [34228]
[2020-10-05 19:19:43 +0100] [34227] [INFO] update to market btc_ltc: 3350.505 -> 3292.16
[2020-10-05 19:19:49 +0100] [34227] [INFO] update to market ltc_dot: 2752.763 -> 2708.661

Connecting to the server

The server runs on the localhost.

The REST API is available on port 8000, while the websocket API is available on port 8001.

REST endpoints:

/full_ticker - no parameters, returns a json response of the form:

{ 'result':  
    {'btc_eur':  2134.12, 'btc_usd': 2245.76} ... }
}

/single_ticker - single parameter "market", must be given. Returns a json response of the form:

{ 'result':
    {'btc_eur': 2134.12}
}

The list of available markets can be found at:

import coinblockpro
coinblockpro.markets

Some example requests are given below:

import requests
r1 = requests.get('http://0.0.0.0:8000/full_ticker')
r2 = requests.get('http://0.0.0.0:8000/singler_ticker', params={'market': 'btc_eur'})

Websocket API

The websocket API runs on the localhost, on port 8001, and gives real-time information on markets as they change at the /ticker_feed endpoint.

An example configuration using the websockets library is given below.

import websockets
import asyncio
import websockets


async def subscribe():
    async with websockets.connect('ws://0.0.0.0:8001/ticker_feed') as ws:
        while True:
            resp = await ws.recv()
            print(resp)

if __name__ == '__main__':
    asyncio.run(subscribe())

Example client

UNDER CONSTRUCTION

Metadata

Release files for coinblockpro 0.0.2

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

Source distribution (sdist)

Source distribution for coinblockpro 0.0.2
File Size Uploaded Provenance
coinblockpro-0.0.2.tar.gz 5.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for coinblockpro 0.0.2
File Interpreter ABI Platform
coinblockpro-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 23.3 kB

Release files / coinblockpro-0.0.2.tar.gz

Download URL coinblockpro-0.0.2.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1adae22139df3e9a6f8ee080c7d5d9a46de333ce179b9bc97edb8dc1bbff2fbb
BLAKE2b-256 checksum
How to use checksums
c59bca1345c12c57ac014326b3e6a960f9050012c235e091219955c1d6527e3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200917 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Release files / coinblockpro-0.0.2-py3-none-any.whl

Download URL coinblockpro-0.0.2-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
adaae7ea32fde87d0c62c68911945ec471a800302f772231c27beb25abe5491f
BLAKE2b-256 checksum
How to use checksums
ed8c7ba60721fb17e0f80abccdbcbc763b1daba38bab5b39c1d2e4ec0a6706d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200917 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Security for coinblockpro 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

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