To get the hang of the Python client quickly and effortlessly you can check out some provided sample notebooks. Each notebook can be executed from top to bottom, and does not require any setup.

Sample Notebooks

Sample notebooks are accessible on

Google Drive.

Notebook Overview

Cells are executed one-by-one by typing Shift+Enter, most commonly used libraries are pre-installed.

All the demo notebooks require python 3.10 or upwards.

Interactive Environments

Jupyter, Google Colab or JetBrains Datalore are interactive environments that make developing and sharing algorithmic code simple and accessible. They allow to work in notebooks, which are documents that contains both code and rich text elements, such as figures, links, equations, and more. Notebooks don’t need any setup and can be shared with others.

Seeing that Colab is a hosted, free tool that supports all requirements including Python ≥3.10, it’s recommended to use Colab.

Installing Packages

From within your interactive environment you can install missing packages via pip in “magic” cells started with an exclamation mark.

# pip is already installed in your interactive environment
!pip3 install ....

All APIs or commands that require authentication can be used through client libraries that hide the tokens, such that notebooks can be shared without sharing personal credentials.

Executing Code

Code can be executed by pressing the play button in the top left corner of the cell, or by pressing Shift + Enter. While the code is running the cell show a spinning icon, and when the code is done the icon is replaced by a number. This number indicates the order in which the cells were executed. The output of the cell is shown below the code.

Authorization

When sharing notebooks it’s important to not share your Tilebox API key by using it directly. Instead, there are two methods to use the Tilebox Python client in interactive environments. Using environment variables, or interactively.

Using environment variables to store your API key
# first define an environment variable "TILEBOX_API_KEY" which contains your API key
import os
token = os.getenv("TILEBOX_API_KEY")

Interactive authorization is possible by using the builtin getpass module. It prompts the user for the API key when running the code, which is stored in memory and again is not shared with other users when a notebook is shared.

Interactively providing your API key
from getpass import getpass
token = getpass("API key:")