Skip to main content

yourimageshare

Official Python SDK for the YourImageShare upload API. One dependency (requests), Python 3.8+.

Install

pip install yourimageshare

Usage

from yourimageshare import YourImageShare

client = YourImageShare(api_key="YOUR_API_KEY")

# Upload a file by path
result = client.upload("photo.jpg")
print(result.direct)  # https://yourimageshare.com/ib/aB3xY9qRz1

# Upload with auto-delete after 1 hour
client.upload("photo.jpg", expires_in=3600)

# Upload from an already-open file object
with open("photo.jpg", "rb") as f:
    client.upload(f, filename="photo.jpg")

# List your uploads (paginated, 50 per page)
listing = client.list()
for item in listing.data:
    print(item.id, item.direct)

# Delete an upload
client.delete(result.id)

YourImageShare also works as a context manager, which closes the underlying HTTP session on exit:

with YourImageShare(api_key="YOUR_API_KEY") as client:
    client.upload("photo.jpg")

Error handling

Failed requests raise YourImageShareError (.status is the HTTP status code, .message is the server's error text):

from yourimageshare import YourImageShare, YourImageShareError

client = YourImageShare(api_key="YOUR_API_KEY")
try:
    client.upload("photo.jpg")
except YourImageShareError as err:
    print(err.status, err.message)

API

YourImageShare(api_key, base_url=DEFAULT_BASE_URL, timeout=30.0)

base_url defaults to https://yourimageshare.com/api - override only for testing against a different environment.

client.upload(file, *, filename=None, expires_in=None)

file is a path (str/os.PathLike) or an open binary file object. expires_in is seconds, 60 to 2,592,000 (30 days) - omit for a permanent upload. Returns an UploadResult(id, type, path, src, direct, expires_at).

client.list(page=1)

Returns a ListResult(data, meta) where data is a list of ListedUpload(id, type, title, path, src, direct, expires_at, created_at) and meta is ListMeta(current_page, last_page, total).

client.delete(upload_id)

Raises YourImageShareError on a 404/401; returns None on success.

Rate limits

20 requests/minute and 500/day per key by default (2,000/day per IP as a backstop). Not currently surfaced on the return values from this SDK - read the X-RateLimit-Limit/X-RateLimit-Remaining response headers yourself via client._session if you need them, or open an issue to request them on the result objects.

License

Not yet decided by the maintainer - do not treat this as open source until a LICENSE file is added.

Support

yourimageshare.com/contact

Download files

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

Source Distribution

yourimageshare-1.0.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

yourimageshare-1.0.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file yourimageshare-1.0.1.tar.gz.

File metadata

  • Download URL: yourimageshare-1.0.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for yourimageshare-1.0.1.tar.gz
Algorithm Hash digest
SHA256 918f034cc6886db0d4375def8393fcd84d0093b3266bb88cf6941cab2083dbb8
MD5 037f136597a26a5a8c1b47e8ff14acef
BLAKE2b-256 a6879d50fd6c4927d1ec7e090d03a939bad8e16a5915cf9fc1c30e7baea38759

See more details on using hashes here.

File details

Details for the file yourimageshare-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: yourimageshare-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for yourimageshare-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ea3d658292a2735ca7cc458bd9e575455749f6d443aa35e81ba7066873fcd00b
MD5 9fe5ad96963a673bdeedf6dcac8387a4
BLAKE2b-256 df45be85bc5a5ff980431b9c45a7a8cab2d557e439676622c77d7a7728f60af4

See more details on using hashes here.

Supported by

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