Skip to main content

crystal-ball-markets

Exchange rates, currency conversion and the value of gold by weight, in Python: a client for the free Crystal Ball Markets exchange rate and gold price API, the sums behind it, and a command line. The API covers exchange rates for 60 currencies, the gold price in local money in 69 countries, and live quotes for forex, metals, energy, indices, shares and crypto. JSON, refreshed every minute, no sign-up.

pip install crystal-ball-markets

Python 3.8 or later. Standard library only, with type hints.

The client

import os
from crystal_ball_markets import Client, ATTRIBUTION_HTML

cbm = Client(
    site="https://your-site.com/rates",   # the page of your site that shows the figures
    key=os.environ["CBM_SITE_KEY"],       # a secret of your own, 16+ characters
)

cbm.rate("EUR")                           # euros per 1 US dollar
cbm.convert(100, "GBP", "NGN")            # 100 pounds in naira
cbm.gold_value(10, "tola", "22k", "INR")  # ten tolas of 22 karat gold in rupees
cbm.gold_price("IN")                      # the gold price in India, in its own money and unit
cbm.quote("XAUUSD")                       # a live quote

The first call reserves your site for your key. Responses are cached for at least 60 seconds.

Method Returns
rates(), gold(), quotes() the three files, in full
rate(code) units of code per 1 USD
convert(amount, from_code, to_code) amount converted through USD
gold_value(weight, unit, purity, currency) what a weight of gold is worth
gold_price(country) the gold entry for an ISO country code
quote(ticker) one market's quote, e.g. EURUSD

Gold is weighed in gram, ounce (troy), tola, pavan, baht, tael or kilogram, at 24k, 22k, 21k, 18k or 14k. The figure is the value of the gold itself at the international price: shop prices add local duty, tax and making charges.

The sums

For when the rates are already on hand. No network.

from crystal_ball_markets import convert, gold_value, parse_amount, format_money, unit_grams, purity_fineness

rates = cbm.rates()["data"]["rates"]      # units of each currency for one US dollar

convert(100, "GBP", "NGN", rates)         # None when a rate is missing
gold_value(10, unit_grams("tola"), purity_fineness("22k"), usd_per_ounce, rates["INR"]["rate"])
parse_amount("1.234,56")                  # 1234.56: reads the ways people write numbers
format_money(0.1406, "GBP")               # '0.141 GBP': enough decimals for a small amount

The command line

export CBM_SITE=https://your-site.com/rates
export CBM_SITE_KEY=...                   # your own secret, 16+ characters

cbm-rates rate EUR                        # 1 USD = 0.910481 EUR
cbm-rates convert 100 GBP NGN
cbm-rates gold 10 tola 22k INR
cbm-rates gold-price IN
cbm-rates quote XAUUSD
cbm-rates --json convert 100 GBP NGN      # the same, as JSON

python -m crystal_ball_markets does the same.

Terms in short

Wherever the figures appear, show this link. It must be visible and unchanged, with no nofollow, ugc or sponsored. It is also available as ATTRIBUTION_HTML:

<a href="https://crystalballmarkets.com/markets">Rates by Crystal Ball Markets</a>

The named site must be on a domain of your own. Each address allows up to 60 requests a minute. The figures are indicative and for information only: they are not dealing prices and not an offer to buy or sell. Full terms: https://crystalballmarkets.com/markets/rates-api.

From version 1

Nothing was removed. Version 2 adds gold_value(), the sums and the command line. rate("USD") now answers 1.0.

The client is MIT licensed. Questions: support@crystalballmarkets.com.

Metadata

Release files for crystal-ball-markets 2.0.0

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

Source distribution (sdist)

Source distribution for crystal-ball-markets 2.0.0
File Size Uploaded Provenance Actions
crystal_ball_markets-2.0.0.tar.gz 10.8 kB With provenance Details for crystal_ball_markets-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for crystal-ball-markets 2.0.0
File Interpreter ABI Platform Actions
crystal_ball_markets-2.0.0-py3-none-any.whl Python 3 none any Details for crystal_ball_markets-2.0.0-py3-none-any.whl

Total release size: 21.8 kB

Release files / crystal_ball_markets-2.0.0.tar.gz

Download URL crystal_ball_markets-2.0.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9091aafb1635a220b39bfa66f4228be74831d5936bfe8fadce3b7e8dfd9327f0
BLAKE2b-256 checksum
How to use checksums
cf08e47ae4e65bda601f409ade445f2a98795a0159cd4443b3f5a03f0755d3c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / crystal_ball_markets-2.0.0-py3-none-any.whl

Download URL crystal_ball_markets-2.0.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca59cfd54b763f81b0fa8aa6db5f2a134b7f71f460db666f6608b1e9432ed18e
BLAKE2b-256 checksum
How to use checksums
21e6df333468ffa960f18575e54e2dc0c97a66b03d1729cb6981a6c8d1f6ab3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for crystal-ball-markets 2.0.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for crystal_ball_markets-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

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

2.0.0 This release

2 release files Full 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