Writing API Tasks
API Tasks verify and provide a transcript for the execution of web services' API calls.
Last updated
Was this helpful?
API Tasks verify and provide a transcript for the execution of web services' API calls.
Last updated
Was this helpful?
With API Tasks, the Truebit Verify Hub proxies requests to an external API endpoint. API Tasks are dispatched and executed only by the Truebit Verify Hub, which secures sensitive data such as API credentials and allows for execution of a single, audited API call. In a role reversal, Truebit Verify Nodes then audit the network transaction originated by the hub, providing full transparency for each call.
API Tasks are accessed via a built-in web services interface provided by the Truebit Verify Hub, and can be called by any application using HTTP. Each API Task execution is recorded in a transcript.
There are several important considerations when defining an API Task:
OpenAPI Schemas: Truebit Verify uses the as the basis for the API Manifest that defines the interaction with an external HTTP-based API. The OpenAPI schema describes the servers, data formats, validation rules, etc. for a given API endpoint. The Truebit Verify Hub will validate all API Task calls using the OpenAPI schema before executing a network request. Many APIs already provide an OpenAPI schema as part of their documentation — and this can serve as a good starting point for defining your API Manifest. Truebit supports OpenAPI Schema v3 and later.
Credentials: Many APIs require authentication credentials to be provided as part of the network request. We currently support basic auth, AWS key, and custom HTTP Header
credentials. The Truebit Verify CLI allows you to upload encrypted credentials to the Truebit Verify Hub, where they will be securely stored in their encrypted state. When possible, we recommend obtaining credentials specifically scoped to the authorization requirements of your API Task, and rotating credentials in accordance with your team's security practices.
No Determinsim Requirement: Truebit Verify uses a different verification strategy for APIs which does not require deterministic outputs to be provided by the API.
The provides an OpenAPI schema as an API Manifest for the relevant APIs that will be proxied by Truebit Verify. We recommend using a tool like to help develop the OpenAPI schema used in your manifest. If using a pre-existing OpenAPI schema provided by an API publisher, we recommend reviewing the contents of the schema to remove any unneeded endpoints and/or add any additional validation rules as needed by your API Task.
OpenAPI Specification (formerly Swagger Specification) is an API description format for REST APIs. An OpenAPI file allows you to describe an entire API, including:
Available endpoints (/users) and operations on each endpoint (GET /users, POST /users)
Operation parameters Input and output for each operation
Authentication methods
Contact information, license, terms of use and other information.
It’s a standard widely used
Most of the APIs will have an OpenAPI specification ready to be used
Native support of validations
Can be customized to include/exclude fields
Can include credentials or other definitions (using extensibility mechanisms)
The Task Authorization process is an optional step, but it becomes mandatory when the Task Requester has registered the task. This step allows the Task Developer to define who has permission to execute the deployed task.
The creates a new API task by calling the command from the using the defined manifest as the input parameter. As a result, a new will be returned.
The tests the API task using the command from the .
When the API Task is ready, the deploys the task using the command from the .
When the API Task is deployed, you can submit the API Authentication method and credentials (only if applies) by calling the command within the
Click Here to see more information about the process.
The executes the task using the from the Truebit API.
Click to view the list of pre-developed Truebit Tasks created for you to start getting familiar with the task development