Skip to main content
Skip table of contents

API Access to COMET Data

Authorized users of COMET Data can also generate and provide an API Code to external users (e.g., website or 3rd party app developers), which they can use to run and fetch raw report data in JSON format.

First, you will need to define and Save a Report to My Reports. Essentially, an authorized user must prepare a custom report in advance, with all the details they are willing to share with an external party, and save it in their list of My reports.

Next, click on the “options” menu at the far right of your selected report and choose to generate API Code, as shown in the image below. API Code is generated at that moment and copied to the clipboard so it can be pasted into your email, browser, or any other app.

slika-20260122-155504.png

Once the API code has been generated, it is also saved in the system and can be reaccessed by the same user via the Copy API code option, which copies the code to the clipboard and can be used to run and fetch data from outside COMET.

If you have prepared and sent this API code to an external user, and later you choose to delete the Report from the My Reports list, the API access will be disabled.

The maximum number of calls per second per user is 10.

To use data obtained via the API to feed an external system (e.g., a website or other apps), developers must save the information captured from COMET in a separate local database. Make sure this is done from the start and by design to avoid the risk of rejected calls or performance issues.

  1. The structure of the COMET data API endpoint

CODE
https://<comet-url>/data-backend/apu/public/areports/<current_page>/<results_per_page>
?API_KEY=<api_key>

example
https://comet.faw.cymru/data-backend/api/public/areports/run/0/25/?API_KEY=XXXXXXXXXXX

The fetched data from the API URL is divided into one or many pages, and the user should pull the data page by page.

By default URL will fetch only the first page <current_page>=0 and first 25 rows <results_per_page>=25

0 is the first page, 1 is the second page, 2 is the third one, etc.

The maximum valur for <results_per_page> (<results_per_page>) is 1000.

2. The structure of the response (JSON)

  • columnTypes - data types of column

    • NUMBER

    • IMAGELINK - direct public link to image/photo

    • STRING

    • DATE, DATETIME

    • AMOUNT

  • columnNames - names of columns

    • Names are translated into the language that was active at the moment of generating the REST API URL

  • data

DATE and DATETIME fields are represented in milliseconds at the UTC timezone.

  • At the end of the JSON payload, there is a summary part
    "totalSize": 185 - number of all records in the report
    "page": 0 - current page
    "pageSize": 25 - current value for results per page
    "lastPage": 7 - last possible page

Here, we have 8 pages of data in total - 0,1,2,3,4,5,6,7.

"sortField": null - if data is sorted, by which column
"sortDirection": "asc" - if data is sorted, in which direction
"locale": "en_CY" - locale of translated column names

Example

JSON
{
"reportName": "Person Registrations",
"columnTypes": [
"IMAGELINK",
"NUMBER",
"STRING",
"STRING",
"DATE"
],
"columnNames": [
"Photo",
"Person ID",
"Given names",
"Last name",
"Date of birth"
],
"columnKeys": [
"photo",
"personId",
"firstName",
"lastName",
"dateOfBirth"
],
"results": [
{
"lastName": "Rushesha",
"firstName": "Tivonge",
"photo": "https://comet.comet/resources/images/noImageAvailable.png",
"#result_id#": "1",
"dateOfBirth": 1027468800000,
"personId": 191579
},
{
"lastName": "Jenkins",
"firstName": "Kian John",
"photo": "https://comet.comet/file?id=5b621510-415b-484b-a3ae-9b1bf833a230",
"#result_id#": "2",
"dateOfBirth": 1086307200000,
"personId": 241553
},
.....
"totalSize": 185,
"page": 0,
"pageSize": 25,
"lastPage": 7,
"sortField": null,
"sortDirection": "asc",
"locale": "en_CY",
"pivot": false,
"curl": null,
"apiKeyRequestURL": "http://comet.comet/data-backend/api/public/areports/run/0/25/?API_KEY=4c01e7460ccf01118409cfd33631a16503a72b5128e2bc5a2f7da707cf93d5d8e6f3bb3d0a26b8019be60fc608a44782f2364aa515dddac209dc5b7a5a3b7f7e",
"reportTemplateID": 1074
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.