Skip to main content

A Solidarity.Tech Python API Wrapper

Project description

pysolidarity

Solidarity.Tech API Wrapper for Python.

Creates a clean(er) python interface to a few functions of the Solidarity.tech API.

This is an early version. Not fully tested. Significantly vibe-coded. USE AT YOUR OWN RISK

Currently only supports creating, updating, and fetching users.

Installation

pip install pysolidarity
# with optional rate limiting support
pip install "pysolidarity[rate]"

Quick start

from pysolidarity import make_client_from_env

# export SOLIDARITY_API_KEY=...
client = make_client_from_env()

# Create-or-update by email or phone
user = client.users.create_or_update({"phone_number": "15555555555", "first_name":"Jimmy"})
print(user)

# Update (returns all user details)
client.users.update(user["id"], {"first_name":"Jiiiimmy"})

# Get (returns all user details)
client.users.get(user["id"])

# Set exclusive chapter
client.users.update(user["id"], {"chapter_id": 123, "set_exclusive_chapter": True})

# Enrol in automation (example below is by user_id but you can do it with email and phone_number)
client.users.enroll_in_automation(automation_id=12,user_id=1234)

# Add a user action
client.users.add_action(
    page_id=1234,
    user_id=user["id"],
    data={
        "email": "taylor.smith@example.com",
        "phone_number": "16135551234",
        "first_name": "Taylor",
        "last_name": "Smith",
        "address": {
            "address1": "123 Maple St",
            "address2": "Unit 4",
            "city": "Toronto",
            "state": "ON",
            "zip_code": "M5V1J2",
            "country": "CA",
        },
        "sms_permission": True,
        "call_permission": True,
        "email_permission": True,
    },
)

Rate limiting (does not work in publicly available version)

import redis
from pysolidarity import make_rate_limited_client

r = redis.Redis(host="127.0.0.1", port=6379)
client = make_rate_limited_client(r, req_per_sec=4)
print(client.users.get(1234))

Environment

SOLIDARITY_API_KEY (required)

Development

pip install -e .[dev]

Pushing a new version

Ensure you update the version in _version.py and pyproject.toml

python3 -m pip install --upgrade build
python3 -m build
python3 -m pip install --upgrade twine
python3 -m twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysolidarity-0.4.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysolidarity-0.4.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file pysolidarity-0.4.0.tar.gz.

File metadata

  • Download URL: pysolidarity-0.4.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pysolidarity-0.4.0.tar.gz
Algorithm Hash digest
SHA256 84bc302b88f2cf1abc954e0cbed4ff574e1f45071b89e9bc84a483aed99bc5f7
MD5 faaba5594a3f11b853215c4a60adad41
BLAKE2b-256 2c3fa7c0d8d918f04ca66228965fe760d1af0833f27d03c0b15b8253d98c2798

See more details on using hashes here.

File details

Details for the file pysolidarity-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pysolidarity-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pysolidarity-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87d3837184dacaf1ecbb165be25849893a66e55602578d3c9b8cdb4a120d0323
MD5 a27bd176255e34d6010b509d0decab23
BLAKE2b-256 02673e79fb1180e2bef07d7b4c8016d0a964efe979cfed35a7a99204f414570f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page