Skip to main content

Fidloy Python SDK

Official Python SDK for the Fidloy API.

Install

pip install fidloy-sdk

Quick Start

from fidloy import Fidloy

client = Fidloy(api_key="YOUR_API_KEY")

transactions = client.list_transactions(business_id=2)

for txn in transactions:
    print("ID:", txn.get("id"), "Amount:", txn.get("amount"))

client.close()

base_url is optional and already defaults to the production API.

Simplest 2 Examples

Example 1: Show transactions

from fidloy import Fidloy

client = Fidloy(api_key="YOUR_API_KEY")

for txn in client.list_transactions(business_id=2):
    print(txn.get("id"), txn.get("amount"))

client.close()

Example 2: Show customers

from fidloy import Fidloy

client = Fidloy(api_key="YOUR_API_KEY")

for customer in client.list_customers(business_id=2):
    print(customer.get("id"), customer.get("first_name"), customer.get("phone"))

client.close()

Example 3: Get point balance

from fidloy import Fidloy

client = Fidloy(api_key="YOUR_API_KEY")

balance = client.get_points_balance(business_id=2, customer_id=30)
print(f"Balance: {balance.get('points_balance')} points")

client.close()

Example 4: Validate coupon

from fidloy import Fidloy

client = Fidloy(api_key="YOUR_API_KEY")

result = client.validate_coupon(
    business_id=2,
    code="SUMMER20",
    amount=10000,
    customer_id=30,
    phone="+250788000000",
    email="customer@example.com"
)

if result.get("valid"):
    print(f"Coupon valid! Discount: {result.get('discount_amount')}")
else:
    print(f"Invalid coupon: {result.get('error')}")

client.close()

Retention engine (API v1)

Use with a business API key. business_id is optional when the key is scoped to one merchant.

from fidloy import Fidloy

client = Fidloy(api_key="YOUR_API_KEY")

# Identity + external ID mapping
client.customers.upsert(
    external_customer_id="cus_123",
    first_name="Alex",
    last_name="Dev",
    email="alex@example.com",
)

# Activity signals (idempotent via external_event_id)
client.events.track(
    external_customer_id="cus_123",
    event_type="subscription_renewed",
    external_event_id="evt_unique_1",
    occurred_at="2026-09-30T12:00:00Z",
    amount=49.0,
    properties={"plan": "pro"},
)

# Purchases (external customer id)
client.transactions.create_v1(
    external_customer_id="cus_123",
    amount=12000,
    transaction_date="2026-09-30T12:00:00Z",
    store_name="Online",
)

# Feedback
client.feedback.submit(
    external_customer_id="cus_123",
    rating=4,
    comment="Great service",
)

# Retention snapshot
snap = client.customers.retention("cus_123")
print(snap.get("state"), snap.get("score"), snap.get("reasons"))

# Retention rules (tenant automation config)
rules = client.retention_rules.list()
client.retention_rules.create(
    name="At risk SMS",
    trigger_kind="customer_state",
    trigger_config={"state": "AT_RISK"},
    action_kind="send_sms",
    action_config={"message": "We miss you!"},
)

client.close()

Also Available (Direct Client)

from fidloy_sdk import FidloyClient

client = FidloyClient(api_key="YOUR_API_KEY")
customer = client.create_customer(
    first_name="Alex",
    last_name="Bwana",
    business_id=2,
    phone="+250788000000",
)
print(customer)
client.close()

Main Features

  • API-key authenticated requests
  • Very simple Fidloy facade for beginners
  • Customer-in-business reward history helper methods
  • Customer and transaction creation helpers
  • Points and coupon redemption helpers
  • Point balance checking and point rules listing
  • Coupon validation and code checking
  • Receipt and webhook creation helpers
  • Typed, predictable exceptions
  • Configurable timeout and headers

Core Methods

  • get_rewards_history
  • get_customer_rewards_history
  • create_customer
  • create_transaction
  • create_receipt
  • create_webhook
  • redeem_points
  • redeem_coupon
  • get_points_balance
  • list_point_rules
  • list_point_rules_categorized
  • validate_coupon

Publish to PyPI

Follow PYPI_RELEASE_CHECKLIST.md to configure PyPI Trusted Publisher.

Then publish by creating a GitHub Release for your version tag.

Manual upload (fallback)

python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*

Use a PyPI token when uploading.

Metadata

Release files for fidloy-sdk 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fidloy-sdk 0.1.12
File Size Uploaded
fidloy_sdk-0.1.12.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fidloy-sdk 0.1.12
File Interpreter ABI Platform
fidloy_sdk-0.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 28.5 kB

Release files / fidloy_sdk-0.1.12.tar.gz

Download URL fidloy_sdk-0.1.12.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8a3516bb66b28c7a3c56d8314a37466ddb29a9e6b170043c5dd123615cd12246
BLAKE2b-256 checksum
How to use checksums
4a7e0037291ab7495186b5559e49fc4256a7367cc8946e1ddd189bb1d95184dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / fidloy_sdk-0.1.12-py3-none-any.whl

Download URL fidloy_sdk-0.1.12-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
451a3ecdba1d31e2de682cba3de727f9b24ee982a106b1a8939875dda18132a1
BLAKE2b-256 checksum
How to use checksums
8ffd1d4403b553851312e1afecb6292af1d0adcf2f9e5a5caea027ba0606e54f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release history Release notifications | RSS feed

0.1.13

2 release files

This release

0.1.12 This release

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

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