Examples
Every example uses the public, read-only v1 API. Use plain HTTP from any language, or a client library for typed helpers.
List a page#
curl -sS "https://gzw-data.dev/api/v1/weapons?page=1&per_page=5"REST uses per_page. The JavaScript SDK uses the equivalent camelCase option perPage.
Fetch one record by ID#
curl -sS https://gzw-data.dev/api/v1/weapons/ak-12Search and inspect metadata#
curl -sS "https://gzw-data.dev/api/v1/search?q=AK&dataset=weapons&limit=5"
curl -sS "https://gzw-data.dev/api/v1/metadata?full=true"Use the SDK for typed helpers#
Install @zoniboy/gzw-data-client in Node.js 22+ or a modern browser app. It has no runtime dependencies and needs no API key. Details are in the SDK guide.
npm install @zoniboy/gzw-data-clientimport { GzwDataClient } from "@zoniboy/gzw-data-client";
const gzw = new GzwDataClient();
const page = await gzw.dataset("weapons").list({ page: 1, perPage: 5 });
console.log(page.data);
console.log(page.total);Build a live dataset picker#
Read names from the API registry at runtime. New datasets and fields work without updating the npm package.
const registry = await gzw.metadata();
const datasetNames = registry.datasets.map(({ name }) => name);
const selectedName: string = datasetNames[0] ?? "weapons";
const resource = gzw.dataset(selectedName);
const info = await resource.info();
const firstPage = await resource.list({ page: 1, perPage: 20 });Fetch from a browser app#
For a small prototype, call the REST endpoint with standard fetch. Check response.ok before treating the body as a success.
const params = new URLSearchParams({ page: "1", per_page: "5" });
const response = await fetch(
`https://gzw-data.dev/api/v1/weapons?${params}`,
{ headers: { Accept: "application/json" } },
);
if (!response.ok) throw new Error(`GZW Data API: HTTP ${response.status}`);
const payload = await response.json();
console.log(payload.data);Python#
The client handles pagination, retries and errors. See the Python guide.
pip install gzw-data
from gzw_data import GzwDataClient
client = GzwDataClient()
for gun in client.iterate("weapons", search="AK"):
print(gun["name"], gun["caliber"])Prefer plain HTTP? Pass query values separately instead of building an encoded URL by hand.
import requests
response = requests.get(
"https://gzw-data.dev/api/v1/search",
params={"q": "AK", "dataset": "weapons", "limit": 5},
timeout=10,
)
response.raise_for_status()
print(response.json()["data"])