Skip to main content

Official Fourbyfour SDK for Python

Project description

fourbyfour

Official Python SDK for Fourbyfour - Revenue workflows on autopilot.

Installation

pip install fourbyfour

Quick Start

from fourbyfour import saas

fbf = saas(api_key="sk_...", project_id="proj_...")

# Track events → triggers workflows
fbf.track("payment.failed", {
    "user_id": "u_123",
    "amount": 99.0,
    "currency": "USD",
    "plan": "Pro",
    "subscription_id": "sub_456",
    "billing_cycle": "monthly"
})

# Send context → helps optimize
fbf.notify({
    "user_id": "u_123",
    "timezone": "Asia/Kolkata",
    "tier": "premium"
})

Verticals

Choose the client that matches your business:

from fourbyfour import saas, ecommerce, fintech, edtech, games, apps

# SaaS
saas_client = saas(api_key="sk_...", project_id="proj_...")

# E-commerce
ecom_client = ecommerce(api_key="sk_...", project_id="proj_...")

# Fintech
fin_client = fintech(api_key="sk_...", project_id="proj_...")

# EdTech
edu_client = edtech(api_key="sk_...", project_id="proj_...")

# Games
game_client = games(api_key="sk_...", project_id="proj_...")

# Apps
app_client = apps(api_key="sk_...", project_id="proj_...")

SaaS Events

fbf = saas(api_key="sk_...", project_id="proj_...")

# Trial lifecycle
fbf.track("trial.started", {"user_id": "u_123", "plan": "Pro", "trial_days": 14})
fbf.track("trial.ending", {"user_id": "u_123", "plan": "Pro", "days_remaining": 3})

# Subscription events
fbf.track("subscription.canceled", {"user_id": "u_123", "plan": "Pro", "reason": "too_expensive"})
fbf.track("subscription.upgraded", {"user_id": "u_123", "from_plan": "Starter", "to_plan": "Pro"})
fbf.track("subscription.downgraded", {"user_id": "u_123", "from_plan": "Pro", "to_plan": "Starter"})

# Usage & engagement
fbf.track("usage.threshold", {"user_id": "u_123", "metric": "api_calls", "current": 9500, "limit": 10000})
fbf.track("feature.adopted", {"user_id": "u_123", "feature": "analytics"})
fbf.track("nps.submitted", {"user_id": "u_123", "score": 9, "feedback": "Great product!"})

# Payment
fbf.track("payment.failed", {"user_id": "u_123", "amount": 99.0, "currency": "USD", "plan": "Pro"})

E-commerce Events

fbf = ecommerce(api_key="sk_...", project_id="proj_...")

fbf.track("cart.abandoned", {
    "user_id": "u_123",
    "cart_id": "cart_456",
    "items": [{"product_id": "prod_1", "name": "Shirt", "quantity": 2, "price": 29.99}],
    "total_value": 59.98
})

fbf.track("order.placed", {"user_id": "u_123", "order_id": "ord_789", "total_value": 150.0})
fbf.track("order.shipped", {"user_id": "u_123", "order_id": "ord_789", "tracking_number": "TRK123"})

Type Hints

Full type hint support with all events:

from fourbyfour import saas, SaaSClient, TrackResult

fbf: SaaSClient = saas(api_key="sk_...", project_id="proj_...")

result: TrackResult = fbf.track("trial.started", {
    "user_id": "u_123",
    "plan": "Pro",
    "trial_days": 14
})

Error Handling

from fourbyfour import saas, FourbyfourError, AuthenticationError, RateLimitError

fbf = saas(api_key="sk_...", project_id="proj_...")

try:
    fbf.track("payment.failed", {"user_id": "u_123", "amount": 99.0})
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limit exceeded, retry later")
except FourbyfourError as e:
    print(f"API error: {e}")

Documentation

See docs.fourbyfour.dev for full documentation.

License

MIT

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

fourbyfour-0.1.2.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

fourbyfour-0.1.2-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file fourbyfour-0.1.2.tar.gz.

File metadata

  • Download URL: fourbyfour-0.1.2.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for fourbyfour-0.1.2.tar.gz
Algorithm Hash digest
SHA256 39ed68faf19fed7f532d41a4bf1fe9a8821b36c418136665bdf0d2d814979ee0
MD5 6a3366cb07e9cc9df18ed42131529d58
BLAKE2b-256 32101b115e8436956694316792d3388af633d2586cb623723fbdffb4932941ac

See more details on using hashes here.

File details

Details for the file fourbyfour-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: fourbyfour-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for fourbyfour-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4bb06aeff977cce1decbbd25e7079eb73f54a6de8f9c83650752b30adfffaa1a
MD5 94bca43ee3afdba355fa9b860d25d555
BLAKE2b-256 7e29c5ace5ca67577a163a6047813f0e7a7c31c87c554be16549e8f3375a923c

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