Skip to main content

Python server-side SDK for the imgwire API.

Project description

imgwire

imgwire is the server-side Python SDK for the imgwire API.

Use it in backend services, jobs, and server runtimes to authenticate with a Server API Key, upload files from Python paths, file objects, or bytes, manage server-side resources, and call the imgwire API without hand-writing request plumbing.

Installation

pip install imgwire

Quick Start

from imgwire import ImgwireClient

client = ImgwireClient(api_key="sk_...")

image = client.images.upload("hero.jpg")

print(image.id)
print(image.url(preset="thumbnail"))

Client Setup

Create a client with your server key:

from imgwire import ImgwireClient

client = ImgwireClient(api_key="sk_...")

Optional configuration:

client = ImgwireClient(
    api_key="sk_...",
    base_url="https://api.imgwire.dev",
    environment_id="env_123",
    timeout=10.0,
    max_retries=2,
    backoff_factor=0.25,
)

Resources

The current handwritten SDK surface exposes these grouped resources:

  • client.images
  • client.custom_domain
  • client.cors_origins
  • client.metrics

client.images

Image operations and upload workflows.

Returned image records expose image.url(...) so your backend can generate imgwire transformation URLs without reimplementing CDN path and query rules.

Supported methods:

  • list(page=None, limit=None)
  • list_pages(page=1, limit=None)
  • list_all(page=1, limit=None)
  • retrieve(image_id)
  • create(body, upload_token=None)
  • upload(file, file_name=None, mime_type=None, content_length=None, ...)
  • create_upload_token()
  • create_bulk_download_job(body)
  • retrieve_bulk_download_job(image_download_job_id)
  • bulk_delete(body)
  • delete(image_id)

List images:

page = client.images.list(limit=25, page=1)

print(page.data)
print(page.pagination.total_count)

Iterate page-by-page:

for page in client.images.list_pages(limit=100):
    print(page.pagination.page, len(page.data))

Iterate every image record:

for image in client.images.list_all(limit=100):
    print(image.id)
    print(image.url(preset="small"))

Retrieve an image by id:

image = client.images.retrieve("img_123")

transformed_url = image.url(
    width=300,
    height=300,
)

Create a standard upload intent directly:

upload = client.images.create(
    {
        "file_name": "hero.png",
        "mime_type": "image/png",
        "content_length": 1024,
    }
)

print(upload.upload_url)

Upload from a file path:

image = client.images.upload("hero.jpg")

Upload from a file object:

with open("hero.jpg", "rb") as handle:
    image = client.images.upload(handle, mime_type="image/jpeg")

print(
    image.url(
        width=1200,
        height=800,
        format="webp",
        quality=80,
    )
)

Upload from bytes:

image = client.images.upload(
    image_bytes,
    file_name="hero.png",
    mime_type="image/png",
)

Create an upload token:

upload_token = client.images.create_upload_token()

print(upload_token.token)

Create and inspect a bulk download job:

job = client.images.create_bulk_download_job(
    {
        "image_ids": ["img_123", "img_456"],
    }
)

refreshed = client.images.retrieve_bulk_download_job(job.id)

Delete multiple images:

client.images.bulk_delete(
    {
        "image_ids": ["img_123", "img_456"],
    }
)

Image URL Transformations

Image-returning endpoints return ImgwireImage records with a url(...) helper:

image = client.images.retrieve("img_123")

thumbnail_url = image.url(
    preset="thumbnail",
    width=300,
    height=300,
    format="webp",
    quality=80,
)

print(thumbnail_url)

The SDK validates and normalizes transformation values to match the CDN worker. Query params are emitted using canonical rule names and sorted deterministically.

Examples:

image.url(bg="#ffffff", w=150, h=150, rot=90)
image.url(strip_metadata=True, enlarge=False)
image.url(crop="300:300:ce", gravity="ce")

client.custom_domain

Custom domain management for your imgwire environment.

Supported methods:

  • create(body)
  • retrieve()
  • test_connection()
  • delete()

Example:

client.custom_domain.create(
    {
        "hostname": "images.example.com",
    }
)

custom_domain = client.custom_domain.retrieve()
verification = client.custom_domain.test_connection()

client.cors_origins

CORS origin management for server-controlled environments.

Supported methods:

  • list(page=None, limit=None)
  • list_pages(page=1, limit=None)
  • list_all(page=1, limit=None)
  • create(body)
  • retrieve(cors_origin_id)
  • update(cors_origin_id, body)
  • delete(cors_origin_id)

