How to integrate external API endpoints in AppGyver
Tags: api, integrations, appgyver, beginners
Published: 2022-04-26 09:43:36


With the advent of low-code/no-code platforms, building applications has become much easier. The AppGyver platform is one such no-code platform where you can develop applications without having to code.

Now that we have a clear understanding of the platform, let’s dive into the functioning and step-by-step guide to integrate external API endpoints in the platform.

## How to integrate external API endpoints in AppGyver

**Step 1: Open your Project in AppGyver & Go to the Data button**
Once you are inside your project, go to the Data button at the top of the toolbar, to create new external data resources or to edit the existing ones.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ljti4wtayc8tgqtr7oyf.png)

**Step 2: Add Data Resources**
Once you’re into the data tab go to the Add Data Resources by clicking on plus sign in the top right corner, which will have a dropdown of 5 different options from which we will select — Rest API direct Integration to integrate external API endpoint.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p5tlbpn27a2kj8t0zodk.png)
**Step 3: Base Configuration**
The resource configuration is split into base configuration and method configurations for GET collection, GET record, POST, PUT/PATCH and DELETE.

 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bcygxadqskg4c309cwo.png)

## Base Configuration:

_Here, you define the base configuration:_

- Resource ID: unique ID for the resource in your app
- Base URL: URL shared between all methods
- Path variables: Use to make parts of the URL dynamic
- Headers: HTTP headers to be included in every API call made to this external resource
- Query parameters: Parameters to be included in every API call made to this external resource

## Canonic for the Backend

Here, we will be using [Canonic](https://canonic.dev/?utm_source=dev.to&utm_medium=organic_article&utm_campaign=april16-31&utm_term=firstlink&utm_content=april26) to generate all the required APIs endpoints that we need to integrate with AppGyver.

Canonic is the simplest way for agile teams to build internal tools.

In Canonic, you can directly get your Base Configuration by:
Going to your project in Canonic → Docs section → Copy the URL


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t4ogzhzq40hu3o8ys2z9.png)

Once you have your URLs ready, get back on AppGyver and place them at the required spot as shown in the picture below.
With that, you have your base configuration ready! 💃


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rocr7tlcrkh9s08yqk93.png)

## Exploring the API methods

Now that we have our base config in place, let’s see how can we integrate all these different methods in our project.

## Get Collection (GET):

The base URL will automatically reflect in all other tabs. So, all you now have to do is fill in the Relative path/ Response key and Test API call response.

For Get Collection, there’s no specific id required because we are retrieving the collection of data from a server.

Thus, will go in with the Relative path and Response key.
Response key — The JSON response from an API might include the actual data we are interested in inside a key of the main response object.

Which in Canonic’s case is data:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6tk1bgfeyvhc5u9l8zdx.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mkdblydukbug4lxa27na.png)

If you’ve correctly followed and tested, you’ll get something like this:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rybqz8taiyaq85besqrs.png)
 Similarly, all you have to do is copy the required URL which you get readily available with Canonic, put them in dedicated fields.

## GET RECORD (GET):

GET method is used to retrieve data from a server at the specified resource.

Now to retrieve some data, we need to specify which data we are required to fetch, and hence we’ll need to pass the id and Access Tokens (represent the authorization of a specific application to access specific parts of a user’s data).

Go to Canonic — Select Product (GET) — Copy the URL from the endpoint section.

As the base URL is already set we will just paste /products/:_id on AppGyver’s Relative path section.

Now, we need to pass the id, which you can get by following:
Canonic → Project → CMS section → Under the CMS entry title you can see the id (shown in the image below).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eq85awji3dv5fvn6u442.png)
Copy the id and pass in the Relative path of Appygyver

**Access Tokens: This broadly has two steps**
_1. Creating Access Token in the backend_: 
As we are using Canonic as our backend, the access tokens can be created within minutes.

Go to settings→ AccessTokens → Create A New Token → Give it a name and provide access → click on create → copy the value.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzg9fn98wprtshklrmwd.png)

_2. Embedding access Token in AppGyver:_
In AppGyver, the access tokens need to be embedded in the HTTP Header section, where you’ll require the below fields:

In the config tab of AppGyver → Http Header → On the right-hand side panel fill all the required details:

Key: The exact key name of the authorization Label: Name this as per your understanding Value type: Text Description: Description of the token

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i379tvq57orrqf20kpdm.png)

Go to the Test tab to run a test and in the URL placeholder, mention the id of the product that we copied earlier.

Once the access token is in place, run a test (here you need to mention the id as well) and that’s it!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/owxb8ufudjupdcp0vew6.png)

You’ve successfully retrieved data from a server ✅

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/80jsxua95y2szd0phfi5.png)

## CREATE RECORD (POST):

A POST is used to create or update a resource on a server. POST data is sent to the server in the request body of the HTTP request.

Here, we will require to specify the data that we want to store in the server.

Let’s see how to do that 👇
Go to Canonic — Docs Section — Select Create product (post)- Copy the URL from the endpoint section.
Go to AppGyver -> CREATE RECORD (POST) → paste the relative path ****
As the base URL is already set we will just paste the required specific field on the Relative path’s section.

**Sending the Payload**
Now as additional steps to send the payload, go to the schema tab → Create record (POST) request schema
Here, we will specify our data requirements which are name and description with the input object.

Go to add Property → mention key as input and value type as object. Within which we will add the rest of the values, in our example’s case, name and description with key as name and description and value type as text.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9effzzj1bezj8kl7q6k.png)

Once done, Go to the test tab and custom object and mention the required name and description which will get updated in your backend, in this case — Canonic.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36zm9o4liy20as0pcd9d.png)

## DELETE RECORD (DELETE):

Similarly to delete the record, we will need to pass a specific id (which we want to delete).

Go to Canonic — Docs Section — Select Delete product (delete)- Copy the URL from the endpoint section.

Go to AppGyver -> DELETE RECORD (DELETE)→ In the config section tab, paste /products/:_id on the Relative path’s section.

Follow the same pattern of updating id and custom object
(Ref above to get Product id from Canonic)

One all the fields are set, run Test API call response

## UPDATE RECORD (PUT):

The same process will apply to PUT in which the method will search for the input if found will update it or will create a new record, quite similar to the steps we did in the POST method.

If you will follow the steps right, you will be able to external API endpoints in AppGyver with ease! 🚀

## Voila, you’re done!✨

Yes, that was it. Here are all the links you’ll require:

[AppGyver ](https://www.appgyver.com/)— A no-code platform, enabling you to build apps for all form factors, including mobile, desktop, browser, TV, and others.