Install and Setup the Stax Python SDK

Learn how to install and setup the Stax SDK

Article Tags
On This Page
Before You BeginInstallation and SetupUsageSee also

The Stax Python SDK allows you to leverage automation functionality within Stax so that you can increase the speed of your development and reduce inefficiencies. The SDK provides you with all the tools you need to interact with the Stax API, including code examples for making requests against the Stax API and code pipeline integration examples for end to end automation. Authenticating to the SDK is made simple with Stax API Token, which are security credentials that allow users to access the Stax API.

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)
  • The permissions assigned to your API Token will depend on the role assigned to the token (see API Token Permissions)
  • Estimated completion time: 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.

  1. 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 Organisation:

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 Organization
accounts = StaxClient("accounts")
response = accounts.ReadAccounts()
print(response)

Follow the usage example in the README.md and review the example folder to learn how to authenticate Stax API operations using the SDK.

You can find additional SDK troubleshooting and support guides here.

See also