Example:

created = client.cors_origins.create(
    {
        "pattern": "app.example.com",
    }
)

origins = client.cors_origins.list(limit=50, page=1)

client.cors_origins.update(
    created.id,
    {
        "pattern": "dashboard.example.com",
    },
)

for origin in client.cors_origins.list_all(limit=50):
    print(origin.pattern)

client.metrics

Server-side metrics endpoints for dashboards, reporting, and internal tooling.

Supported methods:

  • get_datasets(date_start=None, date_end=None, interval=None, tz=None)
  • get_stats(date_start=None, date_end=None, interval=None, tz=None)

Example:

from datetime import datetime, timezone

datasets = client.metrics.get_datasets(
    date_start=datetime(2026, 4, 1, tzinfo=timezone.utc),
    date_end=datetime(2026, 4, 15, tzinfo=timezone.utc),
    interval="DAILY",
    tz="America/Chicago",
)

stats = client.metrics.get_stats(
    date_start=datetime(2026, 4, 1, tzinfo=timezone.utc),
    date_end=datetime(2026, 4, 15, tzinfo=timezone.utc),
    interval="DAILY",
    tz="America/Chicago",
)

Response Shape Notes

  • List endpoints exposed through handwritten wrappers return { data, pagination }-style objects via Page(data=..., pagination=...).
  • list_pages() yields paginated result objects across pages.
  • list_all() yields individual items across every page.
  • Image-returning methods return image records extended with url(...) for transformation URL generation.
  • Upload helpers return the created image record after the presigned upload completes.

Development

For local development from this repository:

make install-py
. .venv/bin/activate
python

Common local workflows:

make help
make format
make format-py
make release-set VERSION=0.2.0
make clean
make ci

Generation

This repository is generated from the imgwire API contract and then extended with handwritten Python SDK code.

The pipeline is:

  1. acquire the raw OpenAPI document
  2. shape it with @imgwire/codegen-core for target: "python"
  3. generate a disposable base client with OpenAPI Generator
  4. apply deterministic post-processing
  5. layer in handwritten SDK code from imgwire/

Set OPENAPI_SOURCE to override the spec source. By default:

  • local/dev uses http://localhost:8000/openapi.json
  • release-oriented generation can use https://api.imgwire.dev/openapi.json by setting OPENAPI_RELEASE=true
make install
make generate
make verify-generated

This writes:

  • openapi/raw.openapi.json
  • openapi/sdk.openapi.json
  • generated/
  • CODEGEN_VERSION

Generated code lives in generated/ and should not be edited by hand. Durable SDK code lives in imgwire/.

Versioning

The PyPI package version lives in pyproject.toml, and the repo tooling version in package.json is kept in sync with it.

Set a new version manually with:

make release-set VERSION=0.2.0

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

imgwire-0.1.0.tar.gz (49.2 kB view details)

Uploaded Source

Built Distribution

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

imgwire-0.1.0-py3-none-any.whl (89.5 kB view details)

Uploaded Python 3

File details

Details for the file imgwire-0.1.0.tar.gz.

File metadata

  • Download URL: imgwire-0.1.0.tar.gz
  • Upload date:
  • Size: 49.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for imgwire-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d7aa8339fd3631bbe1594786da837b9c4de6c823fb59e9671524f9f0a20da6b
MD5 36e7b96260a1f3c5d1f4a5ff2b600cf7
BLAKE2b-256 0db6d17f484252c9e9e9cdbeb292557075adc289d28e6ff32695547c453df818

See more details on using hashes here.

Provenance

The following attestation bundles were made for imgwire-0.1.0.tar.gz:

Publisher: release.yml on Blackhawk-Software/imgwire-python

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

File details

Details for the file imgwire-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: imgwire-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 89.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for imgwire-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8654ebb7dee8e7fe9513cc689d9831357f659cf7d9b6916939ada6f9e57d20c
MD5 1269b3716f1688ba6c7b6d62d5eca832
BLAKE2b-256 dbd679c617e3568a5933c5c9c561df24c1a35a1b536a5012fd77a5cff4f7e10a

See more details on using hashes here.

Provenance

The following attestation bundles were made for imgwire-0.1.0-py3-none-any.whl:

Publisher: release.yml on Blackhawk-Software/imgwire-python

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