Skip to main content

Python SDK for the Thingiverse API

Project description

Thingiverse Python SDK

A Python SDK for the Thingiverse API.

Installation

pip install thingiverse-client

Or from source:

pip install .
# or for development
pip install -e ".[dev]"

Quick start

from thingiverse import AuthenticatedClient, BASE_URL_PRODUCTION
from thingiverse.api.thing import get_things_thing_id

client = AuthenticatedClient(
    base_url=BASE_URL_PRODUCTION,
    token="YOUR_ACCESS_TOKEN",
)

response = get_things_thing_id.sync_detailed(thing_id=123, client=client)

Using the staging API

Use BASE_URL_STAGING to target the staging environment:

from thingiverse import AuthenticatedClient, BASE_URL_STAGING

client = AuthenticatedClient(base_url=BASE_URL_STAGING, token="...")

Authentication

The Thingiverse API uses Bearer token authentication. You can obtain a token from Thingiverse app settings or from browser network requests to api.thingiverse.com.

File uploads

File uploads (designs and images) use a specific flow. See the Thingiverse upload guide for details. The SDK exposes the generated uploadFile and FinalizeFiles endpoints; you may use a thin helper for the full upload flow (see docs).

Development setup

  1. Clone the repository and create a virtual environment:

    python3 -m venv .venv
    source .venv/bin/activate  # or .venv\Scripts\activate on Windows
    pip install -e ".[dev]"
    
  2. Install pre-commit hooks (including commit message format):

    pre-commit install
    pre-commit install --hook-type commit-msg
    
  3. Commit messages must follow Conventional Commits (e.g. feat: add X, fix: Y). The commit-msg hook enforces this.

Running tests

Use the virtual environment’s Python so that dependencies (e.g. httpx) are found. Either activate the venv first (source .venv/bin/activate then pytest) or run:

.venv/bin/python -m pytest tests/unit tests/integration -v
  • Unit tests (default, no API calls):

    pytest tests/unit -v
    
  • Integration tests (read-only, real API). Set THINGIVERSE_TOKEN; optionally set THINGIVERSE_BASE_URL for staging:

    THINGIVERSE_TOKEN=... pytest tests/unit tests/integration -v
    
  • Destructive tests (optional; modify data). Not run in CI. Use a dedicated test account and prefer staging:

    THINGIVERSE_BASE_URL=https://api-staging.thingiverse.com THINGIVERSE_TOKEN=... pytest -m destructive
    

Updating the API spec

To refresh the SDK from the upstream Thingiverse OpenAPI spec:

  1. Run the fetch script (downloads the full spec; the docs URL may be behind Cloudflare—see script docstring):

    python scripts/fetch_openapi_spec.py
    
  2. Bundle, run the upstream-spec fix script, and regenerate the client (see OpenAPI upstream notes):

    ./scripts/generate_client.sh
    
  3. Commit changes and open a PR; merging can trigger a new release via release-please.

Documentation

Documentation is built with Zensical (reads mkdocs.yml) and published to GitHub Pages. Build locally:

pip install -e ".[dev]"
zensical serve

Publishing to PyPI

Publishing is automated via the Publish to PyPI workflow. When a GitHub release is published (e.g. by merging a release-please release PR), the workflow builds the package and uploads it to PyPI.

One-time setup:

  1. Create a PyPI account and register the project name thingiverse-client if needed.
  2. Configure trusted publishing for this repository:
    • PyPI: Add a new trusted publisher for the project.
    • Set Owner and Repository name to this repo, Workflow name to publish-pypi.yml.
    • No secrets or API tokens are required; PyPI uses OIDC to verify the workflow.

After that, each new release will be published to PyPI automatically. Optionally, add a GitHub Actions environment (e.g. pypi) and set environment: pypi in the workflow for approval or protection rules.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thingiverse_client-1.1.0.tar.gz (170.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thingiverse_client-1.1.0-py3-none-any.whl (988.3 kB view details)

Uploaded Python 3

File details

Details for the file thingiverse_client-1.1.0.tar.gz.

File metadata

  • Download URL: thingiverse_client-1.1.0.tar.gz
  • Upload date:
  • Size: 170.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for thingiverse_client-1.1.0.tar.gz
Algorithm Hash digest
SHA256 899c36ac7c204317837e02f4ba918bcf3be5a6a797d0ec9862f004ad33c38636
MD5 3b87bb5b8ad533f7c454b08a71358ec6
BLAKE2b-256 746072d1d45bc95e41e28005e137c3f4fbef5c21306f47b480d9ed077dc3cefd

See more details on using hashes here.

Provenance

The following attestation bundles were made for thingiverse_client-1.1.0.tar.gz:

Publisher: publish-pypi.yml on nomike/thingiverse-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file thingiverse_client-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for thingiverse_client-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e8ff9d6b673bbd23f36b5e2098bc3f5edd4531ce7b5ce477d6eb427a958a45e
MD5 a99d62bec94c7a8e13253c2bc8ed5b21
BLAKE2b-256 bc8548257e343ac122ee917ce2e9c21476bc6e70c5929a9301ed05231a7c20c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for thingiverse_client-1.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on nomike/thingiverse-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page