{"id":39226673,"url":"https://github.com/imagekit-developer/imagekit-python","last_synced_at":"2026-04-06T09:04:27.778Z","repository":{"id":44450630,"uuid":"233840618","full_name":"imagekit-developer/imagekit-python","owner":"imagekit-developer","description":"ImageKit.io Python SDK","archived":false,"fork":false,"pushed_at":"2026-04-06T07:37:41.000Z","size":1610,"stargazers_count":56,"open_issues_count":0,"forks_count":17,"subscribers_count":7,"default_branch":"master","last_synced_at":"2026-04-06T08:43:31.544Z","etag":null,"topics":["hacktoberfest","image-manipulation","image-optimization"],"latest_commit_sha":null,"homepage":"https://imagekit.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imagekit-developer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-01-14T12:51:22.000Z","updated_at":"2026-04-06T07:37:30.000Z","dependencies_parsed_at":"2026-01-05T19:08:32.483Z","dependency_job_id":null,"html_url":"https://github.com/imagekit-developer/imagekit-python","commit_stats":{"total_commits":174,"total_committers":15,"mean_commits":11.6,"dds":0.632183908045977,"last_synced_commit":"154806bd7f376a24940a49f3c2f192dc13854823"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/imagekit-developer/imagekit-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imagekit-developer","download_url":"https://codeload.github.com/imagekit-developer/imagekit-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-python/sbom","scorecard":{"id":484774,"data":{"date":"2025-08-11","repo":{"name":"github.com/imagekit-developer/imagekit-python","commit":"cc951b2f895160ee028e75e2106c0246044265e7"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":8,"reason":"Found 4/5 approved changesets -- score normalized to 8","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/imagekit-developer/imagekit-python/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/imagekit-developer/imagekit-python/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/imagekit-developer/imagekit-python/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/imagekit-developer/imagekit-python/test.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:21","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:22","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:27","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:19","Warn: downloadThenRun not pinned by hash: .github/workflows/test.yml:23","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 pipCommand dependencies pinned","Info:   0 out of   1 downloadThenRun dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"14 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-9hjg-9r4m-mvj7","Warn: Project is vulnerable to: GHSA-9wx4-h78v-vm56","Warn: Project is vulnerable to: PYSEC-2023-74 / GHSA-j8r2-6x86-q33q","Warn: Project is vulnerable to: GHSA-34jh-p97f-mpxf","Warn: Project is vulnerable to: PYSEC-2023-212 / GHSA-g4mx-q9vg-27p4","Warn: Project is vulnerable to: PYSEC-2023-207 / GHSA-gwvm-45gx-3cf8","Warn: Project is vulnerable to: PYSEC-2019-133 / GHSA-mh33-7rrq-662w","Warn: Project is vulnerable to: GHSA-pq67-6m6q-mj2v","Warn: Project is vulnerable to: PYSEC-2019-132 / GHSA-r64q-w8jr-g9qp","Warn: Project is vulnerable to: PYSEC-2023-192 / GHSA-v845-jxx5-vc9f","Warn: Project is vulnerable to: PYSEC-2020-148 / GHSA-wqvq-5m8c-6g24","Warn: Project is vulnerable to: PYSEC-2018-32 / GHSA-www2-v7xj-xrc6","Warn: Project is vulnerable to: PYSEC-2021-108","Warn: Project is vulnerable to: PYSEC-2021-59"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T17:30:29.042Z","repository_id":44450630,"created_at":"2025-08-19T17:30:29.042Z","updated_at":"2025-08-19T17:30:29.042Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31466228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T08:36:52.050Z","status":"ssl_error","status_checked_at":"2026-04-06T08:36:51.267Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","image-manipulation","image-optimization"],"created_at":"2026-01-17T23:36:20.251Z","updated_at":"2026-04-06T09:04:27.759Z","avatar_url":"https://github.com/imagekit-developer.png","language":"Python","readme":"# ImageKit.io Python SDK\n\n\u003c!-- prettier-ignore --\u003e\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe ImageKit Python SDK provides convenient access to the ImageKit REST API from any Python 3.9+ application. It offers powerful tools for URL generation and transformation, signed URLs for secure content delivery, webhook verification, file uploads, and more. The library includes type definitions for all request params and response fields, and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Requirements](#requirements)\n- [Usage](#usage)\n  - [Using types](#using-types)\n  - [Nested params](#nested-params)\n  - [Async usage](#async-usage)\n- [URL generation](#url-generation)\n  - [Basic URL generation](#basic-url-generation)\n  - [URL generation with transformations](#url-generation-with-transformations)\n  - [URL generation with image overlay](#url-generation-with-image-overlay)\n  - [URL generation with text overlay](#url-generation-with-text-overlay)\n  - [URL generation with multiple overlays](#url-generation-with-multiple-overlays)\n  - [Signed URLs for secure delivery](#signed-urls-for-secure-delivery)\n  - [Using Raw transformations for undocumented features](#using-raw-transformations-for-undocumented-features)\n- [Authentication parameters for client-side uploads](#authentication-parameters-for-client-side-uploads)\n- [Webhook verification](#webhook-verification)\n- [Advanced Usage](#advanced-usage)\n  - [File uploads](#file-uploads)\n  - [Handling errors](#handling-errors)\n  - [Retries](#retries)\n  - [Timeouts](#timeouts)\n  - [Logging](#logging)\n  - [Accessing raw response data](#accessing-raw-response-data-eg-headers)\n  - [Making custom/undocumented requests](#making-customundocumented-requests)\n  - [Configuring the HTTP client](#configuring-the-http-client)\n  - [Managing HTTP resources](#managing-http-resources)\n- [Versioning](#versioning)\n- [Contributing](#contributing)\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n    private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"),  # This is the default and can be omitted\n)\n\n# Upload a file\nwith open(\"/path/to/your/image.jpg\", \"rb\") as f:\n    file_data = f.read()\n\nresponse = client.files.upload(\n    file=file_data,\n    file_name=\"uploaded-image.jpg\",\n)\nprint(response.file_id)\nprint(response.url)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY=\"My Private Key\"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n\n### Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n### Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\n# Read file into memory and upload\nwith open(\"/path/to/file.jpg\", \"rb\") as f:\n    file_data = f.read()\n\nresponse = client.files.upload(\n    file=file_data,\n    file_name=\"fileName\",\n    transformation={\n        \"post\": [\n            {\n                \"type\": \"thumbnail\",\n                \"value\": \"w-150,h-150\",\n            },\n            {\n                \"protocol\": \"dash\",\n                \"type\": \"abs\",\n                \"value\": \"sr-240_360_480_720_1080\",\n            },\n        ]\n    },\n)\nprint(response.file_id)\n```\n\n### Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n    private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"),  # This is the default and can be omitted\n)\n\n\nasync def main() -\u003e None:\n    # Read file into memory and upload\n    with open(\"/path/to/your/image.jpg\", \"rb\") as f:\n        file_data = f.read()\n    \n    response = await client.files.upload(\n        file=file_data,\n        file_name=\"file-name.jpg\",\n    )\n    print(response.file_id)\n    print(response.url)\n\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n#### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\n\nasync def main() -\u003e None:\n    async with AsyncImageKit(\n        private_key=os.environ.get(\n            \"IMAGEKIT_PRIVATE_KEY\"\n        ),  # This is the default and can be omitted\n        http_client=DefaultAioHttpClient(),\n    ) as client:\n        # Read file into memory and upload\n        with open(\"/path/to/your/image.jpg\", \"rb\") as f:\n            file_data = f.read()\n        \n        response = await client.files.upload(\n            file=file_data,\n            file_name=\"file-name.jpg\",\n        )\n        print(response.file_id)\n        print(response.url)\n\n\nasyncio.run(main())\n```\n\n## URL generation\n\nThe ImageKit SDK provides a powerful `helper.build_url()` method for generating optimized image and video URLs with transformations. Here are examples ranging from simple URLs to complex transformations with overlays and signed URLs.\n\n### Basic URL generation\n\nGenerate a simple URL without any transformations:\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n    private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"),\n)\n\n# Basic URL without transformations\nurl = client.helper.build_url(\n    url_endpoint=\"https://ik.imagekit.io/your_imagekit_id\",\n    src=\"/path/to/image.jpg\",\n)\nprint(url)\n# Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg\n```\n\n### URL generation with transformations\n\nApply common transformations like resizing, cropping, and format conversion:\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n    private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"),\n)\n\n# URL with basic transformations\nurl = client.helper.build_url(\n    url_endpoint=\"https://ik.imagekit.io/your_imagekit_id\",\n    src=\"/path/to/image.jpg\",\n    transformation=[\n        {\n            \"width\": 400,\n            \"height\": 300,\n            \"crop\": \"maintain_ratio\",\n            \"quality\": 80,\n            \"format\": \"webp\",\n        }\n    ],\n)\nprint(url)\n# Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg?tr=w-400,h-300,c-maintain_ratio,q-80,f-webp\n```\n\n### URL generation with image overlay\n\nAdd image overlays to your base image:\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n    private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"),\n)\n\n# URL with image overlay\nurl = client.helper.build_url(\n    url_endpoint=\"https://ik.imagekit.io/your_imagekit_id\",\n    src=\"/path/to/base-image.jpg\",\n    transformation=[\n        {\n            \"width\": 500,\n            \"height\": 400,\n            \"overlay\": {\n                \"type\": \"image\",\n                \"input\": \"/path/to/overlay-logo.png\",\n                \"position\": {\n                    \"x\": 10,\n                    \"y\": 10,\n                },\n                \"transformation\": [\n                    {\n                        \"width\": 100,\n                        \"height\": 50,\n                    }\n                ],\n            },\n        }\n    ],\n)\nprint(url)\n# Result: URL with image overlay positioned at x:10, y:10\n```\n\n### URL generation with text overlay\n\nAdd customized text overlays:\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n    private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"),\n)\n\n# URL with text overlay\nurl = client.helper.build_url(\n    url_endpoint=\"https://ik.imagekit.io/your_imagekit_id\",\n    src=\"/path/to/base-image.jpg\",\n    transformation=[\n        {\n            \"width\": 600,\n            \"height\": 400,\n            \"overlay\": {\n                \"type\": \"text\",\n                \"text\": \"Sample Text Overlay\",\n                \"position\": {\n                    \"x\": 50,\n                    \"y\": 50,\n                    \"focus\": \"center\",\n                },\n                \"transformation\": [\n                    {\n                        \"font_size\": 40,\n                        \"font_family\": \"Arial\",\n                        \"font_color\": \"FFFFFF\",\n                        \"typography\": \"b\",  # bold\n                    }\n                ],\n            },\n        }\n    ],\n)\nprint(url)\n# Result: URL with bold white Arial text overlay at center position\n```\n\n### URL generation with multiple overlays\n\nCombine multiple overlays for complex compositions:\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n    private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"),\n)\n\n# URL with multiple overlays (text + image)\nurl = client.helper.build_url(\n    url_endpoint=\"https://ik.imagekit.io/your_imagekit_id\",\n    src=\"/path/to/base-image.jpg\",\n    transformation=[\n        {\n            \"width\": 800,\n            \"height\": 600,\n            \"overlay\": {\n                \"type\": \"text\",\n                \"text\": \"Header Text\",\n                \"position\": {\n                    \"x\": 20,\n                    \"y\": 20,\n                },\n                \"transformation\": [\n                    {\n                        \"font_size\": 30,\n                        \"font_color\": \"000000\",\n                    }\n                ],\n            },\n        },\n        {\n            \"overlay\": {\n                \"type\": \"image\",\n                \"input\": \"/watermark.png\",\n                \"position\": {\n                    \"focus\": \"bottom_right\",\n                },\n                \"transformation\": [\n                    {\n                        \"width\": 100,\n                        \"opacity\": 70,\n                    }\n                ],\n            },\n        },\n    ],\n)\nprint(url)\n# Result: URL with text overlay at top-left and semi-transparent watermark at bottom-right\n```\n\n### Signed URLs for secure delivery\n\nGenerate signed URLs that expire after a specified time for secure content delivery:\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n    private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"),\n)\n\n# Generate a signed URL that expires in 1 hour (3600 seconds)\nurl = client.helper.build_url(\n    url_endpoint=\"https://ik.imagekit.io/your_imagekit_id\",\n    src=\"/private/secure-image.jpg\",\n    transformation=[\n        {\n            \"width\": 400,\n            \"height\": 300,\n            \"quality\": 90,\n        }\n    ],\n    signed=True,\n    expires_in=3600,  # URL expires in 1 hour\n)\nprint(url)\n# Result: URL with signature parameters (?ik-t=timestamp\u0026ik-s=signature)\n\n# Generate a signed URL that doesn't expire\npermanent_signed_url = client.helper.build_url(\n    url_endpoint=\"https://ik.imagekit.io/your_imagekit_id\",\n    src=\"/private/secure-image.jpg\",\n    signed=True,\n    # No expires_in means the URL won't expire\n)\nprint(permanent_signed_url)\n# Result: URL with signature parameter (?ik-s=signature)\n```\n\n### Using Raw transformations for undocumented features\n\nImageKit frequently adds new transformation parameters that might not yet be documented in the SDK. You can use the `raw` parameter to access these features or create custom transformation strings:\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n    private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"),\n)\n\n# Using Raw transformation for undocumented or new parameters\nurl = client.helper.build_url(\n    url_endpoint=\"https://ik.imagekit.io/your_imagekit_id\",\n    src=\"/path/to/image.jpg\",\n    transformation=[\n        {\n            # Combine documented transformations with raw parameters\n            \"width\": 400,\n            \"height\": 300,\n        },\n        {\n            # Use raw for undocumented transformations or complex parameters\n            \"raw\": \"something-new\",\n        },\n    ],\n)\nprint(url)\n# Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg?tr=w-400,h-300:something-new\n```\n\n## Authentication parameters for client-side uploads\n\nGenerate authentication parameters for secure client-side file uploads:\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n    private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"),\n)\n\n# Generate authentication parameters for client-side uploads\nauth_params = client.helper.get_authentication_parameters()\nprint(auth_params)\n# Result: {'expire': \u003ctimestamp\u003e, 'signature': '\u003chmac-signature\u003e', 'token': '\u003cuuid-token\u003e'}\n\n# Generate with custom token and expiry\ncustom_auth_params = client.helper.get_authentication_parameters(\n    token=\"my-custom-token\",\n    expire=1800\n)\nprint(custom_auth_params)\n# Result: {'expire': 1800, 'signature': '\u003chmac-signature\u003e', 'token': 'my-custom-token'}\n```\n\nThese authentication parameters can be used in client-side upload forms to securely upload files without exposing your private API key.\n\n## Webhook verification\n\nThe ImageKit SDK provides utilities to verify webhook signatures for secure event handling. This ensures that webhook requests are actually coming from ImageKit and haven't been tampered with.\n\nFor detailed information about webhook setup, signature verification, and handling different webhook events, refer to the [ImageKit webhook documentation](https://imagekit.io/docs/webhooks#verify-webhook-signature).\n\n## Advanced Usage\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, an `IO[bytes]` file object, or a tuple of `(filename, contents, media type)`.\n\nHere are common file upload patterns:\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\nimport io\n\nclient = ImageKit()\n\n# Method 1: Upload from bytes\n# Read file into memory first, then upload\nwith open(\"/path/to/your/image.jpg\", \"rb\") as f:\n    file_data = f.read()\n\nresponse = client.files.upload(\n    file=file_data,\n    file_name=\"uploaded-image.jpg\",\n)\n\n# Method 2: Upload from file stream (for large files)\n# Pass file object directly - SDK reads it\nwith open(\"/path/to/your/image.jpg\", \"rb\") as file_stream:\n    response = client.files.upload(\n        file=file_stream,\n        file_name=\"uploaded-image.jpg\",\n    )\n\n# Method 3: Upload using Path object (SDK reads automatically)\nresponse = client.files.upload(\n    file=Path(\"/path/to/file.jpg\"),\n    file_name=\"fileName.jpg\",\n)\n\n# Method 4: Upload from BytesIO (for programmatically generated content)\ncontent = b\"your binary data\"\nbytes_io = io.BytesIO(content)\nresponse = client.files.upload(\n    file=bytes_io,\n    file_name=\"binary-upload.jpg\",\n)\n\n# Method 5: Upload with custom content type using tuple format\nimage_data = b\"your binary data\"\nresponse = client.files.upload(\n    file=(\"custom.jpg\", image_data, \"image/jpeg\"),\n    file_name=\"custom-upload.jpg\",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n**Note:** URL strings (e.g., `\"https://example.com/image.jpg\"`) are not supported by the Python SDK. To upload from a URL, download the content first:\n\n```python\nimport urllib.request\n\n# Download from URL and upload to ImageKit\nurl = \"https://example.com/image.jpg\"\nwith urllib.request.urlopen(url) as response:\n    url_content = response.read()\n\n# Upload the downloaded content\nupload_response = client.files.upload(\n    file=url_content,\n    file_name=\"downloaded-image.jpg\",\n)\n```\n\n### Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n    # Read file into memory and upload\n    with open(\"/path/to/your/image.jpg\", \"rb\") as f:\n        file_data = f.read()\n    \n    response = client.files.upload(\n        file=file_data,\n        file_name=\"file-name.jpg\",\n    )\nexcept imagekitio.APIConnectionError as e:\n    print(\"The server could not be reached\")\n    print(e.__cause__)  # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n    print(\"A 429 status code was received; we should back off a bit.\")\nexcept imagekitio.APIStatusError as e:\n    print(\"Another non-200-range status code was received\")\n    print(e.status_code)\n    print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type                 |\n| ----------- | -------------------------- |\n| 400         | `BadRequestError`          |\n| 401         | `AuthenticationError`      |\n| 403         | `PermissionDeniedError`    |\n| 404         | `NotFoundError`            |\n| 422         | `UnprocessableEntityError` |\n| 429         | `RateLimitError`           |\n| \u003e=500       | `InternalServerError`      |\n| N/A         | `APIConnectionError`       |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and \u003e=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n    # default is 2\n    max_retries=0,\n)\n\n# Or, configure per-request:\nwith open(\"/path/to/your/image.jpg\", \"rb\") as f:\n    file_data = f.read()\n\nclient.with_options(max_retries=5).files.upload(\n    file=file_data,\n    file_name=\"file-name.jpg\",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n    # 20 seconds (default is 1 minute)\n    timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n    timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nwith open(\"/path/to/your/image.jpg\", \"rb\") as f:\n    file_data = f.read()\n\nclient.with_options(timeout=5.0).files.upload(\n    file=file_data,\n    file_name=\"file-name.jpg\",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n  if 'my_field' not in response.model_fields_set:\n    print('Got json like {}, without a \"my_field\" key present at all.')\n  else:\n    print('Got json like {\"my_field\": null}.')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe \"raw\" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\n# Read file into memory and upload\nwith open(\"/path/to/your/image.jpg\", \"rb\") as f:\n    file_data = f.read()\n\nresponse = client.files.with_raw_response.upload(\n    file=file_data,\n    file_name=\"file-name.jpg\",\n)\nprint(response.headers.get('X-My-Header'))\n\nfile = response.parse()  # get the object that `files.upload()` would have returned\nprint(file.file_id)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\n# Read file into memory and upload\nwith open(\"/path/to/your/image.jpg\", \"rb\") as f:\n    file_data = f.read()\n\nwith client.files.with_streaming_response.upload(\n    file=file_data,\n    file_name=\"file-name.jpg\",\n) as response:\n    print(response.headers.get(\"X-My-Header\"))\n\n    for line in response.iter_lines():\n        print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n    \"/foo\",\n    cast_to=httpx.Response,\n    body={\"my_param\": True},\n)\n\nprint(response.headers.get(\"x-foo\"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n    # Or use the `IMAGE_KIT_BASE_URL` env var\n    base_url=\"http://my.test.server.example.com:8083\",\n    http_client=DefaultHttpxClient(\n        proxy=\"http://my.test.proxy.example.com\",\n        transport=httpx.HTTPTransport(local_address=\"0.0.0.0\"),\n    ),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n  # make requests here\n  ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimagekit-developer%2Fimagekit-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimagekit-developer%2Fimagekit-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimagekit-developer%2Fimagekit-python/lists"}