Retool apps tutorial: Connect and query data
Learn how to connect a data source and retrieve customer data using queries.
This guide is part of a multi-page tutorial. If you're starting here, consider reviewing the previous steps and following the Retool apps tutorial in sequence.
A resource is a set of user-configured properties that determine how Retool interacts with a data source, such as an API. You create a resource for each data source you want to use with Retool. You can then select the resource when writing a query so you can interact with the data.
1. Generate a mock API with customer data
Use the mock API generator below to generate a fully functional temporary REST API with customer data that you can use.
- Select the Customers sample data set.
- Specify the number of Items that the data set should include.
- Click Generate API to generate the API with sample data.
2. Create a resource query
First, add a resource query to retrieve customer data. Before the query can do this, you must create the necessary resource. You can do this directly from the resource query.
First, click in the left-side vertical toolbar to open the Code tab. In the Page pane, click and select Resource query.
The Resources dropdown contains a list of resources in your Retool organization for which you have access.
3. Create a REST API resource
Retool supports most databases and APIs, and you can use built-in integrations to connect to popular data sources with minimal configuration.
The mock API is a basic REST API with no authentication. To create a resource for it:
- Click the Resource dropdown and select + Create a new resource.
- Select the REST API integration.
- Set the resource name to Sample Customers and then paste the copied API URL into the Base URL field.
- Click Create resource.
4. Retrieve customer data
The resource query updates to perform a GET request with the newly created resource. Click Save & Run to save the resource query and run it. The query then retrieves the list of customers from the API.