Skip to main content

Intempt Python SDK

Server-side client for Intempt. Data in, decisions out.

  • In — events, identity, consent, commerce
  • Out — recommendations from your feeds

This is a server library, not a browser one. It holds no per-user state: every call takes its identifier explicitly, so one client instance is safe to share across threads and requests for all users.

pip install intempt

Requires Python 3.9 or newer. No runtime dependencies.

Quick start

from intempt import Intempt

intempt = Intempt(
    org="my-org",
    project="my-project",
    api_key=os.environ["INTEMPT_API_KEY"],  # "<prefix>.<secret>"
    source_id="684508596718616576",
)

intempt.track("purchase", user_id="user@example.com", properties={"total": 99.99})

feed = intempt.recommend(
    user_id="user@example.com",
    feed_id="5292",
    fields=["id", "title"],
)

By default each call sends one request and returns when the server responds. Nothing is buffered, so there is nothing to lose on exit — which makes this safe in Lambda and other short-lived processes.

API

call returns endpoint
Intempt(**config) client —
track(event, **options) bool POST …/track
track_batch(events) bool POST …/track, chunked
identify(**options) bool POST …/track (reserved Identify)
group(account_id=…, **options) bool POST …/track (reserved Identify)
consent.grant(**options) bool POST …/consents/data
consent.revoke(**options) bool POST …/consents/data
ecommerce.product_viewed(product_id=…, **ids) bool POST …/track
ecommerce.added_to_cart(product_id=…, quantity=…, **ids) bool POST …/track
ecommerce.ordered(products=[…], **ids) bool POST …/track
recommend(feed_id=…, fields=[…], **ids) dict POST …/feeds/{id}/data
opt_in() / opt_out() / is_opted_in() — —
flush() / close() FlushResult(sent, failed) —
set_config(**patch) / config / buffered — —

Writes (track, track_batch, identify, group, consent.*, ecommerce.*) return bool — queued in batch mode, delivered in direct mode — and never raise for a delivery problem. A failed send is reported once per batch to the on_delivery_failure callable you pass to Intempt(...), as a DeliveryFailure(kind, event_count, event_ids, terminal, status, retry_after). A bad argument or a closed client still raises IntemptConfigError, and recommend() still raises IntemptApiError. The return values in the table above that say None are bool for these write methods.

Identifiers

Every call takes at least one of two, and both are values you already own:

user_id your identifier for a person: an email, an internal user id
account_id your identifier for a company or account

That is the whole list. The platform resolves identity from user_id itself.

Two platform identifiers are deliberately not exposed:

  • profile_id is the anonymous id the browser SDK mints and keeps on the device. A server that invents one creates an orphan profile that never stitches to a real visitor.
  • master_id is assigned internally after identity resolution. There is no way to look one up from here, and a hardcoded one breaks the moment two profiles merge.

Batching

Off by default. Turn it on for a long-lived process:

from intempt import Intempt, BatchOptions

intempt = Intempt(
    org="my-org",
    project="my-project",
    api_key=key,
    batch=BatchOptions(size=50, flush_ms=5_000, max_queue=10_000),
)

intempt.track("page_view", user_id="u1")  # buffered
intempt.flush()  # send now
intempt.close()  # drain and release

flush() and close() are safe to call when batching is off; they return FlushResult(sent=0, failed=0). close() is this SDK's shutdown.

close() drains for at most 30 seconds, then drops what is left, counts it as failed, reports it as dropped and logs how many events it gave up on. Without a ceiling a shutdown hook can block for minutes against a failing endpoint. flush() is not bounded: a caller who is not shutting down has not asked to give up.

Send policy (INT-7436)

Each request is sent once, in batch and direct mode alike.

response behaviour
2xx sent
503, 429 resend once after Retry-After clamped to 1–60 s (1 s when absent); a wait over 5 s drops instead of sleeping
any other status (400, 401–404, 408, 413, 500, 502, 504, …) drop and report
timeout or broken connection after the request was written drop and report; the server may already have it
never reached the server (DNS, refused, connect timeout) batch mode keeps the batch until the next timed flush (flush_ms) or an explicit flush(), and reaching size meanwhile sends nothing; direct mode drops and reports
a pooled keep-alive socket the server already closed reconnect once at once and send on the fresh socket

At max_queue the oldest queued event that no send is carrying is dropped and reported dropped, and the new event is queued.

The buffer is in memory. A hard crash loses it.

Ingestion has no idempotency key — eventId travels in the payload but is not a column in the events table, and the table is a plain MergeTree, so nothing collapses duplicates. That is why a request that may have landed (a timeout after the write) is never resent: the SDK trades a possible loss, which it reports, for no duplicates.

Timestamps

timestamp accepts a datetime or epoch milliseconds. A naive datetime is treated as UTC, not local time.

It is a backfill mechanism, between 2010 and 2040. The event store keeps your value and records arrival separately, so the two never overwrite each other.

your timestamp what happens
before 2010-01-01 request rejected with an error naming the threshold
2010 to 2040 stored as given
after 2040-01-18 silently replaced with the server's current time

A timestamp in seconds where milliseconds were meant lands in the far future, sails past the upper bound, and is quietly rewritten to now — no error, and the event looks like it just happened. The reverse mistake fails loudly.

Opting out

intempt.opt_out()  # suppresses track, batch and commerce; consent is still sent
intempt.opt_in()

The gate is applied when events are sent, not only when they are captured, so events buffered before opt_out() are discarded rather than transmitted by a later flush.

Not in this SDK

Console and configuration operations — journeys, dashboards, segments, brand — belong to the CLI and the MCP server, not to a data-plane SDK.

Experiments and personalizations are also absent: they resolve a web experience against a page, and a server has no page to modify. Use the browser SDK for those.

License

Apache 2.0. Contains code derived from mixpanel-python, also Apache 2.0; see NOTICE for what was taken and what was changed.

Metadata

Release files for intempt 3.0.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 intempt 3.0.0
File Size Uploaded Provenance Actions
intempt-3.0.0.tar.gz 95.6 kB Without provenance Details for intempt-3.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 133.7 kB

Release files / intempt-3.0.0.tar.gz

Download URL intempt-3.0.0.tar.gz
Size 95.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3e1cf086313410d99cf20d0335f8b41aa1e5123a65a96230b1b780c0a55ca033
BLAKE2b-256 checksum
How to use checksums
dfd56fa595677842c456d8a432edd9a98753a3e7583dab49d066f5f2ee5eb769
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / intempt-3.0.0-py3-none-any.whl

Download URL intempt-3.0.0-py3-none-any.whl
Size 38.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
762d993df57b88d74e0c3784f3c48d2529048c215bbf5c77df70bbf5c4c7cb74
BLAKE2b-256 checksum
How to use checksums
ed8bd22bd8f5753e2d12c164baac489377df36890958c46ff26df92501764068
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for intempt 3.0.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.

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.

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