NAV Navbar
python swift java javascript

Select Your Language

Introduction

Welcome to the Terrene Docs!

We have language bindings in Python, Python, Swift (iOS), and Java (Android)! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

Install Terrene’s SDK

pip install terrene
npm install terrene
//todo
//todo

You can view a list of Terrene’s SDKs on our public git group

Authentication

Terrene’s SDK allows you to use multiple authorization methods at the same time with different resources.

Username and Password Authentication

To authorize, use this code

from terrene.core.auth import UserPassCredentials

# create a credentials object
credentials = UserPassCredentials(
  "<username>",
  "<password>"
)
//todo
//todo
//todo

This method allows you to use the same username and password from Terrene’s portal to authorize the Terrene’s SDK.

Collectors

Create a Collector Management Client

from terrene.apps.collectors import CollectorManagementClient

# create a collector management client
collector_management_client = CollectorManagementClient(
  credentials  # created using one of the authentication methods
)
//todo
//todo
//todo

A client management client is authorized to read/write from/to a set of collectors that satisy one of the following conditions:

Get All Collectors

# a way to query the returned collectors
paramaters = {
  'shards': 2
}

# collector_management_client created in the previous step
collector_management_client.collectors.list(
  paramaters
)
//todo
//todo
//todo

Returns a list of all collectors accessible to a collector management client

Parameter Type
name string e.g. ‘iphone app data’
owners_email string e.g. 'me@example.com’
contributors_email string e.g. 'me@example.com’
region string e.g. 'eastus’

Get a Single Collector

# collector_management_client created in the previous step
collector = collector_management_client.collectors.get(
  "<object_id>"  # object_id of the collector
)
//todo
//todo
//todo

Retrieves a single collector object by it’s object_id if it is accessible to the collector_management_client

Write to a Collector

# data to be written to the collector
my_dict = {
  "item1": 1,
  "items": [
    1,
    2,
    3,
    4
  ],
  "item3": {
    "item1": "data"
  }
}

# collector created in the previous step
collector.write(my_dict)
//todo
//todo
//todo