Registry / payments / sift
library6.0.0pypypi✓ verified 84d ago

The `sift` library provides Python bindings for interacting with the Sift Science API, which offers real-time fraud prevention and risk assessment. It enables developers to send event data, retrieve scores and decisions, and manage labels. The library is actively maintained, with version 6.0.0 as the current release, and follows a regular release cadence to support new Python versions and API features.

pip install sift
INSTALL
IMPORT
SIG · SIFT
S
sift
paymentspythonv6.0.0
Install
3.8s avg
Import
620ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v6.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.647s · 21.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.8s · import 0.593s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
import sift client = sift.Client(api_key='YOUR_API_KEY', account_id='YOUR_ACCOUNT_ID')
from sift import Client
The primary Sift client is accessed via 'sift.Client' after importing the top-level 'sift' package, not directly from a submodule named 'Client'.

Initialize the Sift client using your API key and Account ID, then demonstrate sending a `$login` event and fetching user decisions. Authentication details are expected via environment variables for security.

import os import sift # Ensure API_KEY and ACCOUNT_ID are set as environment variables api_key = os.environ.get('SIFT_API_KEY', 'YOUR_API_KEY') account_id = os.environ.get('SIFT_ACCOUNT_ID', 'YOUR_ACCOUNT_ID') if api_key == 'YOUR_API_KEY' or account_id == 'YOUR_ACCOUNT_ID': print("WARNING: Please set SIFT_API_KEY and SIFT_ACCOUNT_ID environment variables or replace placeholders.") client = sift.Client(api_key=api_key, account_id=account_id) # Example: Send a $login event try: response = client.track( event={ '$type': '$login', '$user_id': 'billy_jones_301', '$session_id': 'gigtleqlbrcssi8tghzz2w4w2', '$login_status': '$success', '$user_email': 'billy_jones@example.com', '$ip': '128.148.1.10' } ) print("Login event sent successfully:", response) except sift.client.ApiException as e: print(f"Error sending login event: {e}") # Example: Get decisions for a user try: user_decisions = client.get_user_decisions('billy_jones_301') print("User decisions:", user_decisions) except sift.client.ApiException as e: print(f"Error fetching user decisions: {e}")
Debug
Known issues
breakingVersion 6.0.0 dropped support for Python versions older than 3.8. Projects still on Python 3.7 or earlier must upgrade their Python environment before upgrading to `sift` v6.0.0 or higher.
fix
Upgrade your Python environment to 3.8 or newer, or pin `sift` to a version less than 6.0.0 (e.g., `pip install 'sift<6.0.0'`).
affects: >=6.0.0
breakingThe `abuse_types` parameter in `client.get_decisions()` changed type in v6.0.0. It no longer accepts a comma-separated string (e.g., `'legacy,payment_abuse'`) and now requires a sequence of string literals (e.g., `('legacy', 'payment_abuse')`).
fix
When calling `client.get_decisions()`, pass `abuse_types` as a tuple or list of strings: `abuse_types=('legacy', 'payment_abuse')`.
affects: >=6.0.0
deprecatedStarting from v5.6.1, several API calls (client.score(), client.get_user_score(), client.rescore_user(), client.unlabel()) moved from passing the API key as a request parameter to using Basic Authentication. While the old method might still work for some older endpoints or versions, it's deprecated for these specific calls and should be updated.
fix
Ensure your `sift.Client` is initialized with `api_key` and the library will automatically handle Basic Authentication for affected methods. Do not manually add `api_key` to event bodies or URL parameters for these calls.
affects: >=5.6.1
Errors
Common errors & fixes
TypeError: 'str' object is not iterable
Attempting to pass a comma-separated string to the `abuse_types` parameter in `client.get_decisions()` after upgrading to `sift` v6.0.0, which now expects a sequence (e.g., tuple or list).
fix
Change the `abuse_types` parameter from a string to a tuple or list of strings: `abuse_types=('legacy', 'payment_abuse')`.
sift.client.ApiException: API key not found or invalid.
The Sift API key or Account ID is missing or incorrect during client initialization, or for specific requests that require authentication.
fix
Verify that `SIFT_API_KEY` and `SIFT_ACCOUNT_ID` environment variables are correctly set, or that `api_key` and `account_id` are passed correctly to `sift.Client()` upon instantiation.
Unsupported Python version: X.X. `sift` requires Python >= 3.8.
Running `sift` version 6.0.0 or newer with an unsupported Python version (e.g., Python 3.7 or earlier).
fix
Upgrade your Python environment to version 3.8 or higher. Alternatively, if unable to upgrade Python, downgrade the `sift` library version: `pip install 'sift<6.0.0'`.
Upgrade
Version history
6.0.0latest on PyPI · released May 5, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
46 hits · last 30 days
node
42
Resources
sift — pip install sift · libregistry