Data Export

Last edit: Oct 04, 2019
  • Contributors:
  • DeanmvSG
  • pavelloz
  • piotrze

You can export data using either the CLI or the raw export API. This can be useful when test data is needed for a service, e.g. in a staging environment.

Data export with the CLI

platformOS CLI provides the pos-cli data export command. Options:

  • --path (short: -p): A file path to a JSON file which will be created by the CLI and where the exported data is stored.
  • --export-internal-ids: By default, export will use the autogenerated external_id for the id field. When this option is set, it will use the normal id from the object.

Under the hood, the CLI uses the export API that's described in the next section. However, using the CLI provides some major benefits:

  • Leveraging the CLI's authentication mechanism (i.e. you don't need to manually send your authentication token)
  • Writing downloaded data directly to the file system

Example:


pos-cli data export --path=data.json production

Data export with raw export API

Our CLI uses the HTTP API to schedule an export task. Once it is finished, you can download the data.


curl -d @data.json \
  -H "Content-Type: application/json" \
  -H "Authorization: Token token=[YOUR API TOKEN]" \
  -X POST https://example.com/api/marketplace_builder/exports

curl -H "Content-Type: application/json" \
  -H "Authorization: Token token=[YOUR API TOKEN]" \
  https://example.com/api/marketplace_builder/exports/[export_id]

Note

You can find your API Token in Partner Portal under "Access Key".

Data export with GraphQL

It is possible to export data with GraphQL queries.

{
  users: people(per_page: 10000, user: { is_deleted: false }){
    total_entries
    results {
      id
      email
      first_name
      last_name
      middle_name
      created_at
      slug
      profiles {
        type_name: profile_type
        id
        ...Properties
      }
    }
  }
  models: customizations(per_page: 10000, is_deleted: false){
    total_entries
    results {
      type_name: name
      id
      customizable_id
      customizable_type
      user_id
      ...Properties
    }
  }
}

fragment Properties on ListingCustomAttributeInterface{
  properties
}

Questions?

We are always happy to help with any questions you may have.