Create & Test API Calls | FlutterFlow Documentation (2024)

On this page, you will learn how to create and test the API call.

Creating API calls

To use an API in your app, first, you have to create the API Call.

Follow the steps below to create an API Call:

  1. Select API Calls from the left Navigation Menu.
  2. Click on the + Add button and select Create API Call.
  3. Enter the API Call Name.
  4. Select the Method Type: GET, POST, DELETE, PUT, or PATCH.
  5. Enter the API URL of the service you want to access.

note

If you want to use a dynamic URL, for example, <https://reqres.in/api/users/2> where 2 is dynamic and <https://reqres.in/api/users?page=5> where 5 is dynamic:

  1. Replace the hard-coded value with a meaningful name inside the brackets (e.g., from https://reqres.in/api/users/2to https://reqres.in/api/users/[user_id]).
  2. And then, create a new variable with the same name you provided inside the brackets.

The further instructions are based on the Method Type you selected.

For GET & DELETE call

If you selected GET or DELETE as the method type, follow the steps below:

  1. Optional: If the API call requires request headers such as an authorization token, add a header.
  2. Optional: If the API call requires query parameters such as page number or user id, add query parameters.
  3. Click Add Call to save the API Call.

In the above demo, a GET API call is defined to fetch users' data from REQ | RES (which provides hosted REST API to try out HTTP requests).

A demo of using a dynamic URL in a GET request is as follows:

To add such an API call:

  1. Replace the hard-coded value with a meaningful name inside the brackets (e.g., from https://reqres.in/api/users/2to https://reqres.in/api/users/[user_id]).
  2. And then, create a new variable with the same name you provided inside the brackets.

The DELETE API Call can also be defined similarly; just make sure you select the Method Type as DELETE.

For POST, PUT & PATCH call

If you have selected POST request, follow the steps below:

  1. Optional: If the API call requires request headers such as an authorization token, add a header.
  2. Create a request body for the API call.
  3. Click Add Call to save the API Call.

warning

After making any changes, you must save the API call.

In this demo, a POST API call is defined with two variables, userName and userJob. The variables are used inside the JSON request body.

The PUT and PATCH API calls can be defined similarly; make sure you enter a valid API URL endpoint and select the correct Method Type.

Grouping API calls

You can create a group of API calls that share the same base URL. Grouping the API calls helps you add all request headers (e.g., auth token) at once, and they will be automatically added for all the API calls inside the group.

warning

For private APIs, headers defined within the group will not be automatically included. You'll need to manually add headers for APIs marked as private.

To create the API Group:

  1. Click on the + button (top left side) and select the Create API Group.
  2. Enter the API Group Name.
  3. Enter the API Base URL. This should be the portion that is common in all the APIs. Note: Do not keep the '/' in the end.
  4. You can add request headers by clicking on the + Add Header button. See detailed instructions on how to add headers.
  5. Click Add Group. This will display the group on the left side.
  6. Open the newly created API group, and click on the + Add API Call.
  7. Add the API call as you would normally do. Note: Inside the API endpoint, enter the URL portion that starts after the base URL.

Import API definitions

We allow you to add multiple API call definitions by importing them directly from the Swagger/OpenAPI in bulk. With just a simple click, you can add a large number of APIs, significantly reducing the time and effort needed to create them manually.

Furthermore, the ability to import Swagger/OpenAPI definitions directly into FlutterFlow eliminates the risk of errors that may occur when creating API definitions manually, ensuring that applications are reliable and efficient.

info

We also add all settings that are required to run the API, such as headers, query parameters, variables, and body as they are defined in the Swagger file. However, you might need to replace the hard-coded values in Body text with the variables.

warning

Please note that while it is possible to import APIs created with OAS 2.0 in FlutterFlow, you might face some issues, such as the body request being lost during the import process. Our import functionality is built based on the OAS 3.0 standard, so for the best experience and compatibility, it is recommended to use APIs that adhere to OAS 3.0 or above.

To import API call definitions:

  1. Click the Import OpenAPI icon. This will open a new popup.
  2. Click Upload File. Here you can upload your swagger file available in .yml or .json file format.
  3. After the import is successful, you will see the list of all APIs created and added as a group.

Here's an example of importing API calls in bulk, taken from here.

Testing API calls

You should always test your API call before using it inside your app. We make it easy for you to try the API call inside our builder.

To test the API call along with its response, follow the steps below:

  1. Select an API call you have already created or are currently defining, and go to the Response & Test tab.
  2. On the left side, you will see the Variables section, where you can enter the values for the variables defined for your API call.
  3. On the right, the Preview section lets you check the API URL, request headers, request body, and response. In the Test Response tab, you can view the full API response, including both the JSON format and raw body text, as well as the response header.
  4. Click Test API Call to trigger the API call. You'll notice that the status of the GET request is displayed, and if it's successful (status code 200), the result returned from that request will also be displayed below.
  5. Any value of the JSON result can be accessed by defining the JSON path.

The demo below shows the testing of creating a new user using a POST request. The API Call takes two variables: userName and userJob. The successful POST request returns a status code of 201.

info

The testing of PUT and PATCH requests would also be similar to this.

Trigger API calls [Action]

Using this action, you can trigger the API Call defined in your project.

tip

You can also add the API Call as a Backend Query that gets triggered automatically when the page or widget is loaded on the screen.

Go to your project and follow the steps below to define the Action to any widget.

  1. Select the Widget (e.g., Button) on which you want to define the action.
  2. Select Actions from the Properties panel (the right menu), and click Open. This will open an Action Flow Editor in a new popup window.
  3. Click on the + Add Action.
  4. On the right side, search and select the API Call (under Backend/Database) action.
    1. Select the Group or Call Name from the dropdown.
    2. Optional: If your API call requires variables (e.g., auth token, query parameters, user id, etc.), pass their value by clicking on the + Variable button.
    3. The Action Output Variable Name helps you retrieve the response of an API call. By default, we set it to any random name. However, you can change it to a meaningful name if you wish to. (e.g., loginResponse).
    4. You can add a conditional action that checks if the API call is succeeded.
    5. If the API call is succeeded, all actions under the TRUE path will be executed. For example, navigate to the home page if the login is successful.
    6. If the API call is failed, all actions under the FALSE path will be executed. For example, showing a snackbar if the login is unsuccessful.
Create & Test API Calls | FlutterFlow Documentation (2024)

FAQs

Create & Test API Calls | FlutterFlow Documentation? ›

You can make 200 API calls/day for every basic and advanced monitor; 40 API calls/day for every network interface in your license. This is exclusive of the API calls made from the Site24x7 web client and mobile app. For MSP accounts, you can make 100 K calls per customer account.

How do I create an API response? ›

  1. The first element of any API response will be the "Success" element, which will either be true or false. ...
  2. When a GET request successfully executes, the second element in the response will be the payload , which will contain the data requested.

How many API calls can I make? ›

You can make 200 API calls/day for every basic and advanced monitor; 40 API calls/day for every network interface in your license. This is exclusive of the API calls made from the Site24x7 web client and mobile app. For MSP accounts, you can make 100 K calls per customer account.

Can we create an API in Flutter? ›

In general, you will go through the following steps for integrating an API into the Flutter application. Get the base URL, the endpoints, and the API key. Add required packages in-app to consume HTTP resources like http, dio, chopper, etc. Create a constant file that will hold all your URLs and Endpoints.

How to test an API call? ›

API testing flow is quite simple with three main steps:
  1. Send the request with necessary input data.
  2. Get the response having output data.
  3. Verify that the response returned as expected in the requirement.

How to create an API for beginners? ›

Choosing your API design tools
  1. In the console, open the navigation menu and click Developer Services. Under API Management, click Gateways.
  2. On the APIs page, click Create API Resource and specify its Name. ...
  3. Click Create to create the new API resource.
  4. Write the backend code. ...
  5. Test the backend code. ...
  6. Deploy.

What is an example of an API call? ›

Suppose someone searches for bus tickets on a travel website. The travel website sends an API call to the various bus companies' servers and receives back information about what rides are available and how much they cost. From the user's perspective, this process should be almost instantaneous.

What is the difference between API and API call? ›

The functionality of application programming interfaces (APIs) is built upon several layers — one of which includes requests made to APIs to retrieve a service or data, or what's otherwise known as an API call.

Can I create my own API? ›

Creating your own APIs can seem daunting if you're new to the practice, but sticking to a design-first approach will keep you on the right track. A simple three-step process—design, verify, code—can increase your chances of building an API that benefits the people who use it.

How to trigger an API call? ›

Add an API trigger
  1. Enter a name and description in the Create Integration pane.
  2. Select a region for the integration. Note: The Regions dropdown only lists the regions provisioned in your Google Cloud project. ...
  3. Select a service account for the integration. ...
  4. Click Create.

Is REST an API? ›

A REST API (also known as RESTful API) is an application programming interface (API or web API) that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. REST stands for representational state transfer and was created by computer scientist Roy Fielding.

How do I call another API from one API? ›

Methods: callApiGetAllEmployee() : This method handles HTTP GET requests made to "/api/call-api/get-all-employee". It returns an Iterable of Employee objects retrieved from an external API. Constructs the URL for the external API by appending “/api/employee/get-all-employees” to the base URL ( otherApiBaseUrl ).

How do you structure an API response? ›

A well-structured API response should be:
  1. Consistent: Uniform format across different endpoints.
  2. Informative: Includes relevant data, messages, status codes, and error codes.
  3. Simple: Easy to parse and understand.
Aug 2, 2024

How do I make an API react? ›

How To Make An API Call In React
  1. Installing & running a new React App with Axios.
  2. Setting up a basic structure.
  3. Making the API call with useEffect.
  4. Making the API call from a click event.

What is the common API response format? ›

The common response formats encountered in API interactions include:
  • JSON (JavaScript Object Notation) ...
  • XML (eXtensible Markup Language) ...
  • YAML (YAML Ain't Markup Language) ...
  • Protocol Buffers. ...
  • HTML (Hypertext Markup Language)
Dec 20, 2023

How to create an API endpoint? ›

Step 1: Create the endpoint
  1. Navigate to Platform > API platform > API collections and select the API collection in which to create the new endpoint.
  2. Select Create new endpoint.
  3. Fill in the following fields: Endpoint name. ...
  4. Select Add endpoint. The new endpoint appears in the API collection page. ...
  5. Next, view the endpoint.

Top Articles
SharePoint vs. OneDrive (What's the Difference Again?)
Manage site storage limits in SharePoint in Microsoft 365 - SharePoint in Microsoft 365
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
Things To Do In Atlanta Tomorrow Night
Non Sequitur
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated:

Views: 5524

Rating: 4.6 / 5 (46 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.