One Python package for 128 data APIs

dataandapis is the official Python client for the catalog. Every API is an attribute of the client and every endpoint is a method with keyword arguments, a docstring and type hints, so your editor completes the call and you never build a URL by hand.

pip install dataandapis
  • Version 0.1.0
  • MIT licence
  • No dependencies
  • Type hints included
  • Python 3.9 or later
main.py
from dataandapis import DataAndApis

# reads DATAANDAPIS_API_KEY from the environment
client = DataAndApis()

check = client.vat.validate_vat_number(vat="IE6388047V")

print(check["valid"], check["name"])
# True GOOGLE IRELAND LIMITED

Install

pip install dataandapis

With another tool:

uv add dataandapis
poetry add dataandapis

Quick start

Create a free account and generate a key on your dashboard. The Free plan includes 500 tokens a month and needs no card; most calls cost 1 token. Get a free API key →

import os

from dataandapis import DataAndApis

client = DataAndApis(os.environ["DATAANDAPIS_API_KEY"])

check = client.vat.validate_vat_number(vat="IE6388047V")
print(check["valid"], check["name"])  # True GOOGLE IRELAND LIMITED

If you leave the key out, the client reads the DATAANDAPIS_API_KEY environment variable.

How calls are named

The attribute is the API's address on this site in snake case, so /apis/barcode-lookup is client.barcode_lookup. The method is the endpoint's name in snake case, so Lookup By Barcode is lookup_by_barcode.

Path and query parameters are keyword arguments, named exactly as the API names them. A JSON body goes in body. A parameter whose name is a Python keyword takes a trailing underscore: from is from_.

# GET /v1/products/{barcode}: the path parameter is a keyword argument
product = client.barcode_lookup.lookup_by_barcode(barcode="3017620422003")

# Query parameters are keyword arguments too
result = client.sanctions.screen_name(name="Viktor Bout", min_score=0.85)

# A Python keyword takes a trailing underscore: "from" is from_
fx = client.currency_rates.convert(from_="USD", to="GBP", amount=100)

# POST: the JSON body goes in "body"
batch = client.sanctions.screen_names_batch(
    body={"names": ["Viktor Bout", "Acme Trading LLC"]},
)

Every API page shows the exact call for each of its endpoints, ready to copy.

Errors

Every failure is an instance of DataAndApisError, with one class per case.

ClassWhen
AuthenticationError401: the key is missing or not valid
PaymentRequiredError402: the subscription is past due; payment_url holds the link to pay
QuotaExceededError429: the monthly token allowance is used up
ApiErrorAny other error status, such as 400 or 404
ApiTimeoutErrorNo response within the timeout; also a built-in TimeoutError
ApiConnectionErrorThe request never got a response
from dataandapis import ApiError, DataAndApis, QuotaExceededError

try:
    client.barcode_lookup.lookup_by_barcode(barcode="0000000000000")
except QuotaExceededError:
    ...  # upgrade the plan or wait for the monthly reset
except ApiError as err:
    if err.status == 404:
        print("Not in the catalogue:", err.message)
    else:
        raise

Retries, timeouts and token balance

GET requests are retried up to twice after a network error or a 408, 502, 503 or 504 response. POST requests and 429 responses are never retried. Each attempt has a 30 second timeout. Both numbers can be changed for the client or for one call. Failed calls do not use tokens.

The client keeps connections open between calls, so a loop of lookups does not pay for a new TLS handshake each time. One client can be shared between threads.

Every response reports how many tokens are left on your key, and on_response receives that number.

def watch(info):
    if info.tokens_remaining is not None and info.tokens_remaining < 50:
        print("Running low on tokens")

client = DataAndApis(
    timeout=30,      # seconds per attempt
    max_retries=2,   # retries for GET requests
    on_response=watch,
)

# Or for one call
client.vat.validate_vat_number(
    vat="FR40303265045",
    options={"timeout": 45, "max_retries": 0},
)

Endpoints that return a file

Image and document endpoints return bytes.

png = client.qr_code_generator.generate_qr_code(data="https://dataandapis.com", size=400)

with open("qr.png", "wb") as f:
    f.write(png)

Type hints

Type hints ship with the package, so mypy and Pyright check your calls and your editor completes the keys of a response. Response types are inferred from one sample response per endpoint, so treat them as a guide: a field can be None or missing for other inputs.

from dataandapis.types import VatValidateVatNumberResponse

def is_valid(check: VatValidateVatNumberResponse) -> bool:
    return check["valid"]

asyncio

The client is synchronous. In async code, run a call in a worker thread.

import asyncio

check = await asyncio.to_thread(client.vat.validate_vat_number, vat="IE6388047V")

Where it runs

Python 3.9 or later; the tests run on Python 3.9, 3.13 and 3.14. The package uses only the standard library, so there is nothing else to install.

Keep your key on the server: in an environment variable or a secrets manager, not in code that ships to users.

All 128 APIs in the package

Version 0.1.0 covers 128 APIs and 529 endpoints. Search for an API to see its name on the client.

Not using Python?

JavaScript and TypeScript have their own package: npm install dataandapis. Every API is also plain REST with an X-Api-Key header, so any HTTP client works, and each API page has samples in PHP and Go and an OpenAPI 3.1 document.