With Appsmith, you can connect to a wide range of tools and platforms. If you want connect to an API or if there isn't a native integration with a datasource on Appsmith, you can connect through the REST API interface.
If the API is protected by an authentication mechanism that requires a standard set of headers or parameters that need to be sent with every request, you can save these in a common datasource that can be reused with every request known as Authenticated API datasources.
Appsmith encrypts all your datasource credentials and stores them securely. Appsmith also doesn't store any data returned from your datasources and acts only as a proxy layer to orchestrate the execution of Queries. As Appsmith is an open source framework, you can deploy it on-premise, and audit it to ensure none of your data leaves your VPC. For more information, see Security.
Connecting to REST API
To connect to a REST API, go to the Explorer tab, click the + icon next to Datasources and select REST API.
You can provide the URL and additional information like the Headers, Params, Body, and Pagination. After adding the request details, you can directly run the API query and bind it to widgets to display the results in the UI. To learn more about setting API request details, you can refer to the documentation on configuring APIs.
Appsmith provides a sample API
https://mock-api.appsmith.com to help you learn to create and modify queries using the REST API pane.
To use the sample APIs:
- Go to the Explorer tab, click the + icon next to Datasources.
- Select REST API
- To fetch users data from this API choose the
GETmethod and enter the following URL:
- Click the Run button to execute the API query and view the response.
Creating an authenticated API datasource
When you create an authenticated API datasource, you need to configure the headers and query parameters only once and thereafter don't need to configure these for every API request. Additionally, to ensure authorized access and secure data transfer, various authentication mechanisms can be implemented, such as OAuth 2.0, signature headers, self-signed certificates, bearer token-based authentication, and API key-based authentication.
To create an authenticated API datasource:
On the Explorer tab, click the + icon next to Datasources
Select Authenticated API.
Click on the edit pencil icon next to the default name to rename the datasource.
Provide the configuration details required to connect to your API.
- Name: Specify a name for the API datasource.
- Method: Select the method for the API request.
- URL: Specify the URL for the API endpoint.
- Headers: Set the required HTTP headers for the API request.
- Query parameters: Provide the query parameters for the API request, if necessary.
- Authentication type: Define an authentication type for REST APIs by using the protocols available on Appsmith.
- Send appsmith signature header: Ensure that the incoming requests originate from Appsmith.
- Use self-signed certificate: These certificates can be configured as part of the Advanced Settings.
Save the datasource. The configuration details aren't saved/updated until the Save button is clicked. When the datasource has been added successfully, a success message appears at the top of the app window.
Importing cURL commands
cURL is a command-line tool that can be used to make HTTP requests to a server. You can use cURL to send HTTP requests, such as GET, POST, PUT, and DELETE, to a server to retrieve or manipulate data. Appsmith makes it easy to import your APIs into your application using cURL commands.
To import cURL commands into your application:
- On the Explorer tab, click the + icon next to Datasources
- Select cURL Import.
- Add your cURL command, for example:
curl -X GET https://example.com/resource
- Click the Import button.
Native API datasources
Appsmith can also seamlessly connect with most other tools through the RESTful API plugin. For more information, see Integrations
Passing parameters to API requests
There are three ways to pass parameters to API calls on Appsmith as shown in the video below: