Unofficial Python SDK for Loops.so email platform
Project description
PyLoops
Unofficial Python SDK for Loops.so.
Installation
pip install pyloops
Or with uv:
uv add pyloops
Quick Start
PyLoops offers two ways to interact with the Loops API:
High-Level API
import pyloops
# Configure once (or set LOOPS_API_KEY environment variable)
pyloops.configure(api_key="your_api_key_here")
# Get the client
client = pyloops.get_client()
# Upsert a contact
await client.upsert_contact(
email="user@example.com",
first_name="John",
last_name="Doe",
subscribed=True,
)
# Find a contact
contacts = await client.find_contact(email="user@example.com")
# Send an event
await client.send_event(
event_name="user_signup",
email="user@example.com",
event_properties={"plan": "premium"},
)
# List mailing lists
mailing_lists = await client.list_mailing_lists()
Low-Level API
For more control, use the auto-generated low-level API directly:
from pyloops import AuthenticatedClient
from pyloops.api.contacts import put_contacts_update
from pyloops.models import ContactUpdateRequest
client = AuthenticatedClient(
base_url="https://app.loops.so/api/v1",
token="your_api_key_here",
)
response = await put_contacts_update.asyncio(
client=client,
body=ContactUpdateRequest(
email="user@example.com",
first_name="John",
last_name="Doe"
)
)
Authentication
All API calls require a Loops API key. Get your API key from your Loops account settings.
There are three ways to configure authentication:
- Environment variable:
export LOOPS_API_KEY="your_api_key_here"
- Module-level configuration:
import pyloops
pyloops.configure(api_key="your_api_key_here")
- Per-client configuration:
import pyloops
client = pyloops.LoopsClient(api_key="your_api_key_here")
Features
This SDK provides access to all Loops.so API endpoints:
- Contacts: Create, update, find, and delete contacts
- Contact Properties: Manage custom contact properties
- Mailing Lists: View available mailing lists
- Events: Trigger event-based emails
- Transactional Emails: Send and list transactional emails
- Sending IPs: Retrieve dedicated sending IP addresses
Documentation
For detailed API documentation, visit the Loops.so API docs.
Automated Updates
This SDK is automatically updated to match the latest Loops.so API specification. The package version corresponds to the Loops API version (current: 1.6.1).
A GitHub Action checks for API updates daily and creates a pull request when changes are detected. After review and merge, a new version is automatically published to PyPI.
Development
Setup
# Clone the repository
git clone https://github.com/doctorgpt-corp/pyloops.git
cd pyloops
# Install dependencies with uv
uv sync --all-groups
Running Tests
Using just:
just check # Run linting + type checking
just lint # Run linting only
just typecheck # Run type checking only
just fmt # Format code
Or directly with uv:
uv run ruff check src/
uv run pyright src/
Project Structure
src/pyloops/
├── __init__.py # Main exports
├── client.py # High-level LoopsClient wrapper
├── config.py # Configuration
├── exceptions.py # Exceptions
├── api/ # Re-exports from _generated.api
├── models/ # Re-exports from _generated.models
└── _generated/ # ALL auto-generated code
├── client.py
├── api/
├── models/
└── types.py
Regenerate SDK
To manually regenerate the SDK from the latest OpenAPI spec:
just generate
Or manually:
rm -rf src/pyloops/_generated
uv tool run openapi-python-client generate --url https://app.loops.so/openapi.yaml --meta uv
mv loops-open-api-spec-client/loops_open_api_spec_client src/pyloops/_generated
rm -rf loops-open-api-spec-client openapi.yaml
Custom code is never touched during regeneration.
License
MIT
Disclaimer
This is an unofficial SDK and is not affiliated with or endorsed by Loops.so.
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 pyloops-1.6.1.4.tar.gz.
File metadata
- Download URL: pyloops-1.6.1.4.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9459f66e54c35b3ed1757fea0bbd533be956ca240da4ed637c9138e831653ad9
|
|
| MD5 |
60123344b1a488a45fec47f495967ca3
|
|
| BLAKE2b-256 |
8a6101cae416f66bba340075caed2fbcb34f0543a74b8d1998cee1cdae39a4f5
|
Provenance
The following attestation bundles were made for pyloops-1.6.1.4.tar.gz:
Publisher:
publish.yml on doctorgpt-corp/pyloops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyloops-1.6.1.4.tar.gz -
Subject digest:
9459f66e54c35b3ed1757fea0bbd533be956ca240da4ed637c9138e831653ad9 - Sigstore transparency entry: 707691822
- Sigstore integration time:
-
Permalink:
doctorgpt-corp/pyloops@bdcdba4564d8b1df2a201a4341105b869e499ff9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/doctorgpt-corp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bdcdba4564d8b1df2a201a4341105b869e499ff9 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pyloops-1.6.1.4-py3-none-any.whl.
File metadata
- Download URL: pyloops-1.6.1.4-py3-none-any.whl
- Upload date:
- Size: 66.6 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 |
7d01c335f64ec8e7716332635405ef2ab1a86f87b84087f9372882a2f44fce0c
|
|
| MD5 |
30aa730992fc567fd980234268616d9c
|
|
| BLAKE2b-256 |
ea1952cb792f86db055cc3e301c98301feee7f3df9d2a63d43b8f662a468a09c
|
Provenance
The following attestation bundles were made for pyloops-1.6.1.4-py3-none-any.whl:
Publisher:
publish.yml on doctorgpt-corp/pyloops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyloops-1.6.1.4-py3-none-any.whl -
Subject digest:
7d01c335f64ec8e7716332635405ef2ab1a86f87b84087f9372882a2f44fce0c - Sigstore transparency entry: 707691046
- Sigstore integration time:
-
Permalink:
doctorgpt-corp/pyloops@bdcdba4564d8b1df2a201a4341105b869e499ff9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/doctorgpt-corp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bdcdba4564d8b1df2a201a4341105b869e499ff9 -
Trigger Event:
push
-
Statement type: