Skip to main content

Web app tutorial: Connect a data source

Learn how to connect your data source by creating a resource.

The first step in building a Retool app is connecting your data source. Retool supports most databases and APIs, and you can use built-in integrations to connect to popular data sources with minimal configuration. You connect a data source by creating a resource in Retool. This guide uses a REST API as the resource.

1. Generate an API and sample data for your app

To work through the tutorial, you'll use Retool's API generator (embedded below) to create a test REST API with some sample data. When building your own apps, you'll often use an existing data source.

Click the Generate API button below and save the Endpoint URL. This generates a data set that includes user IDs, names, email addresses, and blocked status.

2. Create a resource to connect your data source

Navigate to the Resources tab from the Retool homepage and create a new REST API resource. Make sure to paste the endpoint URL from the previous step in the Base URL field.

If this is your first time using Retool, you'll see a prompt for creating an app after saving the resource. Go ahead and create an app and name it User management. If you don't see a prompt, navigate to the Apps tab in Retool and create an app named User management.

3. Write a test query

Queries are covered in more detail later, but it's a good idea to run one now to verify the connection to your resource. When you created the app, Retool automatically added query1 to it. Navigate to this query and rename it to getUsers.

You can see that the resource you just added is selected, and that the query sends a GET request to your API. Click Run to verify the query works. You'll see a success message and a JSON response with your data.

Wrap up

Now that you have a resource you can access, it's time to start building your UI.

You can test your knowledge below or move on to the next lesson.