Retrieve Records
APIs - Retrieving Records (GET)
RegScale APIs are often used to retrieve data for third party integrations or to support reporting needs. Example use cases include:
- Pulling RegScale data for processing in a 3rd party system
- Pulling data for manual manipulation (i.e. in Excel)
- Pulling data for bespoke reporting in Business Intelligence (BI) tools such as Microsoft PowerBI, Tableau, and others
This page is intended to help you understand how the APIs work in RegScale for pulling data and includes example code to get you started.
Understanding API Response Structures
The first step to retreiving data with APIs is to understand the data structure of the objects that will be returned. To view the data structure, click your name in the top right of RegScale, select "APIs", and then RegScale will redirect you to the Swagger endpoint that contains our RegScale API definitions. An example is shown below for the catalogue object:
This screenshot shows the specific fields and data types that will be returned when querying the API. In addition, once you have authorized the page with your bearer token (JWT), you can try out the API directly in the web page for testing.
Example Python Code
The code below shows how to query an API in RegScale after having authenticated in a previous step where the bearer token (JWT) and user ID have been established. The code example is provided in Python:
# create header with JWT token after authenticating
response = requests.request("POST", url_login, json=auth)
authResponse = response.json()
jwt = "Bearer " + authResponse["auth_token"]
headers = {
'Authorization': jwt
}
# set the catalogue URL for your RegScale instance
url_cats = "https://sandbox.regscale.com/api/catalogues"
# get the ue data and print success result
response = requests.request("GET", url_cats, headers=headers)
jsonResponse = response.json()
print(jsonResponse)
The workflow for this code is described below:
- Initial call logs into RegScale and provides a token (JWT) that is added to the header
- Header is created to append to all API requests to authenticate to the API services
- URL is established for the "GET" endpoint
- New GET request is made to the provided URL with the provided header
- Prints the result to the terminal for viewing
This same process can be used for any object in RegScale as they all have well-defined CREATE, READ, UPDATE, and DELETE APIs.
NOTE: The user must have permissions to create records for that module in order for the API calls to work.
Updated 9 months ago