Perform REST API requests | Retool Docs (2024)

Learn how to connect and query REST APIs in Retool.

You can make requests to any REST, GraphQL, or SOAP API. You can also use custom authentication to interact with private REST or GraphQL APIs, such as internal APIs.

Connect to a REST API

You can connect to a REST API in two ways:

  • Create a resource to connect the API to Retool. This allows you to configure the API once so it's available as a resource anywhere in Retool. You can also configure additional authentication options, if required.
  • Use the built-in RESTQuery (restapi) resource and manually write API requests. This is useful if you only need to query an API temporarily and won't use it elsewhere. You must manually define API endpoints, authentication options, and any other parameters in each query.

Query a REST API

You can select a REST API resource in your Retool organization from the Resource field in the query editor. After selecting the resource, the configured API endpoint appears in the URL field. You can then specify the parameters and other options in the available fields.

To interact with a REST API that is not configured as a resource, select the RESTQuery (restapi) resource from the Resource field in the query editor. You manually define the API endpoint and other parameters in the available fields.

Action types

Retool supports the following request methods for REST APIs:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE

You specify the method to use by selecting an option in the Action type dropdown.

Queries using GET methods automatically run whenever any of their parameters change by default (e.g., input field value changes). Queries using POST, PUT, PATCH, and DELETE methods must be manually triggered by default. You can choose whether a query should run automatically or manually in the query editor; select Run query only when manually triggered or Run query automatically when inputs change in the dropdown menu.

Path and URL parameters

You can include additional path and URL parameters to any API request in the query editor. Path parameters can be included directly in your URL, and URL parameters can be added in the URL parameters section. Path and URL parameters can also read from values within curly braces ({{ }}).

When you specify URL parameters, Retool automatically appends them to the endpoint URL. Conversely, Retool detects any URL parameters added to the endpoint URL and populates the URL parameter fields.

The following example shows a GET request which reads the currently selected row of a Table component and passes it as a URL parameter with a key of id.

Perform REST API requests | Retool Docs (1)

Request headers

For REST APIs configured as a resource, you can set request headers on the resource's configuration page. Headers set on resource configuration pages are always included on any requests using that resource.

You can also add headers to any request using the Headers fields in the query editor. These headers are included in addition to any already configured for the resource.

note

Retool sanitizes any headers with keys that contain authorization, key, or password.

Request bodies

You can send requests with JSON, raw, x-www-form-urlencoded, Form data, or binary bodies.

JSON

To construct a JSON request body, select JSON in the Body section of the query editor. You can then construct a JSON object using the key-value fields. A Content-Type: application/json request header is automatically added to requests using JSON body types. The JSON body also supports nested objects within a single key.

Perform REST API requests | Retool Docs (2)

Raw

To send a request body without modifications, select Raw in the Body section of the query editor. For example, if you use the Raw body type and manually add a Content-Type: application/json header, you can send more complex JSON objects.

Perform REST API requests | Retool Docs (3)

You can include JSON in raw request bodies with some additional formatting. You can either wrap the entire body in curly braces to construct the object dynamically or manually format values in the following ways:

  • String values: Wrap values in curly braces {{ }} with double quotes.
  • Boolean or number values: Do not wrap curly braces {{ }} with double quotes.
  • Objects and arrays: UseJSON.stringify() to convert to string values.

Perform REST API requests | Retool Docs (4)

x-www-form-urlencoded

To send URL-encoded data, select x-www-form-urlencoded in the Body section of the query editor. Retool adds Content-Type: application/x-www-form-urlencoded to the request header.

Form data

tip

See the guide to handling files in Retool to learn how Retool represents files.

To send form data in your request, select Form data in the Body section of the query editor. A Content-Type: multipart/form-data header is added to the request.

To upload a file using form data, set a key to file, select the File upload type, and set the value to the file to upload. The .value property on File Input, File Button, and File Dropzone components has the correct schema for file uploads. For example, set value to {{ fileInput.value }} to upload a file as form data.

