Go to EPIC Developer Home
Or go to EPIC REST APIs Overview
What the PAC Control API Can Access on the EPIC
The PAC Control REST API is used to access the PAC Control variables used in the strategy currently running on the EPIC control engine. To access the I/O you should use the groov Manage REST API, and to access any groov data-store tags you should use the groov View REST API.
Getting Started
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.
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 custom HTTP header named “apiKey”.
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 password.
- Make sure the user has PAC Control REST API Read-Write 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 that is made up of two parts: the hostname or IP address of the groov EPIC processor and the URL path of the request, as well as a header for the API key from Step 1.
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 int32 variable list, which has the URL path /device/strategy/vars/int32s
.
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 /pac/
between the hostname and URL path to specify the interface you are using. So the cURL request looks like this:
curl -k -X GET "https://opto-01-02-03/pac/device/strategy/vars/int32s" -H "accept: application/json" -H "apiKey: 3KbLb7yZRxnTBP49nEmobDkrpmPkFoBo"
The -k flag is used to ignore any SSL errors. By default, groov EPIC processors use a self-signed SSL certificate, but your computer and cURL has no reference to it. To make these examples easier, we just ignore the issue with the -k flag. The requests will still be encrypted, but the certificate itself will not be verified.
The API key is set with the -H flag, which adds a custom HTTP header named “apiKey” to the request.
If you run the above command (adjusting for your own address and API key), the response should look like this:
[ { "nMyVeryFavoriteNumber": 22 },
{ "nWidgetsProducedToday": 31415 },
{ "DELAY_LOOP_TIME_IN_MSECS" : 250 } ]
Where each entry in the array is an int32 variable in the PAC Control strategy with it’s associated value at the time of the request response.
Conclusion
There are dozens of GET and POST requests listed in the developer API reference to access specific integer values, floats, strings, tables, timers, strategy info, and even I/O if you want to use the PAC Control API for that. 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.