One npm package for 128 data APIs
dataandapis is the official JavaScript and TypeScript client for the catalog. Every API is a property of the client and every endpoint is a typed method, so your editor completes the call and you never build a URL by hand.
npm install dataandapis- Version 0.1.0
- MIT licence
- No dependencies
- import and require
- Node.js 18 or later
import { DataAndApis } from "dataandapis";
// reads DATAANDAPIS_API_KEY from the environment
const client = new DataAndApis();
const check = await client.vat.validateVatNumber({
vat: "IE6388047V",
});
console.log(check.valid, check.name);
// true "GOOGLE IRELAND LIMITED"Install
npm install dataandapisWith another package manager:
pnpm add dataandapis
yarn add dataandapis
bun 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 { DataAndApis } from "dataandapis";
const client = new DataAndApis({ apiKey: process.env.DATAANDAPIS_API_KEY });
const check = await client.vat.validateVatNumber({ vat: "IE6388047V" });
console.log(check.valid, check.name); // true "GOOGLE IRELAND LIMITED"const { DataAndApis } = require("dataandapis");
const client = new DataAndApis({ apiKey: process.env.DATAANDAPIS_API_KEY });
client.vat.validateVatNumber({ vat: "IE6388047V" }).then((check) => {
console.log(check.valid, check.name);
});If you leave apiKey out, the client reads the DATAANDAPIS_API_KEY environment variable.
How calls are named
The property is the API's address on this site in camelCase, so /apis/barcode-lookup is client.barcodeLookup. The method is the endpoint's name, so Lookup By Barcode is lookupByBarcode.
Path and query parameters go in one object. A JSON body goes in body.
// GET /v1/products/{barcode}: the path parameter goes in the object
const product = await client.barcodeLookup.lookupByBarcode({ barcode: "3017620422003" });
// Query parameters go in the same object
const result = await client.sanctions.screenName({ name: "Viktor Bout", min_score: 0.85 });
// POST: the JSON body goes in "body"
const batch = await client.sanctions.screenNamesBatch({
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; paymentUrl holds the link to pay |
| QuotaExceededError | 429: the monthly token allowance is used up |
| ApiError | Any other error status, such as 400 or 404 |
| TimeoutError | No response within the timeout |
| ConnectionError | The request never got a response |
import { ApiError, DataAndApis, QuotaExceededError } from "dataandapis";
try {
await client.barcodeLookup.lookupByBarcode({ barcode: "0000000000000" });
} catch (err) {
if (err instanceof QuotaExceededError) {
// upgrade the plan or wait for the monthly reset
} else if (err instanceof ApiError && err.status === 404) {
console.log("Not in the catalogue:", err.message);
} else {
throw err;
}
}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.
Every response reports how many tokens are left on your key, and onResponse receives that number.
const client = new DataAndApis({
timeout: 30_000, // milliseconds per attempt
maxRetries: 2, // retries for GET requests
onResponse: ({ api, status, tokensRemaining }) => {
if (tokensRemaining !== undefined && tokensRemaining < 50) console.warn("Running low on tokens");
},
});
// Or for one call
await client.vat.validateVatNumber({ vat: "FR40303265045" }, { timeout: 45_000, maxRetries: 0 });Endpoints that return a file
Image and document endpoints resolve to a Blob.
import { writeFile } from "node:fs/promises";
const png = await client.qrCodeGenerator.generateQrCode({ data: "https://dataandapis.com", size: 400 });
await writeFile("qr.png", Buffer.from(await png.arrayBuffer()));TypeScript
Types ship with the package. Response types are inferred from one sample response per endpoint, so treat them as a guide: a field can be null or missing for other inputs. Pass your own type as a type argument when you need a stricter one.
interface Holiday {
date: string;
name: string;
}
const next = await client.publicHolidays.nextHolidays<{ holidays: Holiday[] }>({ country: "MX" });
// Every parameter and response type is exported
import type { VatValidateVatNumberParams, VatValidateVatNumberResponse } from "dataandapis";Where it runs
Node.js 18 or later; the tests run on Node.js 18, 20, 22 and 25. The package only needs the built-in fetch, so Bun, Deno and Cloudflare Workers should work as well, although they are not part of the test run.
Call the APIs from your server. They do not send CORS headers, so the browser blocks requests from a web page, and a key in front-end code would be visible to every visitor.
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.airQuality - Aircraft API
client.aircraft - Aircraft Registrations API
client.aircraftRegistrations - Airlines API
client.airlines - Airport Status API
client.airportStatus - 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.binCardValidator - Baby Names API
client.babyNames - Banks API
client.banks - Barcode Generator API
client.barcodeGenerator - Barcode Lookup API
client.barcodeLookup - Bible Multi-Translation API
client.bibleMultiTranslation - Business Patterns API
client.businessPatterns - Calories Burned API
client.caloriesBurned - Cars API
client.cars - Cats API
client.cats - Chemical Elements API
client.elements - Climate Normals API
client.climateNormals - Cocktails API
client.cocktails - Colors API
client.colors - Company Enrichment API
client.companies - Company Financials API
client.companyFinancials - Continents, Countries And Cities API
client.continentsCountriesAndCities - Country Flags API
client.countryFlags - Country Indicators API
client.countryIndicators - Crypto Price API
client.cryptoPrices - Currency Exchange Rates API
client.currencyRates - DNS & WHOIS Lookup API
client.dnsWhoisLookup - Day In History API
client.dayInHistory - Demographics API
client.demographics - Dictionary API
client.dictionary - Disposable Email Checker API
client.disposableEmailChecker - Dogs API
client.dogs - Drugs API
client.drugs - EV Chargers API
client.evChargers - Earthquakes API
client.earthquakes - Email Validation API
client.emailValidation - Emission Factors API
client.emissionFactors - Emoji API
client.emoji - Federal Contracts API
client.federalContracts - Federal Grants API
client.grants - Federal Register API
client.federalRegister - Food Nutrition Information API
client.foodNutritionInformation - Food Recalls API
client.foodRecalls - Fuel Stations API
client.fuelStations - Geocoding API
client.geocoding - HTML Render
client.htmlRender - Healthcare Providers API
client.healthcareProviders - Hearthstone API
client.hearthstone - Horoscope & Zodiac API
client.horoscopeZodiac - Hospitals API
client.hospitals - Hurricanes API
client.hurricanes - IBAN & SWIFT/BIC Validator API
client.ibanSwiftValidator - IP Intelligence API
client.ipIntelligence - Image to Text API
client.imageToText - Inflation API
client.inflation - Jokes API
client.jokes - Language Detection API
client.languageDetection - Logos API
client.logos - Lorem Ipsum API
client.loremIpsum - Lottery API
client.lottery - Manga, Manhua And Manhwa API
client.mangaManhuaManhwa - Marine Buoys API
client.buoys - Mobile Devices API
client.mobileDevices - Mortgage & Loan Calculator API
client.mortgageLoanCalculator - Motorcycles API
client.motorcycles - Movies & TV API
client.movies - Name Intelligence API
client.nameIntelligence - Nonprofits API
client.nonprofits - Notable People API
client.notablePeople - Novels API
client.novel - Object Detection API
client.objectDetection - Occupations API
client.occupations - Password Generator API
client.passwordGenerator - Phone Number Validation API
client.phoneValidation - Pokemon Unite Pokemons API
client.pokemonUnite - Population API
client.population - Power Plants API
client.powerPlants - Product Recalls API
client.productRecalls - Profanity Filter API
client.profanityFilter - Public Domain Books API
client.books - Public Holidays API
client.publicHolidays - QR Code Generator API
client.qrCodeGenerator - Quotes API
client.quotes - Random Image & Placeholder API
client.randomImage - Random User API
client.randomUser - Recipes API
client.recipes - Riddles API
client.riddles - River Conditions API
client.rivers - SSL Checker Api
client.sslChecker - Salary Benchmarks API
client.salaryBenchmarks - Sales Tax & VAT API
client.salesTaxVat - Sanctions Screening API
client.sanctions - Seaports API
client.seaports - Sentiment Analysis API
client.sentimentAnalysis - Space Launches API
client.spaceLaunches - Spell Check API
client.spellCheck - Stock Tickers API
client.stockTickers - Tariff Codes API
client.tariffCodes - Tech Stack API
client.techStack - Text Embeddings API
client.textEmbeddings - Thesaurus API
client.thesaurus - Tides API
client.tides - Timezone & World Time API
client.timezoneWorldTime - Trading Calendar API
client.tradingCalendar - Traffic Fatalities API
client.trafficFatalities - Translation API
client.translation - Travel Advisories API
client.travelAdvisories - Trending API
client.trending - Trivia API
client.trivia - URL Metadata API
client.urlMetadata - US Lawyers API
client.usLawyers - Unit Converter API
client.unitConverter - Universities API
client.universities - User Agent Parser API
client.userAgentParser - VAT Validation API
client.vat - VIN Decoder API
client.vinDecoder - Vehicle Recalls API
client.vehicleRecalls - Video Games API
client.videoGames - Watches API
client.watches - Weather API
client.weather - Wildfires API
client.wildfires - Zip & Postal Code API
client.zipPostalCode
Not using JavaScript?
Every API is plain REST with an X-Api-Key header, so any HTTP client works. Each API page has samples in Python, PHP and Go and an OpenAPI 3.1 document.