HomeGuidesSamplesAPI
API

Extract historical inspection data

Export SafetyCulture data to integrate with your systems

The API can be used to extract all historical inspection data that your account has access to.

If you want to extract all your SafetyCulture data not just inspections, take a look at Export your SafetyCulture Data.

The steps described below can be seen in action in our open source SafetyCulture Exporter.

There are several steps to extracting this inspection data:

  1. Retrieve all the available inspection identifiers
  2. Retrieve the corresponding inspection data for each identifier
  3. Retrieve the media associated with each inspection

Retrieve all available inspection identifiers

curl "https://api.safetyculture.io/audits/search?field=audit_id&field=modified_at" \
  -H "Authorization: Bearer {api_token}"
{
  "count": 1000,
  "total": 2023,
  "audits": [
    {
      "audit_id": "audit_01ca38a821504cda885736cccbb9ba40",
      "modified_at": "2015-03-17T03:16:31.072Z"
    },
    {
      "audit_id": "audit_853C17E6040B43DA1DFDDD8E6A4D6D3A",
      "modified_at": "2015-03-24T06:31:47.203Z"
    }
  ]
}

To retrieve all of the available inspection IDs, you will use the process as described in the Search modified inspections section of the documentation. You can then use the IDs from the audit_id field of each record in the inspections array.

curl "https://api.safetyculture.io/audits/search?field=audit_id&field=modified_at&modified_after=2015-03-24T06:31:47.203Z" \
  -H "Authorization: Bearer {api_token}"

If you have more than 1000 inspections, then you'll see that the amount is limited and the total will be greater than the count retrieved. In this case, you should make another request, setting the modified_after parameter to the date of the last retrieved inspection. Repeat this process until all of the inspections have been retrieved.

📘

Ensure that you retrieve further inspections if the total is greater than the count, even if the count is less than the expected limit of 1000.

Retrieve the corresponding inspection data for each identifier

curl "https://api.safetyculture.io/audits/audit_01ca38a821504cda885736cccbb9ba40" \
  -H "Authorization: Bearer {api_token}"

Given the list of inspections retrieved in the previous step, the inspections may then be retrieved individually, as described in Get an inspection (legacy).

The inspection data can then be stored or processed as desired within your own systems, using the Inspection Format as a guide to the data available.

Retrieve the media associated with each inspection

Finally, you may decide that you need to retrieve the media for some or all of the inspections. To do so, for each of the inspections retrieved above, find all of the elements that contain media. This includes:

  • All header_items with a media element
  • All items with a media element
  • All options within an item or header item that contain a media element
  • All responses within an item or header item that contain a media or image element
curl "https://api.safetyculture.io/audits/audit_01ca38a821504cda885736cccbb9ba40/media/9E3BD015-6275-4668-BAF1-296B2F38444C" \
  -o 9E3BD015-6275-4668-BAF1-296B2F38444C.jpg \
  -H "Authorization: Bearer {api_token}"

The media element is described in the media reference. It contains an href element, that allows you to directly request the required media, if you have not retrieved it already. You can then retrieve it as described in Get inspection media.

🚧

The media associated with all inspections can be quite a large quantity. To preserve bandwidth, ensure only the necessary media is retrieved, and is only retrieved once. Media are not updated with the same UUID, so it is unnecessary to retrieve it again to check for updates.