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
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 LIMITEDInstall
pip install dataandapisWith another tool:
uv add dataandapis
poetry add dataandapisQuick 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 LIMITEDIf 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.
| Class | When |
|---|---|
| AuthenticationError | 401: the key is missing or not valid |
| PaymentRequiredError | 402: the subscription is past due; payment_url holds the link to pay |
| QuotaExceededError | 429: the monthly token allowance is used up |
| ApiError | Any other error status, such as 400 or 404 |
| ApiTimeoutError | No response within the timeout; also a built-in TimeoutError |
| ApiConnectionError | The 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:
raiseRetries, 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.
- Air Quality API
client.air_quality - Aircraft API
client.aircraft - Aircraft Registrations API
client.aircraft_registrations - Airlines API
client.airlines - Airport Status API
client.airport_status - Airports API
client.airports - Animals API
client.animals - Anime API
client.anime - Artworks API
client.artworks - Astronomy API
client.astronomy - Attractions API
client.attractions - BIN & Card Validator API
client.bin_card_validator - Baby Names API
client.baby_names - Banks API
client.banks - Barcode Generator API
client.barcode_generator - Barcode Lookup API
client.barcode_lookup - Bible Multi-Translation API
client.bible_multi_translation - Business Patterns API
client.business_patterns - Calories Burned API
client.calories_burned - Cars API
client.cars - Cats API
client.cats - Chemical Elements API
client.elements - Climate Normals API
client.climate_normals - Cocktails API
client.cocktails - Colors API
client.colors - Company Enrichment API
client.companies - Company Financials API
client.company_financials - Continents, Countries And Cities API
client.continents_countries_and_cities - Country Flags API
client.country_flags - Country Indicators API
client.country_indicators - Crypto Price API
client.crypto_prices - Currency Exchange Rates API
client.currency_rates - DNS & WHOIS Lookup API
client.dns_whois_lookup - Day In History API
client.day_in_history - Demographics API
client.demographics - Dictionary API
client.dictionary - Disposable Email Checker API
client.disposable_email_checker - Dogs API
client.dogs - Drugs API
client.drugs - EV Chargers API
client.ev_chargers - Earthquakes API
client.earthquakes - Email Validation API
client.email_validation - Emission Factors API
client.emission_factors - Emoji API
client.emoji - Federal Contracts API
client.federal_contracts - Federal Grants API
client.grants - Federal Register API
client.federal_register - Food Nutrition Information API
client.food_nutrition_information - Food Recalls API
client.food_recalls - Fuel Stations API
client.fuel_stations - Geocoding API
client.geocoding - HTML Render
client.html_render - Healthcare Providers API
client.healthcare_providers - Hearthstone API
client.hearthstone - Horoscope & Zodiac API
client.horoscope_zodiac - Hospitals API
client.hospitals - Hurricanes API
client.hurricanes - IBAN & SWIFT/BIC Validator API
client.iban_swift_validator - IP Intelligence API
client.ip_intelligence - Image to Text API
client.image_to_text - Inflation API
client.inflation - Jokes API
client.jokes - Language Detection API
client.language_detection - Logos API
client.logos - Lorem Ipsum API
client.lorem_ipsum - Lottery API
client.lottery - Manga, Manhua And Manhwa API
client.manga_manhua_manhwa - Marine Buoys API
client.buoys - Mobile Devices API
client.mobile_devices - Mortgage & Loan Calculator API
client.mortgage_loan_calculator - Motorcycles API
client.motorcycles - Movies & TV API
client.movies - Name Intelligence API
client.name_intelligence - Nonprofits API
client.nonprofits - Notable People API
client.notable_people - Novels API
client.novel - Object Detection API
client.object_detection - Occupations API
client.occupations - Password Generator API
client.password_generator - Phone Number Validation API
client.phone_validation - Pokemon Unite Pokemons API
client.pokemon_unite - Population API
client.population - Power Plants API
client.power_plants - Product Recalls API
client.product_recalls - Profanity Filter API
client.profanity_filter - Public Domain Books API
client.books - Public Holidays API
client.public_holidays - QR Code Generator API
client.qr_code_generator - Quotes API
client.quotes - Random Image & Placeholder API
client.random_image - Random User API
client.random_user - Recipes API
client.recipes - Riddles API
client.riddles - River Conditions API
client.rivers - SSL Checker Api
client.ssl_checker - Salary Benchmarks API
client.salary_benchmarks - Sales Tax & VAT API
client.sales_tax_vat - Sanctions Screening API
client.sanctions - Seaports API
client.seaports - Sentiment Analysis API
client.sentiment_analysis - Space Launches API
client.space_launches - Spell Check API
client.spell_check - Stock Tickers API
client.stock_tickers - Tariff Codes API
client.tariff_codes - Tech Stack API
client.tech_stack - Text Embeddings API
client.text_embeddings - Thesaurus API
client.thesaurus - Tides API
client.tides - Timezone & World Time API
client.timezone_world_time - Trading Calendar API
client.trading_calendar - Traffic Fatalities API
client.traffic_fatalities - Translation API
client.translation - Travel Advisories API
client.travel_advisories - Trending API
client.trending - Trivia API
client.trivia - URL Metadata API
client.url_metadata - US Lawyers API
client.us_lawyers - Unit Converter API
client.unit_converter - Universities API
client.universities - User Agent Parser API
client.user_agent_parser - VAT Validation API
client.vat - VIN Decoder API
client.vin_decoder - Vehicle Recalls API
client.vehicle_recalls - Video Games API
client.video_games - Watches API
client.watches - Weather API
client.weather - Wildfires API
client.wildfires - Zip & Postal Code API
client.zip_postal_code
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.