Skip to main content

SwipeFlow Python SDK

Python Version License

Python client for the SwipeFlow API: add manual approval steps to your automation workflows.

Every endpoint and model is generated from the public OpenAPI spec (https://api.swipeflow.io/v1/openapi.json) with openapi-python-client. The only hand-written code is a small wrapper (swipeflow/client.py) that sets the API key, base URL and timeout, and raises on HTTP errors.

Installation

pip install swipeflow

Requires Python 3.11+.

Quick start

from swipeflow import SwipeFlowClient
from swipeflow.api.items.create_item import sync as create_item
from swipeflow.api.items.update_item_decision import sync as update_item_decision
from swipeflow.api.projects.list_projects import sync as list_projects
from swipeflow.models import (
    ContentType,
    CreateItemRequest,
    ItemContent,
    UpdateItemDecisionRequest,
    UpdateItemDecisionRequestDecision,
)

with SwipeFlowClient(api_key="your-api-key") as client:
    projects = list_projects(client=client)
    project_id = projects.projects[0].id

    item = create_item(
        project_id=project_id,
        client=client,
        body=CreateItemRequest(
            title="Approve new user signup",
            content=ItemContent(type_=ContentType.TEXT, data="New user John Doe signed up"),
        ),
    )

    update_item_decision(
        project_id=project_id,
        item_id=item.id,
        client=client,
        body=UpdateItemDecisionRequest(
            decision=UpdateItemDecisionRequestDecision.APPROVED,
            comment="User verified",
        ),
    )

Instead of passing api_key, you can set the SWIPEFLOW_API_KEY environment variable and call SwipeFlowClient().

Using the generated API

Endpoints are modules grouped by API tag under swipeflow.api, named after the spec's operationId (swipeflow.api.projects.list_projects, swipeflow.api.items.create_item, ...). Request and response types are in swipeflow.models. Each endpoint module exposes four functions:

Function Returns
sync(...) the parsed model
sync_detailed(...) Response with status_code, headers, raw content and parsed
asyncio(...) awaitable version of sync
asyncio_detailed(...) awaitable version of sync_detailed

The examples above import the function you want under the endpoint's name, so calls read like list_projects(client=client):

from swipeflow.api.projects.list_projects import sync as list_projects              # blocking
from swipeflow.api.projects.list_projects import asyncio as list_projects_async     # awaitable

Importing the module works too (from swipeflow.api.projects import list_projects, then list_projects.sync(client=client)), which is handy if you use several variants of the same endpoint.

Endpoints whose spec entry declares no response schema (currently billing and a few deletes and redirects) only have the *_detailed variants; read the body from response.content.

Browse swipeflow/api/ (or the OpenAPI spec) to discover endpoints. Editors autocomplete every parameter and model field.

Async

import asyncio

from swipeflow import SwipeFlowClient
from swipeflow.api.projects.list_projects import asyncio as list_projects


async def main():
    async with SwipeFlowClient() as client:
        projects = await list_projects(client=client)


asyncio.run(main())

Authentication

Credential How
API key SwipeFlowClient(api_key=...) or SWIPEFLOW_API_KEY; sent as X-API-Key
JWT / OAuth access token SwipeFlowClient(token=...); sent as Authorization: Bearer

Some account-level endpoints (for example API key management) require an interactive session token and reject API keys with 403.

Error handling

HTTP errors (status >= 400) raise SwipeFlowError:

from swipeflow import SwipeFlowError
from swipeflow.api.projects.get_project import sync as get_project

try:
    get_project(project_id="000000000000000000000000", client=client)
except SwipeFlowError as e:
    print(e.status_code)  # 404
    print(e.message)      # "Project not found"
    print(e.errors)       # field-level validation errors, if any
    print(e.response)     # the underlying httpx.Response

Network failures and timeouts raise the usual httpx exceptions.

Configuration

SwipeFlowClient accepts every argument of the generated AuthenticatedClient, for example:

import httpx

client = SwipeFlowClient(
    api_key="your-api-key",
    base_url="https://staging-api.swipeflow.io",  # default: https://api.swipeflow.io
    timeout=httpx.Timeout(60.0),                   # default: 30s
    headers={"X-Custom": "1"},
)

Development

git clone https://github.com/swipeflow/swipeflow-sdk-py.git
cd swipeflow-sdk-py
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

Set SWIPEFLOW_API_KEY to also run the read-only live tests in tests/test_live.py.

Regenerating from the spec

python scripts/generate.py                  # download the live spec and regenerate
python scripts/generate.py --spec ./my.json # or generate from another spec (URL or file)

This replaces the generated files in swipeflow/ (api/, models/, client.py, errors.py, types.py and __init__.py, the last one from templates/package_init.py.jinja). Never edit those by hand; change the OpenAPI spec (or the generator flags and template in scripts/) instead. The generated code is committed so that installing from git works without a generation step; regenerate and commit it whenever the API changes.

Method names come from each operation's operationId in the spec; operations without one get names derived from their path.

Project layout

swipeflow/
├── _wrapper.py     # hand-written: SwipeFlowClient + SwipeFlowError
├── py.typed
├── __init__.py     # generated from templates/package_init.py.jinja
├── api/            # generated: api/<tag>/<operation>.py
├── models/         # generated
└── client.py, errors.py, types.py  # generated
templates/package_init.py.jinja
scripts/generate.py # download spec + run the generator
tests/

License

ISC

Metadata

Release files for swipeflow 1.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swipeflow 1.1.7
File Size Uploaded Provenance Actions
swipeflow-1.1.7.tar.gz 77.1 kB Without provenance Details for swipeflow-1.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for swipeflow 1.1.7
File Interpreter ABI Platform Actions
swipeflow-1.1.7-py3-none-any.whl Python 3 none any Details for swipeflow-1.1.7-py3-none-any.whl

Total release size: 273.2 kB

Release files / swipeflow-1.1.7.tar.gz

Download URL swipeflow-1.1.7.tar.gz
Size 77.1 kB
Tags Source
SHA-256 checksum
How to use checksums
68afaa55b0f42c5ca67955b7f4045a340f09c4802094a81f6701280584c73f31
BLAKE2b-256 checksum
How to use checksums
77dc4519a600c1f260fcc77201ad6deb55946610f2b88859b330c475f6eed012
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / swipeflow-1.1.7-py3-none-any.whl

Download URL swipeflow-1.1.7-py3-none-any.whl
Size 196.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5550b6cb36ac423dfbded4ca2a66574c40a6a5219dba16e21f104fd0d36ccca7
BLAKE2b-256 checksum
How to use checksums
608450a167f1a0342cde2760e66054ed3ab4110d8bb6f4dfdde3649102f5f227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for swipeflow 1.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page