Declarative REST API ingestion for PySpark
Project description
Welcome to Polymo
Polymo is a helper for pyspark that turns everyday web APIs into tables you can analyse. Point it at an API, tell it what you want to grab, and Polymo does the heavy lifting of fetching the data and lining it up neatly.
Why people use Polymo
- No custom code required. Describe your API once in a short, friendly YAML file or through the point-and-click Builder.
- See results before you commit. Preview the real responses, record-by-record, so you can fix issues early.
- Works with Spark-based tools. When you are ready, Polymo serves the data to your analytics stack using the same interface Spark already understands.
- Designed for teams. Save reusable connectors, share them across projects, and keep secrets (like tokens) out of files.
Pick your path
- Mostly clicking? Open the Builder UI and follow the guided screens. It is the easiest way to create a connector from scratch.
- Prefer a checklist? Read the Configuration guide for a plain-language tour of every field in the YAML file.
- Power user? Jump straight to the CLI or the Python helpers to automate things.
Before you start
- Install Polymo with
pip install polymo. If you want the Builder UI, add the extras:pip install "polymo[builder]". - Make sure you have access to the API you care about (base URL, token if needed, and any sample request parameters).
- Check that PySpark version 4 or newer is available. Polymo uses Spark under the hood to keep data consistent.
Quick tour
- Launch the Builder (optional but recommended). Run
polymo builder --port 9000and open the provided link in your browser. - Describe your API. Fill in a base URL like
https://jsonplaceholder.typicode.com, pick the endpoint/posts, and add filters such as_limit: 20if you only need a sample. - Preview the data. Press the Preview button to see a table of records, the raw API replies, and any error messages.
- Save the connector. Download the YAML config or write it directly to your project folder. Tokens stay out of the file and are passed in later.
- Use it in Spark. Load the file with the short code snippet below or copy/paste from the Builder’s tips panel.
The Builder keeps a local library of every connector you work on. Use the header’s connector picker to hop between drafts, open the library to rename or export them, and never worry about losing your place.
from pyspark.sql import SparkSession
from polymo import ApiReader
spark = SparkSession.builder.getOrCreate()
spark.dataSource.register(ApiReader)
df = (
spark.read.format("polymo")
.option("config_path", "./config.yml") # YAML you saved from the Builder
.option("token", "YOUR_TOKEN") # Only if the API needs one
.load()
)
df.show()
Incremental syncs in one minute
- Add
cursor_paramandcursor_fieldunderincremental:in your YAML to tell Polymo which API field to track. - Pass
.option("incremental_state_path", ...)when reading with Spark. Local paths and remote URLs (S3, GCS, Azure, etc.) work out of the box. - On the first run, seed a starting value with
.option("incremental_start_value", "..."). Future runs reuse the stored cursor automatically. - Override the stored entry name with
.option("incremental_state_key", "...")if you share a state file across connectors. - Skip the state path to keep cursors only in memory during the Spark session, or disable that cache with
.option("incremental_memory_state", "false")if you always want a cold start.
Handling flaky APIs with retries
- Add an
error_handlerblock understream:when you want to customise retries. By default Polymo retries 5× on HTTP5XXand429responses with exponential backoff. - Override the defaults to catch extra status codes or adjust the timing:
stream:
path: /orders
error_handler:
max_retries: 6
retry_statuses:
- 5XX
- 429
- 404
retry_on_timeout: true
retry_on_connection_errors: true
backoff:
initial_delay_seconds: 1
max_delay_seconds: 60
multiplier: 1.8
- Omit the block to keep the safe defaults. The Builder UI exposes the same fields if you prefer toggles over YAML edits.
What’s inside this project
src/polymo/keeps the logic that speaks to APIs and hands data to Spark.polymo builderis a small web app (FastAPI + React) that guides you through every step. No need to run npm, the app is bundled with pip and ready to go.examples/contains ready-made configs you can copy, tweak, and use for smoke tests.
Run the Builder in Docker
- Build the dev-friendly image and launch the Builder with hot reload:
docker compose up --build builder
- The service listens on port
8000; open http://localhost:8000 once Uvicorn reports it is running. - The image already bundles PySpark and OpenJDK 21;
- Stop with
docker compose downand restart quickly using the cached image viadocker compose up builder.
Have fun building connectors!
Where to Next
Read the docs here
Contributions and early feedback welcome!
Project details
Release history Release notifications | RSS feed
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 polymo-0.5.0.tar.gz.
File metadata
- Download URL: polymo-0.5.0.tar.gz
- Upload date:
- Size: 193.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a181ecbc1c1a241b7e469018ca6a985faf14515309fc172abfcc1dde936637ff
|
|
| MD5 |
c578776f15164b5a8b83e823d1d2aff7
|
|
| BLAKE2b-256 |
187d0648bcd5cbd8fda8241913bf8376325b865f2b5fd84254083df4fb31ee95
|
Provenance
The following attestation bundles were made for polymo-0.5.0.tar.gz:
Publisher:
release.yml on dan1elt0m/polymo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polymo-0.5.0.tar.gz -
Subject digest:
a181ecbc1c1a241b7e469018ca6a985faf14515309fc172abfcc1dde936637ff - Sigstore transparency entry: 583940852
- Sigstore integration time:
-
Permalink:
dan1elt0m/polymo@556cf2dab0b65c0be4977862df669226d00bee91 -
Branch / Tag:
refs/tags/0.5.0 - Owner: https://github.com/dan1elt0m
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@556cf2dab0b65c0be4977862df669226d00bee91 -
Trigger Event:
release
-
Statement type:
File details
Details for the file polymo-0.5.0-py3-none-any.whl.
File metadata
- Download URL: polymo-0.5.0-py3-none-any.whl
- Upload date:
- Size: 199.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f084403883e445e1747289b50422b57e1311c5ed127eea108cc05ec9adb66bc
|
|
| MD5 |
35e722bf8c05c726ccc43117014fc033
|
|
| BLAKE2b-256 |
0bef088d3f35879d626bd2011a4ca1ff92534cc582dfb6ef55b3f9c4c9ee03ad
|
Provenance
The following attestation bundles were made for polymo-0.5.0-py3-none-any.whl:
Publisher:
release.yml on dan1elt0m/polymo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polymo-0.5.0-py3-none-any.whl -
Subject digest:
2f084403883e445e1747289b50422b57e1311c5ed127eea108cc05ec9adb66bc - Sigstore transparency entry: 583940853
- Sigstore integration time:
-
Permalink:
dan1elt0m/polymo@556cf2dab0b65c0be4977862df669226d00bee91 -
Branch / Tag:
refs/tags/0.5.0 - Owner: https://github.com/dan1elt0m
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@556cf2dab0b65c0be4977862df669226d00bee91 -
Trigger Event:
release
-
Statement type: