up42 class

Use elementary functionalities of the SDK.


Overview

The up42 class is the base library module imported to Python. It provides the elementary functionality that isn’t bound to a specific class of the UP42 structure.

Authentication

authenticate()

The authenticate() function allows you to access UP42 SDK requests.

ArgumentOverview
cfg_fileUnion[str, Path]
The file path to the JSON file containing the username and password.
usernamestr
The email address used for logging into the console.
passwordstr
The password used for logging into the console.
Examples with authenticate()

Python

    # Authenticate directly in the code

up42.authenticate(
    username="<your-email-address>",
    password="<your-password>",
)

# Authenticate in a configuration file

up42.authenticate(cfg_file="config.json")

  

Logging

tools.settings()

The tools.settings() function allows you to enable logging.

ArgumentOverview
logbool
Determines logging enabling:
  • True: enable logging.
  • False: disable logging.
The default value is True.
An example with tools.settings()

Python

    up42.tools.settings(log=True)

  

Credits

get_credits_balance()

The get_credits_balance() function returns your account balance, in credits. The returned data type is dict.

An example with get_credits_balance()

Python

    up42.get_credits_balance()

  

Geometries

get_example_aoi()

The get_example_aoi() function returns an example AOI. The returned data type is Union[dict, GeoDataFrame].

ArgumentOverview
locationstr
A defined location. The allowed values are as follows:
  • Berlin
  • Washington
The default value is Berlin.
as_dataframebool
Determines how to return the information:
  • True: return DataFrame.
  • False: return JSON.
The default value is False.
An example with get_example_aoi()

Python

    up42.get_example_aoi(
    location="Washington",
    as_dataframe=True,
)

  

read_vector_file()

The read_vector_file() function allows you to upload your geometry from a vector file. The returned data type is Union[dict, GeoDataFrame].

ArgumentOverview
filenamestr
The file path to the vector file containing the geometry. The default value is aoi.geojson.
as_dataframebool
Determines how to return the information:
  • True: return DataFrame.
  • False: return JSON.
The default value is False.
An example with read_vector_file()

Python

    up42.read_vector_file(
    filename="/Users/max.mustermann/Desktop/aoi.geojson",
    as_dataframe=True,
)

  

Webhooks

get_webhook_events()

The get_webhook_events() function returns all available webhook events. The returned data type is dict.

An example with get_webhook_events()

Python

    up42.get_webhook_events()

  

create_webhook()

The create_webhook() function allows you to register a new webhook in the system. The returned data type is Webhook.

ArgumentOverview
namestr / required
The name of the webhook.
urlstr / required
The URL of the webhook.
eventslist[str] / required
A list of events that trigger the webhook. The allowed value is order.status.
activebool
Whether this webhook should be active after the update:
  • True: webhook is active.
  • False: webhook isn’t active.
The default value is False.
secretstr
The secret used to generate webhook signatures.
An example with create_webhook()

Python

    up42.create_webhook(
    name="new-webhook",
    url="https://receiving-url.com",
    events=["order.status"],
    active=True,
    secret="QWZTFnMEXhqZKNmu",
)

  

get_webhooks()

The get_webhooks() function returns all registered webhooks for this workspace. The returned data type is list[Webhook].

ArgumentOverview
return_jsonbool
Determines how to return webhooks:
  • True: return JSON.
  • False: return webhook class objects.
The default value is False.
An example with get_webhooks()

Python

    up42.get_webhooks(return_json=False)

  

A button link with the "View repository" text on it