Run SafetyCulture Exporter
Get up and running with SafetyCulture Exporter
Download
- Download the latest release of the SafetyCulture Exporter for your platform (Windows, macOS, or Linux).
- Uncompress the file and move the extracted folder to where you want to store the SafetyCulture Exporter.
- Proceed to configure the SafetyCulture Exporter.
Configure
-
Open your command-line application. This can be “PowerShell” for Windows and “Terminal” for macOS.
-
In your command line window, navigate to the location where you stored the SafetyCulture Exporter. Learn how to change directory or folder using command lines on Windows and macOS.
-
Run the following command line:
./safetyculture-exporter configure
macOS users
If you’re running macOS, you may come across the following error message: “safetyculture-exporter” cannot be opened because the developer cannot be verified. You can go to your Mac’s System Preferences > Security & Privacy > General settings to Allow Anyway, then retry the command line and click Open in the pop-up window.
Windows Command Prompt users
If you're using Windows Command Prompt rather than PowerShell, the command above may return an error. If you get an error around "." not being recognized, run
.\safetyculture-exporter configure
orsafetyculture-exporter configure
. -
Proceed accordingly to open the configuration file:
Windows PowerShell
Run the following command line:
notepad.exe safetyculture-exporter.yaml
All other command-line applications
Run the following command line:
open safetyculture-exporter.yaml
-
For a basic configuration, update the following fields:
- access_token: Input your API token.
- modified_after: Specify the date and time to start inspection exports from, based on the date inspections are modified, in Coordinated Universal Time (UTC). This field supports multiple date and time formats.
-
Save the changes to the configuration file. You can check out all configuration options on this page.
-
Proceed to run the SafetyCulture Exporter.
Configuration options
SafetyCulture Exporter relies on configuration files to determine what and where to export data and from which account's perspective.
When you download and configure the SafetyCulture Exporter for the first time, you will come across the following configuration options in the default "safetyculture-exporter.yaml" file:
access_token: ""
api:
proxy_url: ""
tls_cert: ""
tls_skip_verify: false
url: https://api.safetyculture.io
csv:
max_rows_per_file: 1000000
db:
connection_string: ""
dialect: mysql
export:
incremental: true
inspection:
archived: "false"
completed: "true"
included_inactive_items: false
limit: 100
skip_ids: []
web_report_link: private
media: false
media_path: ./export/media/
modified_after: ""
path: ./export/
site:
include_deleted: false
include_full_hierarchy: true
tables: []
template_ids: []
report:
filename_convention: INSPECTION_TITLE
format:
- PDF
preference_id: ""
The following table outlines each configuration field's purpose and accepted values:
Make sure you leave a space (
) between each configuration field and its value. For example, take note of the space between
:
and"
foraccess_token: "de8g4e68bg...3acb983b5211"
.
Configuration | Description | Example | Default |
---|---|---|---|
access_token (required) | Your API token. | de8g4e68bg...3acb983b5211 | "" |
api.proxy_url | The proxy URL to go through for API requests. | "http://my-proxy.corp.com" | "" |
api.tls_cert | The custom root CA certificate to use for API requests. | "/path/to/my/root-ca.pem" | "" |
api.tls_skip_verify | The flag to skip or not skip API TLS certificate verifications. | true or false | false |
api.url | The SafetyCulture API URL. The default value should be used at all times. | https://api.safetyculture.io | https://api.safetyculture.io |
db.connection_string | The database connection string. | SQL: sqlserver://user:pass@localhost:1433?database=dbname MySQL: user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local Postgres: postgresql://user:pass@localhost:5434/dbname | "" |
db.dialect | The database dialect. | mysql or postgres or sqlserver | mysql |
export.incremental | The flag to remember or not remember where the last export run for actions, action_assignees, inspections, inspection_items, and templates tables have gotten up to. We recommend keeping this set to true , so that the SafetyCulture Exporter only exports new or updated data.Please note that if this is set to false, all previously exported data will be truncated. | true or false | true |
export.inspection.archived | The flag to export archived or active or both archived and active inspections. | "true" or "false" or "both" | "false" |
export.inspection.completed | The flag to export completed or incomplete or both completed and incomplete inspections. | "true" or "false" or "both" | "true" |
export.inspection.included_ inactive_items | The flag to include or not include inactive question items in the inspection_items table for CSV and SQL. This is relevant to templates that use Logic fields (smartfield), where items nested under a Logic field that hasn't been triggered are considered inactive. Please note that this setting can only be set before the database table is created. If you need to change this at a later date, drop the table first and allow it to be recreated. | true or false | false |
export.inspection.limit | The limit for the number of inspections that gets processed per batch. This only applies to CSV and SQL exports. | 50 | 100 |
export.inspection.skip_ids | The inspection IDs to skip for inspection exports. | ["audit_a3a4dcfa...8bdd55e7","audit_ 117df5ec...6332c485"] | [] |
export.inspection.web_report_link | The flag to export private (requires log in to SafetyCulture) or public inspection report links. | private or public | private |
export.media | The flag to export media with CSV and SQL exports or not. | true or false | false |
export.media_path | The absolute or relative path to save exported media files. | C:\Documents\Inspection-media\ | ./export/media/ |
export.modified_after | The timestamp in Coordinated Universal Time (UTC) to start inspections and actions exports. This field accepts multiple date formats. If you want to export all time data from your organization, leave the default setting. | 2006-01-02T15:04:05.000Z Mon, 02 Jan 2006 15:04:05 MST 02 Jan 06 15:04 MST Monday, 02-Jan-06 15:04:05 MST Mon Jan 2 15:04:05 2006 Mon Jan 2 15:04:05 MST 2006 2006-01-02 02 Jan 2006 | "" |
export.path | The absolute or relative path to save exported data. This applies to all formats except for SQL. | C:\Documents\SafetyCulture\ | ./export/ |
export.site.include_deleted | The flag to include or not include deleted sites in sites table exports. | true or false | false |
export.site.include_full_hierarchy | The flag to include full sites hierarchy in table e.g. areas, regions, etc. | true or false | false |
export.tables | The CSV and/or SQL tables to export. By default, the SafetyCulture Exporter exports all data set tables, unless specified. | [inspections,inspection_items] | [] |
export.template_ids | The template IDs to filter by for inspections and schedules export. | ["template_0dda96ce...802197ea","templ ate_89e72faa...bd30f88c"] | [] |
report.filename_convention | The naming convention for inspection report exports. Either by the inspection title or the inspection ID. | INSPECTION_TITLE or INSPECTION_ID | INSPECTION_TITLE |
report.format | The format for inspection report exports. | ["PDF"] or ["WORD"] or ["PDF","WORD"] | ["PDF"] |
report.preference_id | The report layout to apply for PDF and Word inspection reports. Please note that only report layouts for all templates can be used. Learn how to retrieve layout IDs. | "22af6c2b-e279-40b1-874f-0a4340930b6f" | "" |
Available export options
The SafetyCulture Exporter can export the following data sets from your organization:
All data sets apart from
inspection report
andinspection JSON
can be exported to CSV and SQL.
Data set | Description | Format value |
---|---|---|
Inspection report | Exports the inspection reports you have access to. | PDF and/or WORD |
Inspection JSON | Exports the inspections you have access to in JSON format. | N/A |
Inspections | Lists the inspections you have access to. | inspections |
Inspection items | Exports the inspection data you have access to. | inspection_items |
Templates | Lists templates you have access to. | templates |
Template permissions | Lists the access level users and/or groups have over each template you have access to. | template_permissions |
Sites | Lists the sites in your organization. | sites |
Users (requires the "Platform management: Users" permission) | Lists the users in your organization. | users |
Groups (requires the "Platform management: Group" permission) | Lists the groups in your organization. | groups |
Group users (requires the "Platform management: Group" permission) | Lists the users for each group. | group_users |
Schedules | Lists the schedules you have access to. | schedules |
Schedule assignees | Lists the assignees for each schedule you have access to. | schedule_assignees |
Schedule occurrences | Lists the completion history for schedules you have access to. | schedule_occurrences |
Actions | Lists the actions in your organization. | actions |
Action assignees | Lists the assignees for each action. | action_assignees |
Action timeline items | List the timeline items for each action in your organization. | action_timeline_items |
Issues (requires the "Issues: Access" permission) | List the issues in your organization. | issues |
Issue timeline items (requires the "Issues: Access" permission) | List the timeline items for each issue in your organization. | issue_timeline_items |
Assets | List the assets in your organization. | assets |
The format keys can be used to specify the data set tables to export. If you want to see the schema for each data set for CSV and SQL exports, run the following command line:/.safetyculture-exporter schema
You can also check out each data set in detail to understand what each column's data means.
Please note that by default, the SafetyCulture Exporter exports all available data sets for CSV and SQL exports. However, you can customize the export.tables
field in the configuration file to specify what you want to export.
Export data
Each time you run an export, remember to navigate to the directory or folder where you stored the SafetyCulture Exporter. Learn how to change directory or folder using command lines on Windows and macOS.
If you encounter an error when running the SafetyCulture Exporter, you may be able to refer to the error code and message to resolve the error yourself.
If you've made a mistake in the configuration file and want to reset your exports, you can delete the "export" folder in the SafetyCulture Exporter directory, then export again.
Export to CSV and SQL
- Run the following command line to export data to CSV:
./safetyculture-exporter csv
- Run the following command line to export data to SQL:
./safetyculture-exporter sql
If you want to export inspection media as well, update the flag for export.media
to true
in the configuration file. Alternatively, you can export with media by supplying the media flag in the command line. For example:
- CSV:
./safetyculture-exporter csv --export-media
- SQL:
./safetyculture-exporter sql --export-media
Export to PDF and Word
Please note that the format needs to be specified in the configuration file.
Run the following command line to export inspection reports:./safetyculture-exporter report
Alternatively, you can export inspection reports to PDF or Word by supplying the format flag in the command line. Please note that both format flags need to be entered in uppercase: PDF
and WORD
. For example:
- PDF:
./safetyculture-exporter report --format PDF
- Word:
./safetyculture-exporter report --format WORD
Export to JSON
Run the following command line to export inspection JSON:./safetyculture-exporter inspection-json
Report layouts
You can use the SafetyCulture API to search for report layouts in your organization and use their IDs for applying to inspection report exports. You can search either for report layouts available to all templates or report layouts only available to specific templates.
Search report layouts:
curl "https://api.safetyculture.io/preferences/search" -H "Authorization: Bearer {api_token}"
The above command returns JSON structured like this:
{
"preferences": [{
"id": "da5dceac-188a-4738-9550-a82b8801cef3",
"label": "Example Layout 01",
"is_global": true,
"is_default": false
},
{
"id": "93b6194c-c6b9-464b-a8dc-79fb6b48615c",
"label": "Example Layout 02",
"is_global": true,
"is_default": false
}]
}
Searching for a specific template's report layouts:
curl "https://api.safetyculture.io/preferences/search?template_id=<template_id>" -H "Authorization: Bearer {api_token}"
Updated 7 months ago