Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to PyPI in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/unlayer/unlayer-python/actions/workflows/publish-pypi.yml
name: Publish PyPI
on:
workflow_dispatch:

release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Publish to PyPI
run: |
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.UNLAYER_PYPI_TOKEN || secrets.PYPI_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
if: github.repository == 'unlayer/unlayer-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v6

- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
PYPI_TOKEN: ${{ secrets.UNLAYER_PYPI_TOKEN || secrets.PYPI_TOKEN }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.1.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer%2Funlayer-e77bc881d5cb6c68be6f3d3861ed021b99f6cde45ee28d3511abe284d888262e.yml
openapi_spec_hash: 7e7fae1b919c5d337e8b22be2a24d3ed
config_hash: ea554d62bfbb5e8ea43ebf0a274dec31
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer%2Funlayer-48f00d1c04c23fb4d1cb7cf4af4f56b0c920d758c1f06e06e5373e5b15e9c27d.yml
openapi_spec_hash: 6ee2a94bb9840aceb4a6161c724ce46c
config_hash: 249869757b6eb98ae3d58f2a47ce21e2
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Changelog

## 0.1.0 (2026-02-24)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/unlayer/unlayer-python/compare/v0.0.1...v0.1.0)

### Features

* **api:** api update ([e247358](https://github.com/unlayer/unlayer-python/commit/e24735806fc790506d1d3b9ee84954809bd02258))
* **api:** api update ([1255c9b](https://github.com/unlayer/unlayer-python/commit/1255c9b3e6bd708eefb21313c022a1018a78fc3e))
* **api:** api update ([3901e44](https://github.com/unlayer/unlayer-python/commit/3901e44ec76d4bdc1ae8055639d1121965f8e6c6))
* **api:** api update ([e90df1d](https://github.com/unlayer/unlayer-python/commit/e90df1d06e53f40707ccc73610d797eaa3c51fa5))
* **api:** api update ([d0bb085](https://github.com/unlayer/unlayer-python/commit/d0bb0855866ba1daf54f700415c01fcf752090f3))
* **api:** api update ([39253ba](https://github.com/unlayer/unlayer-python/commit/39253ba25f6a5da8e18da9d564af41e0c7e4c0e7))
* **api:** api update ([b65e14e](https://github.com/unlayer/unlayer-python/commit/b65e14e7a19564d228e7436bae27b35a9ede6693))
* **api:** api update ([d83034d](https://github.com/unlayer/unlayer-python/commit/d83034df2dbb4dfc3ee96d101bcdce87dc66306f))
* **api:** api update ([93b319e](https://github.com/unlayer/unlayer-python/commit/93b319e21ac5f484c9d3efa4a51fba4269fe6737))
* **api:** api update ([dd927cc](https://github.com/unlayer/unlayer-python/commit/dd927cc54abf0b619091f71e91d778da87323043))
* **api:** api update ([1a2f183](https://github.com/unlayer/unlayer-python/commit/1a2f183e4fd9a9e512a41855aa1b91b4d28d6bdf))
* **api:** api update ([1cf5d8e](https://github.com/unlayer/unlayer-python/commit/1cf5d8e9a10c2b8684838fa628b1b864bbe74209))
* **api:** api update ([35876ba](https://github.com/unlayer/unlayer-python/commit/35876ba78ab506c86a36ae8aead33bf3f04549a6))
* **api:** api update ([eafe372](https://github.com/unlayer/unlayer-python/commit/eafe372ab530d1a516b6f88630060dd1e384a288))
* **api:** api update ([db50139](https://github.com/unlayer/unlayer-python/commit/db5013964e0c7efdc485708d622c12fde20c9420))
* **api:** api update ([37dfa82](https://github.com/unlayer/unlayer-python/commit/37dfa8228ed4158855318afb16b50dc71c78b1bb))
* **api:** api update ([04d7f14](https://github.com/unlayer/unlayer-python/commit/04d7f14ec06f71d777b7624b8898e3594dcb88f0))
* **api:** api update ([7dbfb1a](https://github.com/unlayer/unlayer-python/commit/7dbfb1aa7fa765b1750f6ed5a733f4cf584c9766))
* **api:** api update ([51ce8ef](https://github.com/unlayer/unlayer-python/commit/51ce8ef8927b0824ccd847e0acf61cd57388ae0f))
* **client:** add custom JSON encoder for extended type support ([16d4717](https://github.com/unlayer/unlayer-python/commit/16d4717e1dec685c212a6c7d74e969660cf7e03c))
* **client:** add support for binary request streaming ([191bd18](https://github.com/unlayer/unlayer-python/commit/191bd18a0c2588e3742b49b2bb85c23f31c18367))


### Bug Fixes

* use async_to_httpx_files in patch method ([f9bdb58](https://github.com/unlayer/unlayer-python/commit/f9bdb58b5c218d7310e8c3328fc79d2322bc7d24))


### Chores

* **ci:** upgrade `actions/github-script` ([89356cd](https://github.com/unlayer/unlayer-python/commit/89356cd10af2df4ce00e52b3857e772c2ffdda9f))
* configure new SDK language ([9596a35](https://github.com/unlayer/unlayer-python/commit/9596a35093e7c1a7bfb9c1a9da7319482ed4f9c8))
* format all `api.md` files ([eaab341](https://github.com/unlayer/unlayer-python/commit/eaab341586836de0b5d88ccd15ba91bf5d9fb8a9))
* **internal:** add `--fix` argument to lint script ([3402766](https://github.com/unlayer/unlayer-python/commit/340276634acd12227076b5b3fbc3a1d5a8aaaf2f))
* **internal:** add missing files argument to base client ([011c5b3](https://github.com/unlayer/unlayer-python/commit/011c5b3e1d285ad929aa23fbd18f22ded6e37bc2))
* **internal:** add request options to SSE classes ([8215016](https://github.com/unlayer/unlayer-python/commit/82150166172718373d5c625fcb2abd63b996d1c4))
* **internal:** bump dependencies ([4796143](https://github.com/unlayer/unlayer-python/commit/47961438c81e3263207987628d1f00c04a117189))
* **internal:** codegen related update ([d4e8db7](https://github.com/unlayer/unlayer-python/commit/d4e8db7de852054c9232097b80832e630383da0e))
* **internal:** fix lint error on Python 3.14 ([e825b41](https://github.com/unlayer/unlayer-python/commit/e825b41fa160ab18110a59b28ffdf3c504d63407))
* **internal:** make `test_proxy_environment_variables` more resilient ([17a5609](https://github.com/unlayer/unlayer-python/commit/17a5609325e6661d12910c96b3f41ecde33e5cf1))
* **internal:** update `actions/checkout` version ([942160b](https://github.com/unlayer/unlayer-python/commit/942160b8a331a9d21fe2349fba265fd6fb520034))
* speedup initial import ([a0429e9](https://github.com/unlayer/unlayer-python/commit/a0429e971dcf003df2bbfd2d523bea4aab46db76))
* update mock server docs ([e835dc3](https://github.com/unlayer/unlayer-python/commit/e835dc37eab896b138333888f423ba0aae6f0958))
* update SDK settings ([52e5d05](https://github.com/unlayer/unlayer-python/commit/52e5d054a25723d3798cd8a571cd48bc7625bce9))
* update SDK settings ([63ab6f7](https://github.com/unlayer/unlayer-python/commit/63ab6f7d4fee33593fe9d3dfb6daa615bc00897e))
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ If you’d like to use the repository from source, you can either install from g
To install via git:

```sh
$ pip install git+ssh://git@github.com/stainless-sdks/unlayer-python.git
$ pip install git+ssh://git@github.com/unlayer/unlayer-python.git
```

Alternatively, you can build from source and install the wheel file:
Expand All @@ -88,8 +88,7 @@ $ pip install ./path-to-wheel-file.whl
Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.

```sh
# you will need npm installed
$ npx prism mock path/to/your/openapi.yml
$ ./scripts/mock
```

```sh
Expand Down Expand Up @@ -120,7 +119,7 @@ the changes aren't made through the automated pipeline, you may want to make rel

### Publish with a GitHub workflow

You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/stainless-sdks/unlayer-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/unlayer/unlayer-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.

### Publish manually

Expand Down
77 changes: 38 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ The full API of this library can be found in [api.md](api.md).
## Installation

```sh
# install from this staging repo
pip install git+ssh://git@github.com/stainless-sdks/unlayer-python.git
# install from PyPI
pip install unlayer
```

> [!NOTE]
> Once this package is [published to PyPI](https://www.stainless.com/docs/guides/publish), this will become: `pip install unlayer`

## Usage

The full API of this library can be found in [api.md](api.md).
Expand All @@ -32,21 +29,20 @@ import os
from unlayer import Unlayer

client = Unlayer(
access_token=os.environ.get("UNLAYER_ACCESS_TOKEN"), # This is the default and can be omitted
# or 'production' | 'qa' | 'dev'; defaults to "production".
environment="stage",
api_key=os.environ.get("UNLAYER_API_KEY"), # This is the default and can be omitted
)

project = client.project.retrieve(
page = client.templates.list(
limit=10,
project_id="your-project-id",
)
print(project.data)
print(page.data)
```

While you can provide a `access_token` keyword argument,
While you can provide an `api_key` keyword argument,
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
to add `UNLAYER_ACCESS_TOKEN="My Access Token"` to your `.env` file
so that your Access Token is not stored in source control.
to add `UNLAYER_API_KEY="My API Key"` to your `.env` file
so that your API Key is not stored in source control.

## Async usage

Expand All @@ -58,17 +54,16 @@ import asyncio
from unlayer import AsyncUnlayer

client = AsyncUnlayer(
access_token=os.environ.get("UNLAYER_ACCESS_TOKEN"), # This is the default and can be omitted
# or 'production' | 'qa' | 'dev'; defaults to "production".
environment="stage",
api_key=os.environ.get("UNLAYER_API_KEY"), # This is the default and can be omitted
)


async def main() -> None:
project = await client.project.retrieve(
page = await client.templates.list(
limit=10,
project_id="your-project-id",
)
print(project.data)
print(page.data)


asyncio.run(main())
Expand All @@ -83,8 +78,8 @@ By default, the async client uses `httpx` for HTTP requests. However, for improv
You can enable this by installing `aiohttp`:

```sh
# install from this staging repo
pip install 'unlayer[aiohttp] @ git+ssh://git@github.com/stainless-sdks/unlayer-python.git'
# install from PyPI
pip install unlayer[aiohttp]
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
Expand All @@ -98,15 +93,14 @@ from unlayer import AsyncUnlayer

async def main() -> None:
async with AsyncUnlayer(
access_token=os.environ.get(
"UNLAYER_ACCESS_TOKEN"
), # This is the default and can be omitted
api_key=os.environ.get("UNLAYER_API_KEY"), # This is the default and can be omitted
http_client=DefaultAioHttpClient(),
) as client:
project = await client.project.retrieve(
page = await client.templates.list(
limit=10,
project_id="your-project-id",
)
print(project.data)
print(page.data)


asyncio.run(main())
Expand Down Expand Up @@ -135,8 +129,8 @@ client = Unlayer()
all_templates = []
# Automatically fetches more pages as needed.
for template in client.templates.list(
project_id="your-project-id",
limit=10,
project_id="your-project-id",
):
# Do something with template here
all_templates.append(template)
Expand All @@ -156,8 +150,8 @@ async def main() -> None:
all_templates = []
# Iterate through items across all pages, issuing requests as needed.
async for template in client.templates.list(
project_id="your-project-id",
limit=10,
project_id="your-project-id",
):
all_templates.append(template)
print(all_templates)
Expand All @@ -170,8 +164,8 @@ Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get

```python
first_page = await client.templates.list(
project_id="your-project-id",
limit=10,
project_id="your-project-id",
)
if first_page.has_next_page():
print(f"will fetch next page using these details: {first_page.next_page_info()}")
Expand All @@ -185,8 +179,8 @@ Or just work directly with the returned data:

```python
first_page = await client.templates.list(
project_id="your-project-id",
limit=10,
project_id="your-project-id",
)

print(f"next page cursor: {first_page.next_cursor}") # => "next page cursor: ..."
Expand Down Expand Up @@ -227,7 +221,8 @@ from unlayer import Unlayer
client = Unlayer()

try:
client.project.retrieve(
client.templates.list(
limit=10,
project_id="your-project-id",
)
except unlayer.APIConnectionError as e:
Expand Down Expand Up @@ -272,7 +267,8 @@ client = Unlayer(
)

# Or, configure per-request:
client.with_options(max_retries=5).project.retrieve(
client.with_options(max_retries=5).templates.list(
limit=10,
project_id="your-project-id",
)
```
Expand All @@ -297,7 +293,8 @@ client = Unlayer(
)

# Override per-request:
client.with_options(timeout=5.0).project.retrieve(
client.with_options(timeout=5.0).templates.list(
limit=10,
project_id="your-project-id",
)
```
Expand Down Expand Up @@ -340,18 +337,19 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from unlayer import Unlayer

client = Unlayer()
response = client.project.with_raw_response.retrieve(
response = client.templates.with_raw_response.list(
limit=10,
project_id="your-project-id",
)
print(response.headers.get('X-My-Header'))

project = response.parse() # get the object that `project.retrieve()` would have returned
print(project.data)
template = response.parse() # get the object that `templates.list()` would have returned
print(template.id)
```

These methods return an [`APIResponse`](https://github.com/stainless-sdks/unlayer-python/tree/main/src/unlayer/_response.py) object.
These methods return an [`APIResponse`](https://github.com/unlayer/unlayer-python/tree/main/src/unlayer/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/unlayer-python/tree/main/src/unlayer/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
The async client returns an [`AsyncAPIResponse`](https://github.com/unlayer/unlayer-python/tree/main/src/unlayer/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

Expand All @@ -360,7 +358,8 @@ The above interface eagerly reads the full response body when you make the reque
To 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.

```python
with client.project.with_streaming_response.retrieve(
with client.templates.with_streaming_response.list(
limit=10,
project_id="your-project-id",
) as response:
print(response.headers.get("X-My-Header"))
Expand Down Expand Up @@ -457,7 +456,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/unlayer-python/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/unlayer/unlayer-python/issues) with questions, bugs, or suggestions.

### Determining the installed version

Expand Down
4 changes: 2 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Methods:

- <code title="post /v3/convert/simple-to-full">client.convert.simple_to_full.<a href="./src/unlayer/resources/convert/simple_to_full.py">create</a>(\*\*<a href="src/unlayer/types/convert/simple_to_full_create_params.py">params</a>) -> <a href="./src/unlayer/types/convert/simple_to_full_create_response.py">SimpleToFullCreateResponse</a></code>

# Project
# Projects

Types:

Expand All @@ -34,7 +34,7 @@ from unlayer.types import ProjectRetrieveResponse

Methods:

- <code title="get /v3/project">client.project.<a href="./src/unlayer/resources/project.py">retrieve</a>(\*\*<a href="src/unlayer/types/project_retrieve_params.py">params</a>) -> <a href="./src/unlayer/types/project_retrieve_response.py">ProjectRetrieveResponse</a></code>
- <code title="get /v3/projects/{id}">client.projects.<a href="./src/unlayer/resources/projects.py">retrieve</a>(id) -> <a href="./src/unlayer/types/project_retrieve_response.py">ProjectRetrieveResponse</a></code>

# Templates

Expand Down
Loading