Go to EPIC Developer Home
Or go to EPIC REST APIs Overview
What the groov View API can access on the EPIC
The groov View REST API is used to access groov data-store tags used in your groov View via the Devices and Tags interface in groov View Build. To access the strategy variables you should use the PAC Control REST API, and to access I/O you should use the groov Manage REST API.
Prerequisites
Before you start you’ll need an HTTPS client, for example an HTTPS programming library for your coding language of choice, such as the requests Python package, or some other interface like cURL or Postman. In the following example we’ll use cURL.
You should also have a Data Store ready, with some tags to read and write.
Step 1 - Authentication
Requests are authenticated using an API key, where every groov EPIC user has an API key associated with their account.
To find a user’s API key, open groov Manage in a web browser and navigate to the Accounts page and click on the user. The API key is listed near the bottom of the page.
When making a request, the API key needs to be added as a URL property ?api_key=
.
To create an API-only user:
- Go to groov Manage.
- Navigate to the Accounts menu.
- Choose Add to create a new user.
- Set the Username and a strong, random password.
- Make sure the user has groov View Editor permissions.
- Select Save.
- Choose that user from the account list and copy the API key to use in your applications.
Step 2 - Build the Request
To make a request you will need the specific URL (see the previous page for more details) that is made up of three parts: the hostname or IP address of the groov EPIC processor, the URL path of the request, and the API key from Step 1. We would also need to include values if making a write request.
In this example we’ll use an example hostname opto-01-02-03
for the address, with the associated API key 3KbLb7yZRxnTBP49nEmobDkrpmPkFoBo
.
The details of the URL extensions can be found in the developer API reference or follow the steps to auto-generate a request to get the exact URL from the EPIC itself.
In this example we’ll look at the data-store tag list, which has the URL path /v1/data-store/tags
.
Step 3 - Execute the Request
With the API key from Step 1 and the URL from Step 2 we’re ready to make a request.
Note: With the groov EPIC it’s crucial to include /view/api/
between the hostname and URL path to specify the interface you are using. So the cURL request looks like this:
curl -X GET "http://epic-dev/view/api/v1/data-store/tags?api_key=3KbLb7yZRxnTBP49nEmobDkrpmPkFoBo" -H "accept: application/json"
The response type is set with the --header
(or -H
) flag to request a JSON-formatted response, which if you run the above command (adjusting for your own address and API key), should look like this:
[ {
"id": 77,
"deviceId": 7,
"name": "Part #",
"dataType": "string"
}, {
"id": 79,
"deviceId": 7,
"name": "Quantity",
"dataType": "integer"
} ]
Where each entry in the array is a data store tag with it’s associated id, device, name, and data type at the time of the request response. We could then follow this up to get a specific value using the path /v1/data-store/read/{id}
, or overwrite the “Quantity” using /v1/data-store/write/79?value=22&api_key=...
.
Conclusion
There are several GET and POST requests listed in the developer API reference to access specific data-store tags and groov View Info. To make the process of building requests more straightforward and contained check out the developer instructions to auto-generate requests to get the exact URL from the EPIC itself.