{"id":8640,"library":"sift","title":"Sift Science Python API Client","description":"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.","status":"active","version":"6.0.0","language":"en","source_language":"en","source_url":"https://github.com/SiftScience/sift-python","tags":["fraud-detection","api-client","risk-management","fintech","webhook","e-commerce"],"install":[{"cmd":"pip install sift","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary Sift client is accessed via 'sift.Client' after importing the top-level 'sift' package, not directly from a submodule named 'Client'.","wrong":"from sift import Client","symbol":"Client","correct":"import sift\nclient = sift.Client(api_key='YOUR_API_KEY', account_id='YOUR_ACCOUNT_ID')"}],"quickstart":{"code":"import os\nimport sift\n\n# Ensure API_KEY and ACCOUNT_ID are set as environment variables\napi_key = os.environ.get('SIFT_API_KEY', 'YOUR_API_KEY')\naccount_id = os.environ.get('SIFT_ACCOUNT_ID', 'YOUR_ACCOUNT_ID')\n\nif api_key == 'YOUR_API_KEY' or account_id == 'YOUR_ACCOUNT_ID':\n    print(\"WARNING: Please set SIFT_API_KEY and SIFT_ACCOUNT_ID environment variables or replace placeholders.\")\n\nclient = sift.Client(api_key=api_key, account_id=account_id)\n\n# Example: Send a $login event\ntry:\n    response = client.track(\n        event={\n            '$type': '$login',\n            '$user_id': 'billy_jones_301',\n            '$session_id': 'gigtleqlbrcssi8tghzz2w4w2',\n            '$login_status': '$success',\n            '$user_email': 'billy_jones@example.com',\n            '$ip': '128.148.1.10'\n        }\n    )\n    print(\"Login event sent successfully:\", response)\nexcept sift.client.ApiException as e:\n    print(f\"Error sending login event: {e}\")\n\n# Example: Get decisions for a user\ntry:\n    user_decisions = client.get_user_decisions('billy_jones_301')\n    print(\"User decisions:\", user_decisions)\nexcept sift.client.ApiException as e:\n    print(f\"Error fetching user decisions: {e}\")","lang":"python","description":"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."},"warnings":[{"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'`).","message":"Version 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.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"When calling `client.get_decisions()`, pass `abuse_types` as a tuple or list of strings: `abuse_types=('legacy', 'payment_abuse')`.","message":"The `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')`).","severity":"breaking","affected_versions":">=6.0.0"},{"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.","message":"Starting 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.","severity":"deprecated","affected_versions":">=5.6.1"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change the `abuse_types` parameter from a string to a tuple or list of strings: `abuse_types=('legacy', 'payment_abuse')`.","cause":"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).","error":"TypeError: 'str' object is not iterable"},{"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.","cause":"The Sift API key or Account ID is missing or incorrect during client initialization, or for specific requests that require authentication.","error":"sift.client.ApiException: API key not found or invalid."},{"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'`.","cause":"Running `sift` version 6.0.0 or newer with an unsupported Python version (e.g., Python 3.7 or earlier).","error":"Unsupported Python version: X.X. `sift` requires Python >= 3.8."}]}