Skip to main content

AudienceKit for Python

The audiencekit package: an audience's venues, people, locales, events and the signed-in person's own state, over the AudienceKit GraphQL API (https://api.audiencekit.com/v1/audience/<audience id>/graphql). Python 3.10 or newer, on httpx, with a blocking Client and an asyncio AsyncClient that take the same calls. Typed throughout (py.typed).

It carries the same documents and models as the Swift and Kotlin SDKs in this repository, so an app or a service built with it reads the API the way the apps do, with the same tolerance for audiences that haven't installed a module.

  • Building a website: service tokens, the public listings, the community, news and caching.
  • Signing people in: Facebook, Google, Apple and App Review codes, one session per browser.
  • Reference: every call, model and helper.
  • Examples: a listings page, a news digest, Facebook sign-in, member actions and a community export, each a program you can run.

Installation

pip install audiencekit

Or, from this repository: pip install ./python.

Usage

from audiencekit import Client, Configuration, Credential, DeviceDescription

client = Client(Configuration(host="hotmess.social"))

# Either sign a person in with a Facebook (or Apple) token the app obtained…
credential = client.sign_in_with_facebook(facebook_access_token, DeviceDescription("install-id"))
# …or adopt a credential minted elsewhere (a service token from the console, or one you saved):
client.adopt(Credential.from_json(saved_json))

for event in client.events():  # soonest first; window="PAST" for the latest
    print(event.name, event.start_at, event.venue_name, event.rsvp and event.rsvp.count)

venues = client.venues()
people = client.people()
me = client.me()
client.rsvp_event(event.id, "ATTENDING")

The same calls on asyncio:

async with AsyncClient(Configuration(host="hotmess.social"), credential=credential) as client:
    venues = await client.venues()

Servers and jobs: service tokens

A server that reads as the audience, with no one signed in, uses a service token from the audience's console:

client = Client.from_environment()  # AUDIENCEKIT_TOKEN=akst_…, AUDIENCEKIT_HOST=hotmess.social

for listing in client.public_listings():  # needs the public:read scope
    print(listing.kind, listing.title)

community = client.community()  # the audience, locales, venues, people, events and series

The client trades the token for an hour-long session and renews it before it runs out. See Building a website.

News, cover, chat and the calendar

Audiences with Soapbox carry news (articles(), article(id), articles_about("venue", id), publications()); a signed-in member can buy cover (venue_cover(), buy_cover(), cover_pass_code() for the door), chat (send_chat_message()), add events to their calendar (create_calendar_feed()) and report or block (report_content(), block_user()). Every call is in the reference.

Your own operations

client.graphql(query, variables, operation_name) runs any document against the audience's endpoint and returns its data; client.run(Operation(...)) adds the module-tolerant retry below to one of your own. Both take an endpoint for packages built for other views of the API ("graphql", the consumer view, by default).

Modules the audience doesn't have

The API leaves a module's fields out of an audience that hasn't installed it (Facebook Pages, Google Places, RSVP, Ticketing, Friends…), and asking for one fails the whole operation with undefinedField. The typed calls first ask for everything; when the API refuses a field they ask the schema which fields the operation's types have, cache the answer for the session, and run the operation again with only those. The models' module fields (Event.rsvp, Venue.page, Person.home_venue…) are None when the audience doesn't have them.

Errors

Every failure raises AudienceKitError, with a code from the API's vocabulary (UNAUTHENTICATED, FORBIDDEN, NOT_FOUND, INVALID with per-field messages in fields, RATE_LIMITED, CONFLICT, INTERNAL) or the SDK's own (NOT_SIGNED_IN, SIGN_IN_REJECTED, NETWORK, DECODING, MISSING_CONFIGURATION, UPDATE_REQUIRED…), the message, the HTTP status when there was one, and the GraphQL errors when the operation returned any. When the API rejects the session (HTTP 401), the client forgets the credential and tells your on_session_change listener session_ended; sign in again.

Headers

Every call carries Authorization: Bearer <token>, X-AudienceKit-API-Version (the contract date this SDK speaks), X-AudienceKit-Client: AudienceKit-Python/<version> and, for staging builds (Configuration(environment="staging")), X-AudienceKit-Environment: staging.

Development

cd python
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
pytest --cov          # fails under 85% line coverage, the repository's floor
ruff check . && ruff format --check . && mypy

The tests run against a fake API behind httpx.MockTransport (tests/conftest.py), which records every request the client sends and answers each GraphQL operation by name.

Versioning and releases

The package keeps its own version in src/audiencekit/_version.py, separate from the Swift and Kotlin SDKs' VERSION at the repository root, and the root release job doesn't publish it. Add the version's entry to CHANGELOG.md. Once a change that raises the version merges to main, the python-release workflow builds the sdist and wheel, uploads them to PyPI with trusted publishing (PyPI's publisher names lwm-luminx/audience-kit-sdk, workflow python-release.yml, environment pypi), and tags the commit python-<version> (the prefix keeps it apart from the Swift package's bare version tags, which Swift Package Manager resolves).

License

Source-available under the AudienceKit SDK License 1.2 (LicenseRef-AudienceKit-SDK-1.2), © Love Wins Media, Inc.: use it only in apps that connect to AudienceKit as hosted by Love Wins Media. Every other use is prohibited without Love Wins Media's written permission and an audience ID or token issued for that use. No other license is granted, misrepresenting the work is prohibited, and changed versions may be made only in a fork after written notice. See the root README for details.

Metadata

Release files for audiencekit 0.2.0

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

Source distribution (sdist)

Source distribution for audiencekit 0.2.0
File Size Uploaded Provenance Actions
audiencekit-0.2.0.tar.gz 64.8 kB With provenance Details for audiencekit-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 111.7 kB

Release files / audiencekit-0.2.0.tar.gz

Download URL audiencekit-0.2.0.tar.gz
Size 64.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c15b4dd2cc65930330dc553b5e895e8c011088af46942721acef7f846d43de37
BLAKE2b-256 checksum
How to use checksums
10acad214c39aebfb07d6ef34b7a07689c50f6451aa83b94e4d1ccd74ead899c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / audiencekit-0.2.0-py3-none-any.whl

Download URL audiencekit-0.2.0-py3-none-any.whl
Size 46.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01f583fba022a7e3a50f43e39d032ba5f184725637a51b4823104fb7116ec551
BLAKE2b-256 checksum
How to use checksums
801e54347d0d28029516c4aef1726756ee35f532d2b6160e3e21f2ecddc1ab0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for audiencekit 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for audiencekit-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

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

0.2.0 This release

2 release files Full 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