Data Export

Last edit: 

Contributors: 

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 marketplace-kit data export command. It accepts one option:

  • --path (short: -p): A file path to a JSON file which will be created by the CLI and where the exported data is stored.

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:


marketplace-kit 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]

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
      }
    }
  }
  transactables: listings(per_page: 10000, listing: { is_deleted: false }) {
    total_entries
    results {
      type_name: type
      id
      name
      slug
      creator_id
      created_at
      updated_at
      ...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. Check out our Help page, or contact us.