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 on the image below. API Code is generated at that moment and also copied to the clipboard, so it can be pasted to your email or browser or any other app.

Once the API code has been generated, it is also saved in the system, and it can be accessed again by the same user with the Copy API code option, which will copy the code to the clipboard and can be used for running and fetching data from outside of COMET.

Note: If you have prepared and sent this API code to some external user, then later you choose to Delete the Report from the list of My Reports, the API access will be disabled.

The maximum number of calls in second per user is 10

Note: In order to use the data obtained via the API to feed some external system (i.e. website or other apps), developers must save the information captured from Comet to another local database. Make sure this is done from the start and by design, so as to avoid the risk of getting 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 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

IMPORTANT 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 in the language which was active in the moment of generating REST API URL

  • data

IMPORTANT DATE and DATETIME fields are represented in milliseconds at 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 columns name

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.faw.cymru/resources/images/noImageAvailable.png",
"#result_id#": "1",
"dateOfBirth": 1027468800000,
"personId": 191579
},
{
"lastName": "Jenkins",
"firstName": "Kian John",
"photo": "https://comet.faw.cymru/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.faw.cymru/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.