Official Python client for the PUID API — the Provably Unique IDentifier service.
Project description
puid-client
The official Python client for the PUID API — the Provably Unique IDentifier service. Every id is guaranteed distinct by construction, not by the dice roll a random UUID makes.
- Zero dependencies — built on the standard library (
urllib). - Python 3.9+.
Install
pip install puid-client
Quickstart
from puid import Puid
puid = Puid(api_key="puid_live_...") # mint one in the dashboard
one = puid.id()
ids = puid.ids(5) # 1–10 per request
ordinal = puid.ordinal(one) # int — the counter it encodes
quota = puid.quota() # {"plan", "used", "limit", "remaining"}
Mint an API key in the dashboard after signing in.
Generating ids on someone else's behalf (OAuth2)
If you've registered an OAuth2 client, exchange its credentials for a bearer token and generate ids for the account that granted you access — without ever touching their API key:
from puid import Puid
puid = Puid.from_client_credentials(
client_id="...",
client_secret="...",
scope="puid:generate", # default
)
puid.ids(3)
Already have a bearer token (e.g. from the authorization-code flow)? Pass it directly:
puid = Puid(access_token="puid_at_...")
API
Puid(api_key=None, access_token=None, endpoint="https://puid.dev/api", opener=None)
Provide exactly one of api_key or access_token.
endpoint— API endpoint. Defaults tohttps://puid.dev/api. Point it at a local dev server for tests, or at your own domain for a self-hosted (Enterprise) PUID.opener— an optionalurllibopener (advanced / testing).
Methods
ids(count=1) -> list[str]— generate 1–10 ids.id() -> str— generate a single id.ordinal(puid) -> int— decode an id back to its counter value.quota() -> dict— check today's quota; does not spend an id.Puid.from_client_credentials(client_id, client_secret, scope="puid:generate", endpoint=...) -> Puid
Self-hosted / Enterprise
puid = Puid(api_key="...", endpoint="https://ids.yourcompany.com/api")
Errors
Every non-2xx response (and client-side validation) raises PuidError:
from puid import Puid, PuidError
try:
puid.ids(3)
except PuidError as err:
err.status # 401 | 402 | 429 | … (None for client-side/network errors)
err.code # "rate_limited" | "quota_exceeded" | "unauthorized" | "network_error" | …
Common server codes: unauthorized (401), quota_exceeded (402),
rate_limited (429). PUID is rate limited to one request per second — that 429
is by design.
License
AGPL-3.0-only. See the repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file puid_client-1.0.0.tar.gz.
File metadata
- Download URL: puid_client-1.0.0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc6fef2e31f436eb7c29daf0d61f194dbabbde0d144bf3330e8b141a5087f3d9
|
|
| MD5 |
4ddac93c21ac4f5586300e8f297dd4ab
|
|
| BLAKE2b-256 |
2cd5b3deb0a146fae287948f0c4d07989b869aef29bdd167324088486f0b2702
|
File details
Details for the file puid_client-1.0.0-py3-none-any.whl.
File metadata
- Download URL: puid_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ee40716587c5768f35ca7eed12acc550dad74d87a5da61e9c05860675137e30
|
|
| MD5 |
86eaf9fed17a9d5386e55fa9a4f37e04
|
|
| BLAKE2b-256 |
0a2b9595e092297377e0db765308715609e68a14b090b44b9055d0e7f1bff7ef
|