Skip to main content
Version: 6

Torizon Platform Services API (Beta)

Introduction​

This article guides you on automating, extending and integrating the Torizon Platform Services features through its REST API. It also brings information about enabling, testing and using the API in our solution.

If you are looking for reference documentation, check our OpenAPI Specification.

Why Use the Torizon Platform Services API​

A REST API (Application Programming Interface) is a set of rules and protocols that allows different software applications to exchange resources with each other over the internet. The Torizon Platform Services API defines the methods, data formats, and authentication mechanisms that enable your application to request and receive data or perform actions from Torizon Platform Services using HTTP requests.

While we provide a comprehensive feature set in our Torizon Platform Services Web UI, you can automate, extend and integrate its features in your solution using Torizon Platform Services API.

  • Automate: most of the tasks executed on the Torizon Platform Services Web UI can be automated and incorporated into any workflow of your product development/maintenance environment, eliminating the need for manual intervention on the web platform.
  • Extend: if you need features not provided in the Web UI platform, you can try implementing them by leveraging the API: filtering information for exhibition according to your product particularities or even conditional updates.
  • Integrate: you can use the API to bring features such as updates, package management and device monitoring to your application or Web UI, giving your own users access to the powerful capabilities of the Torizon Platform Services.

Common use cases:

  • Fleet Management: integrate the Torizon Platform Services features into your existing fleet management platform to have rich insights on the devices, such as installed software packages and device metrics.
  • Domain translation: you can use the expertise of your support team to manage your devices without having to learn Torizon Platform Services namings and UI, incorporating its features in your support platform.
  • CI/CD Workflows: automate the deployment process and integrate it with the build of your application and OS images. While Torizon provides resources for easy automation of OS and application builds with TorizonCore Builder and Docker Containers, these artifacts can be easily deployed across multiple fleets using Torizon Platform Services API.

Torizon Platform Services API Features​

Product Features​

Most of the features available in the Web UI are accessible using the API:

The Torizon Platform Services Web UI is the standard platform to manage your account, repositories and connected applications.

Accounts & Sandbox​

Due to security reasons, it is recommended that you set up a sandbox environment for evaluation and development. You can do this by creating different accounts for sandbox and production. Check our commercial plans to understand services and trial period.

Documentation​

You can learn the API specifications on our Reference Documentation .

To download the OpenAPI specification file, click ./torizon-openapi.yaml:

Download OpenAPI File

Endpoints​

For precise and complete information, check the Reference Documentation.

Check below a summary of useful functionalities available through the endpoints:

Devices

Fleets

Packages

Updates

Metrics

How to Use Torizon Platform Services API​

Preparation​

Get an account on https://app.torizon.io with access to the feature. Check the commercial plans for more information.

1. Create an API Client​

1.1. Enter your Torizon Platform Services account. On the API Client Manager section, click Create API Client:

Create API Client

1.2. Give the API Client a name and a description. Select the API V2 (beta) Client Type:

Name and Type

1.3. Click or select the Client Secret field to copy and use it during your testing and integration procedures. Note that you won't be able to see the secret after closing the form:

Copy Secret

2. Check the API Endpoints​

There are several ways for you to evaluate Torizon Platform Services API:

  • Curl calls: Command-line tool to transfer data between machines using one of many supported protocols (in this case HTTP is relevant). You can easily test the API with curl commands in a Linux terminal.
  • Restish: CLI for interacting with REST-ish HTTP APIs given an OpenAPI Spec. You can use it to automatically generate commands inside Linux Terminal for direct calls to the API endpoints.
  • Postman: Tool to help design, build, test and iterate REST APIs. It allows importing OpenAPI documentation to easily test endpoints.
  • From the application: Using HTTP utilities from your programming language libraries.
  • OpenAPI Generator: Tool that allows the generation of API client libraries (SDK generation), server stubs, documentation, and configuration automatically given an OpenAPI Spec.

The simplest way to check the API endpoint is using our Online Documentation

2.1. Access the authorization form:

Using API Key

2.2. Enter a valid token to get authorization for the API requests. Refer to the Authentication section to learn how to obtain the token:

Entering Credentials or Key

2.3. Execute calls to the API to get examples of the requests.

Try it Out

Execute

3. Integrate Into Your Solution​

Having understood and designed your integration workflow, you can proceed to add calls to Torizon Platform Services API in your solution. Remember, you can use the libraries available from the programming language your project uses and even leverage the SDK generated by tools such as OpenAPI Generator, as mentioned above.

There are important aspects you should evaluate when integrating Torizon Platform Services API into your solution:

  • API Documentation: Understand and comply with request and response formats, authentication requirements, and any other relevant details of the available endpoints.
  • Rate Limits and Throttling: proper handling of your end users will prevent excessive requests to Torizon Platform Services API and potential service disruptions.
  • Versioning and Upgrades: Understand that this API is versioned and consider the impact of future upgrades on your integration.
  • Scalability and Performance: Consider factors such as response times, concurrency, and data volume to ensure Torizon Platform Services fulfill your requirements under different usage scenarios.
  • Data Validation and Formatting: Pay attention to data formats, units of measurement, and any specific constraints specified in the API documentation.
  • Error Handling: properly handling error codes, error messages, and fallback options will help provide a robust end-user experience.

Authentication and Security​

Torizon Platform Services API uses OAuth2 - Client Credential flow. This means you need a token to successfully execute requests to the API.

Get a Token​

Using your Client ID and Secret you can obtain a valid token to execute requests for the API.

Token URL: https://kc.torizon.io/auth/realms/ota-users/protocol/openid-connect/token

This is a request example using curl to get the token:

$ curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=<yourClientId>&client_secret=<yourClientSecret>" \
https://kc.torizon.io/auth/realms/ota-users/protocol/openid-connect/token

Make sure you follow best practices for securely storing credentials. Anyone with access to these credentials can send malicious software to all devices in the repository.

Manage Tokens​

Define the token lifetime during the creation of the API Client, according to your use case requirements. For instance, in CI/CD environments you should generate the token just before the API calls, using the securely stored keys. After the pipeline is completed, you don't need the token, so it can have a short lifetime.

Setting the Lifetime

If needed, delete a Client on the Torizon Platform Services Web UI, under the section My Account > API Client Manager. This will immediately invalidate all the tokens generated with this Client:

Deleting Keys

CI/CD​

Torizon IDE Extension 2 brings built-in actions that use the Torizon Platform Services API to deploy your OS and application packages to devices or fleets. The provided templates already come with a JSON schema for speeding up the configuration of your GitLab and GitHub CI environment. You can use this as an example to implement automation on other CI/CD environments.

When you create a project using one of the Templates, the Torizon IDE extension creates the configuration files for GitHub and GitLab. If you want to learn how to implement a CI/CD workflow with Torizon IDE Extensions, check the Torizon IDE Extension 2 CI Integration documentation.

Standards & Architecture​

REST​

While REST is not a standard or protocol, it is an important set of architectural constraints that are followed by modern APIs. Being a widely adopted architecture, it allows for easy understanding and fast integration. Torizon Platform Services API is implemented as a REST-like API, which means that the main constraints from REST architecture are followed.

OpenAPI​

As defined on OpenAPI Website:

The OpenAPI Specification is a specification language for HTTP APIs that provides a standardized means to define your API to others. You can quickly discover how an API works, configure infrastructure, generate client code, and create test cases for your APIs.

Torizon Platform Services API complies with OpenAPI specifications, also contributing to its easy and fast integration capabilities.



Send Feedback!