Skip to Content

Connect Your AppGyver Application to a Public API

test
0 %
Connect Your AppGyver Application to a Public API
Details

Connect Your AppGyver Application to a Public API

Requires Customer/Partner License
October 21, 2021
Created by
September 20, 2021
Connect your application to a public API and then test that it's pulling the right information.

You will learn

  • How to add and configure data resources in your AppGyver application
  • How to call a public API by scanning a barcode
QR code

Prerequisites

In the previous tutorial, you configured your application to open a device camera once the scan button had been tapped. This currently reads the barcode and returns only the barcode number, which on it’s own is just a reference with no further information. To improve this, you need to configure a data source connected to that information. In this example, we’ll use the Open Food Facts public API. Here the application will make a HTTPS request to their URL, returning the information provided there.


Step 1: Add data resources

Open your draft application in your AppGyver Composer account, displaying your barcode scanner app.

Click your Scan button and then click Data.

Add data source

Click Add Data Resources – Rest API direct integration.

Rest API direct integration

Now configure the resource with the following details:

Click Save, saving the data resource.

Enter data resource information
Log on to answer question
Step 2: Configure Get Record data

You now need to configure which information is taken from the Open Food Facts API. For your application, you need to configure this to fetch the barcode information, since that’s what’s being scanned with the device camera. This can be achieved using a ‘Get Record’ request.

To configure this, click Get Record (Get).

In the Relative path field enter:

/product/{barcode}.json

Configure relative path field

Click the existing URL placeholder key, and then configure the following settings:

  • Label: Barcode
  • Key: barcode
  • Value type: Text
  • Description: Resource ID to retrieve
  • Is encoded: Enabled
  • Is static: Disabled
  • Is optional: Enabled
URL placeholder configuration
Log on to answer question
Step 3: Test data sources

To now test that the HTTPS is configured and able to fetch information, click Test.

Test configuration

Click Currently bound to: static text.

static text

Click Static Text.

Click static text

Enter 6416453061361 into the Type a text field. This is an example barcode number, taken from a confectionary wrapper.

Enter numerical example

Click Run Test.

Click to run test

The test now runs, displaying a Test API call response. In this response, you can see information about the confectionary. This includes the product categories, allergen information, and the brand who manufactured the product.

View the results
Log on to answer question
Step 4: Set schema from response

After a successful test you should now set the data schema. This stores the data structure from the URL, enabling the application to easily identify the types of information it is fetching.

To do this, click Set Schema from Response.

Link text e.g., Destination screen

Click Save.

Link text e.g., Destination screen

Your draft application is now saved and available in your AppGyver Preview app.

In the example, what is the barcode number of the scanned food item?
×

Next Steps

Back to top