{
  "openapi": "3.1.0",
  "info": {
    "title": "Data Shared API",
    "version": "1.3.0",
    "summary": "Read datasets that PX Data shares with you, over HTTPS with an API key.",
    "description": "The Data Shared API serves configured datasets of PX Data. Each dataset has an\nidentifier (the `dataset` parameter) and a source: S3, Athena, Timestream, RDS or\nthe shared PostgreSQL (`shared_rds`). Which parameters and modes apply depends on\nthe source type of the dataset; `metadata=true` describes a dataset.\n\n**Sign-in.** Send your API key in the header `X-Api-Key`. A key reads only the\ndatasets it was granted; ask the data team for a key and the dataset names.\n\n**Paging.** Large results come in pages: pass `paginate=true`, then the\n`next_token` of each answer as `page-token`, until `next_token` is null.\n`page-size` sets the rows per page (default 1000). Athena datasets start a query\nfirst (HTTP 202 with `job_id`), which you poll with `job-id`.\n`download=true` returns a pre-signed URL of the whole result instead of rows.\n\n**Errors.** JSON with `error` (from the API) or `message` (from the gateway,\nfor example a missing or unknown key).\n\n**Addresses.** Production `https://api.data.pl-x.de/v1`; this document at\n`/openapi.json` and `/openapi.yaml`, a short guide for agents at `/llms.txt`.\nA route for machine clients of PxUser (`/m2m/data`) exists but is not enabled\nin any environment yet.\n"
  },
  "servers": [
    {
      "url": "/v1",
      "description": "This environment (the address this documentation is served from)"
    },
    {
      "url": "https://api.data.pl-x.de/v1",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "datasets",
      "description": "Read a dataset or its metadata"
    }
  ],
  "paths": {
    "/data": {
      "get": {
        "tags": [
          "datasets"
        ],
        "summary": "Get dataset data or metadata",
        "description": "Returns dataset content in its delivery format (JSON or CSV; binary for passthrough) or metadata when `metadata=true`. Time windows and other filters can be provided via query params; the backend substitutes them into connector queries where applicable (e.g., Timestream/Athena placeholders).\n",
        "operationId": "getData",
        "parameters": [
          {
            "name": "dataset",
            "in": "query",
            "required": true,
            "description": "Dataset identifier, as given to you with your key",
            "schema": {
              "type": "string"
            },
            "example": "my_dataset"
          },
          {
            "name": "metadata",
            "in": "query",
            "required": false,
            "description": "When true, return metadata only",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "ISO-8601 start time (used for time-windowed sources)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "description": "ISO-8601 end time (used for time-windowed sources)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "minutes",
            "in": "query",
            "required": false,
            "description": "Relative window in minutes (alternative to since/until)",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "hours",
            "in": "query",
            "required": false,
            "description": "Relative window in hours",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "Relative window in days",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "weeks",
            "in": "query",
            "required": false,
            "description": "Relative window in weeks",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "months",
            "in": "query",
            "required": false,
            "description": "Relative window in months (30-day approximation)",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "quarters",
            "in": "query",
            "required": false,
            "description": "Relative window in quarters (90-day approximation)",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "years",
            "in": "query",
            "required": false,
            "description": "Relative window in years (365-day approximation)",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "additional-filters",
            "in": "query",
            "required": false,
            "description": "Any other query parameter is used when the dataset declares it: as the value of a placeholder of that name in the dataset's query (`{customer_id}` for Athena and Timestream, `:customer_id` for RDS and the shared PostgreSQL), or, for S3 datasets, as an equality filter on a column listed in the dataset's `filterable`. A placeholder without a default value is required (400 when missing).\n",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "start",
            "in": "query",
            "required": false,
            "description": "Example of a dataset parameter, used by many Athena datasets. Substituted into the query template as an escaped string literal (placeholder `{start}`). Commonly an ISO date like 2026-01-10.\n",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "end",
            "in": "query",
            "required": false,
            "description": "Example of a dataset parameter, used by many Athena datasets. Substituted into the query template as an escaped string literal (placeholder `{end}`). Commonly an ISO date like 2026-12-19.\n",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "paginate",
            "in": "query",
            "required": false,
            "description": "When true, returns the result page by page. Athena: starts the query or pages it using `job-id`. Timestream: pages the query. S3: pages a CSV or Parquet object. Datasets on the shared PostgreSQL with a page key answer in pages without it.\n",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "download",
            "in": "query",
            "required": false,
            "description": "When true, returns a pre-signed URL instead of the rows. Athena: URL of the result file (requires `job-id` after start). S3: URL of the object.\n",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "job-id",
            "in": "query",
            "required": false,
            "description": "Athena only. The `job_id` returned from a start request. (Also accepted as `job_id`.)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page-token",
            "in": "query",
            "required": false,
            "description": "The `next_token` of the previous page. (Also accepted as `page_token`.)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page-size",
            "in": "query",
            "required": false,
            "description": "Rows per page, default 1000. Upper limit by source: 1000 for Athena and Timestream, 5000 for the shared PostgreSQL, 10000 for S3. A page also ends early when it approaches the 6 MB response limit. (Also accepted as `page_size`.)\n",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000
            }
          },
          {
            "name": "expires-in",
            "in": "query",
            "required": false,
            "description": "S3 download only. Lifetime of the pre-signed URL in seconds (60 to 604800). (Also accepted as `expires_in`.)\n",
            "schema": {
              "type": "integer",
              "minimum": 60,
              "maximum": 604800,
              "default": 3600
            }
          },
          {
            "name": "chunk",
            "in": "query",
            "required": false,
            "description": "Athena-only. When true, reads the Athena result CSV in S3 using byte offsets (no re-query). Response content follows the dataset `delivery.format` (JSON by default, or CSV when configured).\n",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Athena-only. Byte offset into the result CSV (for chunk mode).",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "chunk-bytes",
            "in": "query",
            "required": false,
            "description": "Athena-only. Target chunk size in bytes (clamped to 1..5_000_000). (Also accepted as `chunk_bytes`.)",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 5000000
            }
          }
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "headers": {
              "X-Job-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "Athena QueryExecutionId (chunk mode only)"
              },
              "X-Next-Offset": {
                "schema": {
                  "type": "string"
                },
                "description": "Next byte offset into the result CSV (chunk mode only)"
              },
              "X-Total-Bytes": {
                "schema": {
                  "type": "string"
                },
                "description": "Total size of the result CSV in bytes (chunk mode only, when available)"
              },
              "X-Done": {
                "schema": {
                  "type": "string"
                },
                "description": "\"true\" or \"false\": whether the end of the file is reached (chunk mode only)"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/MetadataResponse"
                    },
                    {
                      "$ref": "#/components/schemas/AthenaPageResponse"
                    },
                    {
                      "$ref": "#/components/schemas/AthenaChunkResponse"
                    },
                    {
                      "$ref": "#/components/schemas/PageResponse"
                    },
                    {
                      "$ref": "#/components/schemas/DownloadResponse"
                    },
                    {
                      "$ref": "#/components/schemas/GenericJsonResponse"
                    }
                  ]
                },
                "examples": {
                  "page": {
                    "summary": "One page (paginate=true)",
                    "value": {
                      "columns": [
                        "day",
                        "url",
                        "visits"
                      ],
                      "items": [
                        {
                          "day": "2026-12-01",
                          "url": "https://www.example.com/a",
                          "visits": 42
                        }
                      ],
                      "next_token": "eyJuIjoiMiJ9",
                      "page_size_effective": 1
                    }
                  },
                  "last_page": {
                    "summary": "The last page",
                    "value": {
                      "columns": [
                        "day",
                        "url",
                        "visits"
                      ],
                      "items": [],
                      "next_token": null,
                      "page_size_effective": 0
                    }
                  }
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string",
                  "description": "CSV payload when delivery format is CSV"
                }
              },
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "byte",
                  "description": "Base64-encoded binary payload for passthrough/binary responses"
                }
              }
            }
          },
          "400": {
            "description": "Bad request (missing dataset, missing or invalid parameters, invalid page token, page too large)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The key is unknown to API Gateway or not attached to a usage plan (body `{\"message\": \"Forbidden\"}`), or the key lacks access to the dataset (body `{\"error\": \"Access denied\"}`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Dataset not found or empty result (when applicable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error or upstream connector failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "501": {
            "description": "Source type configured but not available yet (redshift)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "Shared PostgreSQL only. The query endpoint failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "202": {
            "description": "Accepted. Athena query started or still running (poll with `job-id`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AthenaAsyncResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key"
      }
    },
    "schemas": {
      "MetadataResponse": {
        "type": "object",
        "description": "Dataset metadata",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "schema": {
            "type": "object"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "GenericJsonResponse": {
        "description": "Generic dataset payload (non-Athena async mode), usually a JSON array of objects.",
        "oneOf": [
          {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          {
            "type": "object"
          }
        ]
      },
      "AthenaPageResponse": {
        "type": "object",
        "description": "Athena paginated page response (HTTP 200 when SUCCEEDED). Values in `items` are strings, numbers included. `next_token` is null on the last page.\n",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "succeeded"
            ]
          },
          "next_token": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as `page-token` for the next page; null on the last page."
          },
          "header_dropped": {
            "type": "boolean"
          },
          "page_size_effective": {
            "type": "integer"
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "PageResponse": {
        "type": "object",
        "description": "One page of an S3, Timestream or shared PostgreSQL dataset. `next_token` is null on the last page.\n",
        "properties": {
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "next_token": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as `page-token` for the next page; null on the last page."
          },
          "page_size_effective": {
            "type": "integer"
          }
        }
      },
      "DownloadResponse": {
        "type": "object",
        "description": "Pre-signed URL of an Athena result file or of an S3 object.",
        "properties": {
          "job_id": {
            "type": "string",
            "description": "Athena query id, or the object key for S3 datasets."
          },
          "download_url": {
            "type": "string"
          },
          "expires_in": {
            "type": "integer",
            "description": "S3 datasets only."
          },
          "bytes": {
            "type": "integer",
            "description": "S3 datasets only. Size of the object."
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "description": "Error answer. `error` comes from the API itself, `message` from the gateway (for example a missing or unknown API key, or throttling).\n",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {
            "type": "object"
          }
        },
        "examples": [
          {
            "error": "Dataset not found"
          },
          {
            "message": "Forbidden"
          }
        ]
      },
      "AthenaAsyncResponse": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "succeeded"
            ]
          },
          "next_token": {
            "type": "string"
          },
          "header_dropped": {
            "type": "boolean",
            "description": "True when Athena header row was removed from the page."
          },
          "page_size_effective": {
            "type": "integer",
            "description": "Number of returned data rows in this page."
          },
          "download_url": {
            "type": "string"
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "AthenaChunkResponse": {
        "type": "object",
        "description": "Athena chunk response when `chunk=true` and dataset `delivery.format` is JSON.",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "succeeded"
            ]
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "next_offset": {
            "type": "integer"
          },
          "done": {
            "type": "boolean"
          },
          "total_bytes": {
            "type": "integer"
          }
        }
      }
    }
  }
}
