Export

Using an existing import profile

In order to launch a new export with API using an existing export profile, you will need to :

  • know the unique ID of your export Profile
  • ask for a new export with this profile id
  • wait for the export to be done
  • download the generated file

Retrieve Export Profile ID

Let's retrieve the Export Profile ID. This call will list all profiles that have been defined in your PIM instance.

import requests
import json
url = "https://_SUBDOMAIN_.quable.com/api/export-profiles"
headers = {
  'Content-Type': 'application/hal+json',
  'Authorization': 'Bearer _BEARER_'
}
response = requests.request("GET", url, headers=headers)
print(response.json())
{
    "hydra:member": [
        {
            "id": "b7e49edf-acb7-4a09-8f2c-706e8a3aefc7",
            "name": "e-Commerce export",
            ...
        },
        {
            "id": "c1e4baf8-8f81-40d1-a5dc-bfa7953622c2",
            "name": "English Print",
            ...
        }
    ],
    ...
    "hydra:totalItems": 2
}

Launch a new export

Now that you know the Export Profile ID, you can ask for a new export :

import requests
import json
url = "https://_SUBDOMAIN_.quable.com/api/exports"
payload = json.dumps({
    "exportProfileId": "_EXPORTPROFILEID_"
})
headers = {
  'Content-Type': 'application/hal+json',
  'Authorization': 'Bearer _BEARER_'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.json())

The 200 Response will contain an ID. This is the unique ID of the export you have asked for.

Check if an export is finished

An export could take a few seconds / minutes depending of your datas.
You will need to ask for the statement of the process you started :

import requests
import json
url = "https://_SUBDOMAIN_.quable.com/api/processes/__EXPORTID__"
headers = {
  'Content-Type': 'application/hal+json',
  'Authorization': 'Bearer _BEARER_'
}
response = requests.request("GET", url, headers=headers)
print(response.json())

Once the status is finished, the CSV will be available (see files[type=export] node).
See the response below :

{
    'id': '__EXPORTID__',
    'type': 'export',
    'status': 'finished',
    ...
    'files': [{
        'id': '__FILEID__',
        'status': 'available',
        'type': 'export',
        'isDownloadable': True
    }],
    ...
    'dateCreated': '2021-12-13T16:26:18+00:00',
    'startDate': '2021-12-13T16:26:18+00:00',
    'endDate': '2021-12-13T16:26:19+00:00'
}

Download the generated file

You can now download the file :

import requests
import json
url = "https://_SUBDOMAIN_.quable.com/api/files/__FILEID__/download"
headers = {
  'Content-Type': 'application/hal+json',
  'Authorization': 'Bearer _BEARER_'
}
response = requests.request("GET", url, headers=headers)
open('_FILENAME_.zip', 'wb').write(response.content)