API Calls

1. Description

Once you have completed the steps in the introduction to the SDK for Developers‍ article,‍ you're ready to use the SDK. Below is a list of the possible command lines with their intended use. For additional information on each call, see the API reference documentation.

2. List of commands

Get all the projects available

>>> projects = sdk.projects.search(limit=100)

Get the missions of a project

>>> my_project = sdk.projects.search(filter={'name': {'$eq': 'My_project'}})[0]
>>> missions = sdk.missions.search(filter={'project': {'$eq': my_project.id}})
>>> my_mission = missions[0]
>>> datasets = sdk.datasets.search(filter={'mission': {'$eq': my_mission.id}})

Explore the dataset properties

To print some properties of a dataset: 

>>> my_dataset = datasets[0]
>>> print("Name: {}".format(my_dataset.name))
>>> print("Type: {}".format(my_dataset.type))
>>> print("Creation date: {}".format(my_dataset.creation_date))

Some dataset properties depend on its type (image, raster, mesh, pcl, vector, file). You can list all the available properties for a dataset with:

>>> dir(my_dataset)

To look for the files related to a dataset, you can list the dataset components:


Download a dataset component

To download a dataset component in the current directory:

>>> component = my_dataset.components[0]
>>> sdk.datasets.download_component(dataset=my_dataset.id,
...                                 component=component.get("name"))

Create a new dataset

To create a new file dataset related to a project:

>>> new_dataset = sdk.datasets.create_file_dataset(name='My file dataset',
...                                                project=my_project.id)

And upload a file:

>>> file_to_upload = "/replace/with/a/file_path.ext"
>>> sdk.datasets.upload_file(dataset=new_dataset.id,
...                          component='file',
...                          file_path=file_to_upload)

Add a tag

To add a tag on the dataset created:

>>> my_tag = sdk.tags.create(name='My tag',
...                          project=my_project.id,
...                          type='dataset',
...                          target=new_dataset.id)

To delete the tag:

>>> sdk.tags.delete(my_tag.id)

Add a comment

To add a comment on this dataset:

>>> my_comment = sdk.comments.create(text='This is my first dataset',
...                                  project=my_project.id,
...                                  type='dataset',
...                                  target=new_dataset.id)

To mark all the comments of this dataset as read:

>>> sdk.comments.mark_as_read(project=my_project.id,
...                           type='dataset',
...                           target=new_dataset.id)

Add an annotation

To add an annotation to a project. For example, one whose geometry is the bounding box of the project:

>>> a = sdk.annotations.create(project=my_project.id,
...                            geometry=my_project.real_bbox,
...                            name='Project bounding box',
...                            description='Bounding box around the project')

This annotation can be deleted with:

>>> sdk.annotations.delete(a.id)