Code samples

Add MCP server to your AI tool

Allow AI tools and LLMs to interact with the API documentation portal through MCP.

MCP server URL

https://api-doc.ppe-analytics.com/mcp

Standard setup for AI tools providing an mcp.json file

mcp.json
"Deck API MCP server": {
  "url": "https://api-doc.ppe-analytics.com/mcp"
}
Close

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 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"

  template_rows        = []
  slice_number         = 1
  has_remaining_slices = True

  # Iterate on all slices
  while has_remaining_slices:
      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"]

      template_rows.extend(result["rows"])

      has_remaining_slices = slice_number < result["pagination"]["max_slice_number"]

      slice_number += 1

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