Skip to main content

Official Python SDK for the Bitculator Data API

Project description

Bitculator Data API — Python SDK

bitculator.com · API documentation · Get an API key PyPI — bitculator · GitHub

The official Python SDK for the Bitculator Data API. Zero dependencies (standard-library only), typed, works on Python 3.9+.

Keep your API key server-side. It is a Bearer token with the data-api ability and is not meant for client-side embedding.

Install

pip install bitculator

Quick start

import os
from bitculator import Bitculator

client = Bitculator(os.environ["BITCULATOR_API_KEY"])

# Single resource — the {"data": ...} envelope is unwrapped for you.
bitcoin = client.coins.get("bitcoin")
print(bitcoin["price"])   # "63520.780763913" — a decimal string, never rounded

# A paginated list.
page = client.coins.list(per_page=50, sort="-marketcap")
print(page.data, page.meta["total"])

Prices are decimal strings

Prices, rates, and supplies come back as strings (e.g. "63520.780763913") to preserve full precision. Use decimal.Decimal if you need to do math — do not pass them through float(), which silently loses precision.

Pagination

Every paginated method returns a Page. Read one page, or iterate to walk them all:

# One page at a time.
page = client.exchanges.list(per_page=100)
while page is not None:
    for exchange in page.data:
        print(exchange["name"])
    page = page.next_page()

# Or auto-paginate across every page (iterating a Page walks all pages).
for coin in client.coins.list(sort="-marketcap"):
    print(coin["symbol"])

Errors

Every failure derives from BitculatorError; HTTP failures raise a status-specific subclass carrying the {"error": {"code", "message", "details"}} envelope.

from bitculator import ValidationError, RateLimitError, APIError

try:
    client.coins.list(per_page=9999)  # over the plan cap -> 422
except ValidationError as err:
    print(err.code, err.details)
except RateLimitError as err:
    print("retry after", err.retry_after)
except APIError as err:
    print(err.status, err.message)
Status Exception
401 AuthenticationError
403 PermissionDeniedError (plan does not include this endpoint)
404 NotFoundError
422 ValidationError (.details holds the field errors)
429 RateLimitError (.retry_after)
5xx ServerError

Timeouts raise APITimeoutError; network failures raise APIConnectionError.

Quota

Every response carries X-Quota-* headers, surfaced on the client after each call:

client.coins.list()
print(client.quota)   # Quota(limit=..., remaining=..., reset=..., raw={...})

Configuration

Bitculator(
    api_key,                          # required (positional)
    base_url="https://bitculator.com",  # default
    timeout=30.0,                     # seconds, default
    max_retries=2,                    # auto-retry 429 / 5xx / network; 0 to disable
)

Passing parameters

Query parameters are keyword arguments and mirror the API's names exactly (per_page, min_price, ...). For the reserved word from (in convert), pass from_ — the SDK maps it back to from on the wire:

client.conversion.convert(from_="btc", to="usd", amount=1)

Resources

coins · prices · markets · exchanges · wallets · global_market · sentiment · indicators · liquidations · conversion · calculators · editorial · alarms · webhooks · meta

Full endpoint reference: https://bitculator.com/en/documentation/api/v1.

License

MIT

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

bitculator-1.0.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitculator-1.0.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file bitculator-1.0.0.tar.gz.

File metadata

  • Download URL: bitculator-1.0.0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for bitculator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 21dfa455d44eeeeaebfd9423c90939f9407daf23f5133d13605b9cb63c4faac2
MD5 813c43521e3859dbbdfaa8aa35909e09
BLAKE2b-256 cfa4c632c32de46ef56d3590693998af170e908ce9b8917d97acd31d0d7c9793

See more details on using hashes here.

File details

Details for the file bitculator-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bitculator-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for bitculator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dda35a0787f1a8b2ccab349282ff8f3f78854ea16175c5674e7d6264251a0ec8
MD5 ea5dc28ebb999b714399912c49e2c98b
BLAKE2b-256 7b42c8362513e9a9713a6191554461df4efb32fc096614de18cc0073c98357d5

See more details on using hashes here.

Supported by

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