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.imagesclient.custom_domainclient.cors_originsclient.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 viaPage(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:
- acquire the raw OpenAPI document
- shape it with
@imgwire/codegen-corefortarget: "python" - generate a disposable base client with OpenAPI Generator
- apply deterministic post-processing
- 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.jsonby settingOPENAPI_RELEASE=true
make install
make generate
make verify-generated
This writes:
openapi/raw.openapi.jsonopenapi/sdk.openapi.jsongenerated/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
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 imgwire-0.1.2.tar.gz.
File metadata
- Download URL: imgwire-0.1.2.tar.gz
- Upload date:
- Size: 49.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10dedd26ee960baae736a0d9edde1b9ada7314e8939722843ed618592bf228d8
|
|
| MD5 |
a33c4833c8ae8080a694fa168a843de3
|
|
| BLAKE2b-256 |
2e925d2ea33ff38eb70a1316fad23fa644f0c059fc2ada0a312c72d57af7f2bc
|
Provenance
The following attestation bundles were made for imgwire-0.1.2.tar.gz:
Publisher:
release.yml on Blackhawk-Software/imgwire-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imgwire-0.1.2.tar.gz -
Subject digest:
10dedd26ee960baae736a0d9edde1b9ada7314e8939722843ed618592bf228d8 - Sigstore transparency entry: 1311111029
- Sigstore integration time:
-
Permalink:
Blackhawk-Software/imgwire-python@aa5765325e716989d0b82c15ad8d1812818f51e9 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Blackhawk-Software
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aa5765325e716989d0b82c15ad8d1812818f51e9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file imgwire-0.1.2-py3-none-any.whl.
File metadata
- Download URL: imgwire-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb1d3a9413ab2cd8039f05811296f4511131cd0ff54f8fb3e2a349aaacbfcee9
|
|
| MD5 |
8e08ac1c8241e62c37aa9e49ce55cae5
|
|
| BLAKE2b-256 |
ff07bfcde7924575fac9ebc17cb2e26e59fedd6f4fbe80a4161f0fd5638f25a3
|
Provenance
The following attestation bundles were made for imgwire-0.1.2-py3-none-any.whl:
Publisher:
release.yml on Blackhawk-Software/imgwire-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imgwire-0.1.2-py3-none-any.whl -
Subject digest:
bb1d3a9413ab2cd8039f05811296f4511131cd0ff54f8fb3e2a349aaacbfcee9 - Sigstore transparency entry: 1311111099
- Sigstore integration time:
-
Permalink:
Blackhawk-Software/imgwire-python@aa5765325e716989d0b82c15ad8d1812818f51e9 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Blackhawk-Software
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aa5765325e716989d0b82c15ad8d1812818f51e9 -
Trigger Event:
release
-
Statement type: