REST requests with cURL
Use the versioned endpoint directly. The API discovers published datasets automatically; check the live route catalog for the current list.
List a page
curl -sS "https://gzw-data.dev/api/v1/weapons?page=1&per_page=5"REST uses per_page; the 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"Search and metadata parameters are documented in the query guide and metadata reference.
Use the SDK for typed helpers
Install @zoniboy/gzw-data-client in Node.js 18+ or a modern browser app. It has no runtime dependencies and needs no API key.
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);Runnable, type-checked quick-start source ↗ · Full SDK guide →
Build a live dataset picker
Read names from the API registry at runtime. New datasets and fields are available without updating the npm package; compile-time autocomplete remains a local snapshot.
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 });Unknown record fields use the generic GzwRecord fallback. See the autocomplete explanation and runnable discovery example ↗.
Fetch from a browser app
For a small prototype or a non-JavaScript SDK, the REST endpoint can be called with standard fetch. Check response.ok before treating the body as a successful result.
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);Use query parameters safely
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"])For exact parameter names, response shapes, errors, caching and rate limits, use the API reference.