Binary

To send data that can't be formatted as form data—for example, an image, audio, or video—select binary in the Body section of the query editor.

The following examples passes the File button upload value as binary data.

Perform REST API requests | Retool Docs (5)

Cookies

You can configure REST API resources to use cookies-based authentication for REST API resource support cookies for API authentication. You can also add cookie headers to API requests using the Cookies key-value field in the query editor.

Perform REST API requests | Retool Docs (2024)

FAQs

How to create API documentation for REST API? ›

Documenting your REST API like a Pro
  1. Planning your REST API Documentation. ...
  2. Decide on your most important sections. ...
  3. Avoid jargon and ensure the document is consistent throughout. ...
  4. Include Interactivity. ...
  5. Writing for an Entry-Level Audience.
Mar 7, 2024

How to write a REST API request? ›

The request must include:
  1. An X-Tableau-Auth header with the authentication token that was returned in the Sign In call.
  2. A Content-Type header set to text/xml .
  3. A request body with an XML or JSON block that includes the changes for the existing resource. The XML or JSON block is defined by an XML schema.

How to use APIs in Retool? ›

You can select a REST API resource in your Retool organization from the Resource field in the query editor. After selecting the resource, the configured API endpoint appears in the URL field. You can then specify the parameters and other options in the available fields.

How do I run REST API commands? ›

Specify the user name with which to run the command. Running a command with the REST API requires the same permissions as using the web interface. Specify the password with which to run the command. Optionally, specify a file name to store the result of the command.

How do I document an API request? ›

How to Write API Documentation
  1. Understand the API's users.
  2. Map out the user journey.
  3. Start with the fundamentals.
  4. Add code examples.
  5. List your status codes and error messages.
  6. Write and design for humans.
  7. Keep your documentation up-to-date.
Sep 26, 2023

What is an API documentation example? ›

API documentation is a comprehensive guide that explains how to effectively use and integrate with an API, providing essential information such as endpoints, request/response formats, authentication methods, and example code.

How to automate using REST API? ›

With the REST interface, the four basic operations are crucial to achieve API Test Automation using Rest Assured. The 4 basic operations Create, Read, Update, and Delete (CRUD) are performed via the POST, GET, and PUT methods. GET: To retrieve or read the server's data. POST: It is used to add a resource to the server.

How to deploy REST APIs? ›

Create a deployment
  1. In the APIs navigation pane, choose the API you want to deploy.
  2. In the Resources pane, choose Deploy API.
  3. For Stage, select from the following: To create a new stage, select New stage, and then enter a name in Stage name. ...
  4. Choose Deploy.

What is REST API with example? ›

REST APIs communicate through HTTP requests to perform standard database functions like creating, reading, updating and deleting records (also known as CRUD) within a resource. For example, a REST API would use a GET request to retrieve a record. A POST request creates a new record.

How REST API works step by step? ›

These are the general steps for any REST API call:
  1. The client sends a request to the server. ...
  2. The server authenticates the client and confirms that the client has the right to make that request.
  3. The server receives the request and processes it internally.
  4. The server returns a response to the client.

What is the difference between API and REST API? ›

REST APIs use the HTTP protocol to send and receive data. Web APIs, on the other hand, rely on multiple communication protocols like SOAP, XML-RPC, and JSON-RPC. REST APIs are the most widely used for data integration, facilitating efficient data transfer.

How to auto generate API documentation? ›

Autogenerating API documentation from OpenAPI
  1. Step 1: Generate your OpenAPI spec. The first step is to get an OpenAPI spec for your APIs. ...
  2. Step 2: Create a Mintlify docs deployment. ...
  3. Step 3: Configure your OpenAPI in the docs. ...
  4. Step 4: Autogenerate your endpoints. ...
  5. Step 5: Showcase your API. ...
  6. Wrapping-Up:
Sep 15, 2023

