Skip to main content

Getting Started with the Stax Python SDK

If you haven't already, learn about the Stax SDK for Python here.

Before You Begin

  • Ensure you have access to a Stax API Token Access Key and Secret Key (see how to create a Stax API Token)

  • Check your API Token role - the permissions for your API Token will depend on the role assigned to the token (see API Token Permissions)

  • Estimated time to complete: 5 minutes

Prerequisite

Ensure you have Python 3.6 or higher installed.

You can check the version of Python by running the following command:

python --version

Installation and Setup

To use the Stax Python SDK with your existing project, perform the following steps:

  1. Install the Stax Python SDK using Pip:

    pip install staxapp

    This will install the Stax Python SDK and its dependencies.

  2. Configure environment variables:

    export STAX_REGION=<your_stax_region> #Your Stax console base URL eg au1.staxapp.cloud
    export STAX_ACCESS_KEY=<your_access_key> #The Stax API Token Access Key
    export STAX_SECRET_KEY=<your_secret_key> #The Stax API Token Secret Key

Usage

The following code snippet can be used to read accounts within your Stax tenancy:

import os

from staxapp.config import Config
from staxapp.openapi import StaxClient

Config.access_key = os.getenv("STAX_ACCESS_KEY")
Config.secret_key = os.getenv("STAX_SECRET_KEY")

# Read all accounts within your Stax tenancy
accounts = StaxClient("accounts")
response = accounts.ReadAccounts()
print(response)

Follow the usage example in the README.md and review the example directory to learn how to authenticate Stax API operations using the SDK. You can find additional SDK troubleshooting and support guides here.