Official SDK

Python SDK

The official Python client: typed models, sync and async, automatic pagination and conditional requests. Published on PyPI and generated from the same contract the API serves.

Install

Requires Python 3.9+. Published on PyPI, currently 0.7.0.

pip install gunspec

Your first call

The client reads your key from the environment. Responses are typed, so the fields below complete in an editor.

from gunspec import GunSpec client = GunSpec(api_key=os.environ["GUNSPEC_API_KEY"]) firearm = client.firearms.get("glock-g17") print(firearm.name, firearm.barrel_length_mm)

Paging

Both clients walk pages for you and stop on a short page, which works on every plan.

for firearm in client.firearms.list_auto_paging(category="rifle"): print(firearm.name)

Why it matters: A hand-written loop that tests against the total reads exactly one page on Explorer, because that plan is not told the total.

Everything else

Retries, conditional requests, error handling and every resource method are in the SDK reference, which is generated from the client itself.

SDK reference · View on PyPI

Back to Assets