The data can then be inserted into a JSON renderer to get a descriptive overview of the data (for example, the following JSON renderer can be used for this: http://json2table.com/#). After the data has been inserted there, the names of the individual schedules and their IDs can now be seen. In our customer example, the following view was generated:
Now, we know the ID for the schedule, we can amend the next API in order to retrieve a query with the schedule information.
<https://api.opsgenie.com/v2/schedules/:identifier/timeline>
To retrieve the timeline for a schedule, the identifier retrieved from the timeline GET must be inserted. In the case of our client, we retrieved the timeline for the IT Operations schedule with this GET:
https://api.opsgenie.com/v2/schedules/70a07640-02a9-4d4a-8935-8384b839f331/timeline/
With the same authorisation in the headers, we have again obtained a status of 200 OK. If your status is also OK, you can go ahead and copy the data generated by the GET again and paste it into a JSON renderer to get a descriptive view of the data again.
After the data has been inserted into JSON renderer, the schedule for a week can be viewed. In the case of our client, the overview generated in the process looked like this:
Alternatively, the JSON data can be entered directly into a tool that converts it into a CSV file (such as this tool: https://data.page/json/csv). This allows the data to be downloaded and displayed directly in Excel.
If you want to get a whole month of data at once, you have to change the timeline GET by appending an IntervalUnit as follows:
https://api.opsgenie.com/v2/schedules/70a07640-02a9-4d4a-8935-8384b839f331/timeline?intervalUnit=months&date=2021-08-22T22:00:00Z
The modified timeline GET must then be entered into Opsgenie as before:
In the example, we again got a status of 200, so we could copy this data in JSON format and paste it directly into the renderer. By entering this, the renderer creates a CSV file like the following: