Skip to main content

No project description provided

Project description

Rulebricks – Python SDK

pypi

Documentation

API reference documentation is available here.

Installation

Add this dependency to your project's build file:

pip install rulebricks
# or
poetry add rulebricks

Configuration

Before using the SDK, configure your API key. You can find your API key in your Rulebricks Dashboard.

import rulebricks as rb

# Replace 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' with your actual API key
rb.set_api_key("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")

Basic Usage

Use the SDK to interact with the Rulebricks API in a synchronous manner is incredibly simple.

Here's an example of how to use the SDK to solve a rule:

import rulebricks as rb

# Set the API key
rb.set_api_key("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")

result = rb.sync_api.rules.solve(
    slug="tJOCd8XXXX",
    request={
        "customer_id": "anc39as3",
        "purchase_history": ["t-shirt", "mug"],
        "account_age_days": 4,
        "last_purchase_days_ago": 3,
        "email_subscription": False
    }
)

print(result)

Asynchronous Usage

For asynchronous API calls, access methods via the async_api attribute.

This allows you to leverage Python's asyncio library for non-blocking operations:

import rulebricks as rb
import asyncio

# Set the API key
rb.set_api_key("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")

async def main():
    async_result = await rb.async_api.rules.solve(
        slug="tJOCd8XXXX",
        request={
            "customer_id": "anc39as3",
            "purchase_history": ["t-shirt", "mug"],
            "account_age_days": 4,
            "last_purchase_days_ago": 3,
            "email_subscription": False
        }
    )
    print(async_result)

if __name__ == "__main__":
    asyncio.run(main())

Beta status

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version in your pyproject.toml file. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Feedback and Contributions

Feedback is vital as we continue to improve the SDK and add more features. Please report any issues or suggest improvements through our GitHub issues page. Contributions to the SDK are welcome via pull requests.

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

rulebricks-0.1.3.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

rulebricks-0.1.3-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file rulebricks-0.1.3.tar.gz.

File metadata

  • Download URL: rulebricks-0.1.3.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1061-azure

File hashes

Hashes for rulebricks-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8552d94c6b5f449eebbc60396ad8ff1fa6b00156c74c71fed2bed1c8bf049115
MD5 f88ac49c1dfae7b7179fccb0f9e7910b
BLAKE2b-256 8cbb4193254c8f8394c1550e5306cc4324c1e9b6d0524708e704a8b50fec2699

See more details on using hashes here.

File details

Details for the file rulebricks-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: rulebricks-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1061-azure

File hashes

Hashes for rulebricks-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 570bb53c376b03354108e262a0e0ddbaf4ee311ffaf1b435f8434f2102fe43f2
MD5 00b9eee3dd5a29aa06cb7eedfd4fd5f2
BLAKE2b-256 78e3651db31b510ef3693141402314286aa7cb701ffde7bcb75654a9d8213b64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page