Getting started (with Python)
Nextspace provides a Python library to interact with the Nextspace API.
The library is available on PyPi and can be installed using pip. Page link
It is deliberately lighter than the web library and does not aim to match it feature for feature. What is covered is Entities and Entity Types, Data Lab queries and actions, Change Sets, historic data, Client Files including Value Maps, Scenarios, Sessions, Accounts and Pending Actions.
Setup
This library needs Python 3.8 or above. That floor exists to meet the interpreters partner installations actually ship with rather than to track upstream, so anything newer is fine.
To install, simply use the following command:
The base install pulls in requests and nothing else. Reading a Value Map needs real array and image handling, which is too heavy to put on an install that only wants the API models, so it lives behind an extra. Install it now if you plan to analyse Value Maps, rather than finding out at the point of decoding a frame.
Everything else works without it. Importing the Value Map module on a base install succeeds too, and only the decoding fails, with a message naming the command above. See FAQ: Analyzing Value Maps for what it does.
Verify the installation by importing the library in your Python script.
You will be using two API instances for your communication with the Nextspace API. The Guardian API and the Bruce API.
The Guardian API is used for authentication and account management, while the Bruce API is your personal API for your account.
Here is how you create an instance of each API:
The session_id accepts either a session token from a login or a long-lived access token. See Authentication for both.
Identify your account with account_id and let the library resolve where its API lives. That lookup happens once, through Guardian, and it is what makes the same code work against any account in any region without changing a url.
What is available
Almost everything is reachable off the top-level module. The exception is noted below.
ClientFileValueMap is the one thing not exported from the top level, because it belongs to the optional extra. Import it by path:
The command line
The library is not only importable. Installing it also installs a bruce command, so the same models drive a command line that configures once and then answers one-off questions without a script: who a credential is, what it can reach, what an Account holds, and seeded end-to-end tests against an installation. There is a public Docker image too, for a machine with no Python on it.
Anything configured there is read by the library as well, so a script picks up the same defaults. See CLI: Getting started and CLI: Docker.