Connect to OpenAPI

Learn how to connect your OpenAPI API to Retool.

1. Connecting to an OpenAPI spec in Retool

Adding your OpenAPI server as a resource

Create a new resource in Retool and select "OpenAPI" as the type.

Enter a name for the resource and the url for the api spec in the "Specification URL" field. Depending on how authentication is set up for your API, you may need to enter URL parameters or headers, or set the method via the "Authentication" dropdown.

See here for more details on authentication.

Resources > Add > OpenAPI

Once you have entered your spec URL you can click "Test Connection" to validate that the spec can be reached and parsed by Retool's API server. The spec will also need to be reachable from your browser when used to build queries for apps.

2. OpenAPI Queries

You can now select your newly-created OpenAPI resource from the Resource dropdown when creating queries in your Retool apps.

Endpoints

The OpenAPI spec will define all the available endpoints. You can select the endpoint you'd like to call from the dropdown. Documentation will be pulled from the spec and displayed in the query editor.

Query Parameters and Variables

For each endpoint, Retool's query editor will parse the spec and display inputs based on the request parameters that are listed. For example, if the parameter is listed as an array of enums the query editor will display a multi-select UI.

Objects in the request parameters are expanded to have the appropriate keys and arrays of objects can be built in the editor.

Dynamic parameters in an OpenAPI query

In the cases where you want to use JavaScript in the query body and reference other inputs, you can switch from the standard input UI to a dynamic one with the "fx" button and return the appropriate JSON for that endpoint or object.

You can display the results of OpenAPI queries as with any other query in Retool.

Templates using OpenAPI

You can explore a number of templates that use OpenAPI in the Retool product.

Other helpful content

OpenAPI sample specs