Python

Use our python package to simplify the integration

Installation

To get started with Refir, you can install it using pip:

pip install my-python-package

Configuration

Before using Refir, you need to configure it with your API key. You can do this as follows:

from refir import Refir

refir = Refir()
refir.configure({"api_key": "your-api-key"})

Usage

Adding a User

You can use Refir to add a user to your referral program. The following example demonstrates how to do this:

const user = {
user = {
  "userId": "unique-user-id",
  "name": "John Doe",
  "email": "johndoe@example.com",
}

success = refir.add_user(user)

if success:
  print("User added successfully.")
else:
  print("Failed to add user.")

Getting a User by ID

You can retrieve a user's referral code by their unique ID using Refir. Here's an example of how to do it:

user_id = "unique-user-id"

referral_code = refir.get_user_by_id(user_id)

if referral_code:
  print(f"User's referral code: {referral_code}")
else:
  print("Failed to get user referral code.")

Error handling

Refir provides basic error handling for API requests. If an error occurs during an API request, an error message will be logged to the console, and the function will return false. You can customize error handling to suit your application's needs.

Last updated