The HTTP component
Connect your app to an API using the HTTP component. For example, you can connect to Airtable to display an external collection (registration list), to Mailchimp to send an email or to OpenWeatherMap to display the weather of the day in your application.
An API makes data or functionality from an existing application available for use by other applications. By connecting to the APIs, it is possible to use existing functionalities within your PandaSuite application.
Each PLC has its own operating mode. The connection to an API is done using the HTTP component.
Connect to the API
URL of the API
Insert the HTTP component in your project, where it will be used. If requests to the API are used throughout the application or if it controls the behavior of your application, we recommend that you put this component in the Project.
https://api.openweathermap.org/data/2.5/weather?q={city name}&appid={API key}
In the URL field, copy and paste everything from the "https:" to the "?" without including the "?". The rest of the information corresponds to the Query String that will be specified below.
API parameters
In some cases you will be asked for a Username and Password to use the API.
Cache management
Caching allows you to efficiently reuse previously retrieved or processed API data. Future requests are processed more quickly by accessing the primary data storage location and without using the network.
Depending on your use of API data, choose how your application behaves with respect to caching :
- No cache: the application will make a network call and will not read the cache.
- Cache first: the application looks for the result in the cache before making a request to the network.
- Network and cache: the application will return the content of the cache but will still make the request to update it. This option allows you to have a quick response.
- Cache and network
The Persistent Cache option allows you to keep the cache even after closing the application.
You can make data available offline with the Offline mode of the HTTP component.
Method
The HTTP component allows you to send or receive data using different available methods. It all depends on what you want to do with the data:
-
GET = request data from a specific resource. This is one of the most common methods.
-
PUT or PATCH = update a resource.
-
DELETE = delete a resource.
-
POST = create a resource.
Choose the content
This option is only required if you choose the method POST, PUT, PATCH etc... Choose the type of content that will be the subject of your request:
- Text
- JSON
- XML
- HTML
Other parameters
- Auto-start: This property allows the HTTP component to automatically launch the request as soon as the application or page is started. This means that the user doesn't need to perform a specific action to initialize or start the request.
- Offline mode: Offline mode allows requests to be queued when the component detects that it doesn't have an Internet connection. When the connection is restored, it will automatically send the requests from this queue. This is useful, for example, for a sales presentation used at a trade show (offline). If the salesperson enters data, it is automatically sent as soon as the device reconnects to the network.
- Proxy mode: Proxy mode is useful for bypassing API security restrictions and not exposing sensitive data locally (only the proxy knows about it). Proxy mode is mandatory as soon as Authorization is enabled,
- Authorization: This is secure API authorization management (see proxy mode), either through an API key (HTTP header) or through HTTP Basic.
Test the request
Display the request results
Choose pagination
Start request