Skip to main content
Version: 1.1.0

Python SDK

Installation

The Alloy Python SDK can be easily installed using pip:

pip install alloy-python-sdk

Usage

The package needs to be configured with your account's API key, which is available in the Alloy Dashboard under settings. You must supply the API key with each instantiation of the module.

To use thie SDK with Alloy's Unified API, use the code snippet below:

Python
from alloy_python.uapi import UAPI
uapi = UAPI('YOUR_API_KEY')

Creating a User

To make API calls to Unified API, you must first create a user. To create a user, call the User.create_user() method as seen below. You must pass a unique username.

Python
user_data = {'username': 'john@example.com'}
user_data = user.create_user(user_data)

Before you make your first API call, you will need to obtain a connectionId. A connectionId represents the unique identifier of an app you plan to make API calls to. You can obtain a connectionId by using the frontend SDK. Read more here.

Making requests to Alloy Unified API's SDK

Once you have a connectionId, you can start making calls to Alloy Unified API. See the example below for making a request to the Commerce Unified API:

Python
from alloy_python.uapi.commerce import Commerce

commerce = Commerce('YOUR_API_KEY')
list_customers_response = commerce.list_customers()

Once you have a connectionId, you can start making calls to Alloy Unified API. See the example below for making a request to the Commerce Unified API:

Python
from alloy_python.uapi.commerce import Commerce

commerce = Commerce('YOUR_API_KEY')
list_customers_response = commerce.list_customers()