In this section you'll find a few basic examples on ways to consume the API with Python scripts.

This can of course be adapted to any language. For production usage, you should handle error responses as well.

Export SKUs or products data with pagination

  '''
  Export SKUs or products data from Deck API configured template
  python3 deck_export_data.py
  '''
  import requests

  # Set script parameters
  item_type       = "skus"
  template_uuid   = "cf0c1a10-776d-41a9-9d65-85535be6f8ff"
  deck_api_url    = f"https://api.ppe-analytics.com/api/v1/export/{item_type}/{template_uuid}"
  deck_api_key    = "YOUR-API-KEY-HERE"

  all_rows = []
  slice_number = 1

  # Iterate on all pages
  while True:
      print(f"GET {deck_api_url} for slice {slice_number}...")

      result = requests.get(deck_api_url, headers={"PPEAPiKey": deck_api_key}, params={"slice_size": 50, "slice_number": slice_number}).json()["result"]

      all_rows.extend(result["rows"])

      if slice_number >= result["pagination"]["max_slice_number"]:
          break

      slice_number += 1

  # In the end, all_rows will contain all aggregated content, ready to be used
  print(all_rows)

  import requests