How do you document restful web services? ›

  1. 1) Plan for the Documentation. You should plan well before commencing the documentation process. ...
  2. 2) Add Fundamental Sections. There are a number of sections that are mandatory for great API documentation. ...
  3. 3) Maintain Consistency and Avoid Jargon. ...
  4. 4) Add Interactive Examples. ...
  5. 5) Write for Entry Level.
Jan 11, 2022

How to make Postman API documentation? ›

Create new documentation for an API
  1. Select APIs in the sidebar and select an API.
  2. On the API's overview, next to Collections, select + and select Generate from definition.
  3. Select the checkbox if you want Postman to suggest updates for the collection when the API definition changes.
Sep 23, 2023

How do I create an open API document? ›

You can document and build OpenAPIs in several ways:
  1. Specify OpenAPI annotations in Java code to augment and document an application.
  2. Use a text editor to document the API with OpenAPI tags and then place the completed openapi. yaml, openapi. yml, or openapi. ...
  3. Use the io. swagger. oas.

Top Articles
Walmart SURREY (SW) | Delta, BC
GuidedResearch:Why Can't I Find the Record - Netherlands Deaths
Fan Van Ari Alectra
Usborne Links
سریال رویای شیرین جوانی قسمت 338
Soap2Day Autoplay
Kagtwt
Cars For Sale Tampa Fl Craigslist
Craigslist Estate Sales Tucson
Unit 1 Lesson 5 Practice Problems Answer Key
1Win - инновационное онлайн-казино и букмекерская контора
Trini Sandwich Crossword Clue
OpenXR support for IL-2 and DCS for Windows Mixed Reality VR headsets
Truck Toppers For Sale Craigslist
10 Free Employee Handbook Templates in Word & ClickUp
Cbs Trade Value Chart Fantasy Football
Painting Jobs Craigslist
How to find cash from balance sheet?
800-695-2780
Connect U Of M Dearborn
Mikayla Campinos Laek: The Rising Star Of Social Media
Concordia Apartment 34 Tarkov
Sussur Bloom locations and uses in Baldur's Gate 3
Dragonvale Valor Dragon
Cain Toyota Vehicles
Bellin Patient Portal
Does Hunter Schafer Have A Dick
Violent Night Showtimes Near Amc Dine-In Menlo Park 12
Times Narcos Lied To You About What Really Happened - Grunge
Log in to your MyChart account
Spirited Showtimes Near Marcus Twin Creek Cinema
Club Keno Drawings
Craigslist Texas Killeen
123Moviestvme
Gwen Stacy Rule 4
School Tool / School Tool Parent Portal
Restored Republic December 9 2022
Natashas Bedroom - Slave Commands
USB C 3HDMI Dock UCN3278 (12 in 1)
How much does Painttool SAI costs?
Topos De Bolos Engraçados
Beaufort SC Mugshots
Coroner Photos Timothy Treadwell
[Teen Titans] Starfire In Heat - Chapter 1 - Umbrelloid - Teen Titans
Child care centers take steps to avoid COVID-19 shutdowns; some require masks for kids
The Machine 2023 Showtimes Near Roxy Lebanon
Shannon Sharpe Pointing Gif
Is My Sister Toxic Quiz
Unpleasant Realities Nyt
Wild Fork Foods Login
Sdn Dds
Olay Holiday Gift Rebate.com
Latest Posts
Article information

Author: Duane Harber

Last Updated:

Views: 5722

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Duane Harber

Birthday: 1999-10-17

Address: Apt. 404 9899 Magnolia Roads, Port Royceville, ID 78186

Phone: +186911129794335

Job: Human Hospitality Planner

Hobby: Listening to music, Orienteering, Knapping, Dance, Mountain biking, Fishing, Pottery

Introduction: My name is Duane Harber, I am a modern, clever, handsome, fair, agreeable, inexpensive, beautiful person who loves writing and wants to share my knowledge and understanding with you.