Skip to main content

Official Python SDK for Forte Platforms

Project description

Forte Platforms Python SDK

Official Python SDK for interacting with the Forte Platforms API.

Installation

pip install forte-sdk

Authentication

The SDK supports three auth modes.

Inside a Forte-hosted service (no config)

FORTE_API_TOKEN is set automatically and scoped to the service's project:

client = ForteClient()

Server-side BFF calling client.users.* (no token, per-call authorization)

When proxying user-scoped calls from a BFF, omit the token and pass each user's session token as the authorization parameter on each call:

client = ForteClient()
client.users.renew_session_token(
    project_id=project_id,
    authorization=f"Bearer {user_session_token}",
)

External server-side calling client.projects.* (explicit token)

client = ForteClient(api_token="your_api_token_here")

Or set FORTE_API_TOKEN in the environment and call ForteClient().

You can generate an API token from the Forte Platforms dashboard.

Quick Start

from forte_sdk import ForteClient

client = ForteClient()

# List your projects
projects = client.projects.list_projects()

# Get a specific project
project = client.projects.get_project(project_id="your-project-id")

Error Handling

API errors are raised as exceptions:

from forte_sdk.generated.exceptions import ApiException

try:
    project = client.projects.get_project(project_id="invalid-id")
except ApiException as e:
    print(f"API error {e.status}: {e.reason}")

User Custom Attributes

Store arbitrary key-value metadata on your users. Useful for tracking subscription tiers, feature flags, preferences, or any application-specific data.

# Set custom attributes on a user
user = client.projects.put_user_custom_attributes(
    project_id="your-project-id",
    user_id="user-id",
    request_body={
        "plan": "pro",
        "referral_source": "google",
        "onboarding_completed": "true",
    },
)

print(user.custom_metadata_attributes)
# {'plan': 'pro', 'referral_source': 'google', 'onboarding_completed': 'true'}

Key constraints:

  • Keys must be 1-64 characters: letters, numbers, underscores, and hyphens only
  • Values are strings
  • Each call replaces all existing attributes — include any you want to keep

Merge with existing attributes

# Read current attributes, then merge
user = client.projects.get_project_user(
    project_id="your-project-id",
    user_id="user-id",
)

client.projects.put_user_custom_attributes(
    project_id="your-project-id",
    user_id="user-id",
    request_body={
        **user.custom_metadata_attributes,
        "plan": "enterprise",  # update one field
    },
)

API Reference

client.projects

Manage projects and services on Forte Platforms.

client.users

Manage end-users within your projects.

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

forte_sdk-1.0.169.tar.gz (84.8 kB view details)

Uploaded Source

Built Distribution

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

forte_sdk-1.0.169-py3-none-any.whl (215.2 kB view details)

Uploaded Python 3

File details

Details for the file forte_sdk-1.0.169.tar.gz.

File metadata

  • Download URL: forte_sdk-1.0.169.tar.gz
  • Upload date:
  • Size: 84.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for forte_sdk-1.0.169.tar.gz
Algorithm Hash digest
SHA256 9a27acf263d57dd6aec9f4736c183de13953a30f92ce440898f891537c5ba75e
MD5 915889fcfb6ad05b1d9e0d5268905e1b
BLAKE2b-256 ad4a089271d204b6aecbded9b2582260bc9309cd72ca7d99876355a962646451

See more details on using hashes here.

File details

Details for the file forte_sdk-1.0.169-py3-none-any.whl.

File metadata

  • Download URL: forte_sdk-1.0.169-py3-none-any.whl
  • Upload date:
  • Size: 215.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for forte_sdk-1.0.169-py3-none-any.whl
Algorithm Hash digest
SHA256 a29b9e79fb7799705c7830dfca7c56fdcd59a6b88d7ce08bd900f8c895708f13
MD5 9a2376ad4a2930a0f9b61e284f1605bf
BLAKE2b-256 020ea7e02c786bd166cef0a3952c3dca31df440789c1154910e7dce1b39cd4be

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