{
  "openapi": "3.1.0",
  "info": {
    "title": "CommodityScope Partner Series Feed",
    "version": "1.0.0",
    "description": "Read one published commodity series per request. The response contains the series code, name, unit, frequency, the URL of its public page and its recent observations: up to 45 points, including the latest one.\n\nBy default a key allows 48 billable requests in a rolling 24 hours; a key can have its own limit. 401 and 429 responses do not consume the limit; 403 and 404 responses do. The API key is free and is issued by email.\n\nGET and HEAD are supported; every other method returns 405. Only the published window is available: there is no full history and no bulk extraction. Full history is available in My Desk.",
    "termsOfService": "https://commodityscope.com/terms",
    "contact": {
      "name": "CommodityScope",
      "url": "https://commodityscope.com/about#contact",
      "email": "desk@commodityscope.com"
    }
  },
  "servers": [
    {
      "url": "https://commodityscope.com",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "API guide",
    "url": "https://commodityscope.com/tools/api"
  },
  "tags": [
    {
      "name": "Series",
      "description": "Published series windows."
    }
  ],
  "paths": {
    "/desk/api/feed/{code}": {
      "get": {
        "tags": [
          "Series"
        ],
        "operationId": "getPublishedSeries",
        "summary": "Read one published series window",
        "description": "Returns the latest observation and up to 45 recent observations for one series. The presented key must include the requested series.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "Public series code (`CS-...`) or numeric China series ID. Use the canonical uppercase form; the server also accepts lower case and underscores.",
            "schema": {
              "type": "string",
              "maxLength": 80,
              "pattern": "^(?:CS-[A-Z0-9]+(?:-[A-Z0-9]+)*|[1-9][0-9]{0,5})$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The published window for the requested series.",
            "headers": {
              "Cache-Control": {
                "description": "no-store",
                "schema": {
                  "type": "string"
                }
              },
              "X-Content-Type-Options": {
                "description": "nosniff",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SeriesWindow"
                }
              }
            }
          },
          "401": {
            "description": "A valid API key is required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "This key does not include that series.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "This series is not in the current publication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "The daily request limit for this key is reached. It frees up within 24 hours.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "API key issued by email."
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "The same API key presented as a bearer token."
      }
    },
    "schemas": {
      "Observation": {
        "type": "object",
        "description": "One published observation.",
        "required": [
          "date",
          "value"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "description": "Observation date."
          },
          "value": {
            "type": "number",
            "description": "Published value."
          },
          "low": {
            "type": "number",
            "description": "Lower bound of the published range. Present only when the range is wider than zero."
          },
          "high": {
            "type": "number",
            "description": "Upper bound of the published range. Present only when the range is wider than zero."
          }
        },
        "additionalProperties": false
      },
      "SeriesWindow": {
        "type": "object",
        "description": "One published series and its recent observations.",
        "required": [
          "code",
          "name",
          "unit",
          "frequency",
          "page",
          "latest",
          "recent"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Public series code."
          },
          "name": {
            "type": "string",
            "description": "Published series name."
          },
          "unit": {
            "type": "string",
            "description": "Published measurement unit."
          },
          "frequency": {
            "type": "string",
            "description": "Published publication frequency."
          },
          "page": {
            "type": "string",
            "format": "uri",
            "description": "Absolute URL of the public series page."
          },
          "latest": {
            "$ref": "#/components/schemas/Observation"
          },
          "recent": {
            "type": "array",
            "description": "Recent observations in chronological order, oldest first; includes the latest observation.",
            "minItems": 1,
            "maxItems": 45,
            "items": {
              "$ref": "#/components/schemas/Observation"
            }
          }
        },
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "description": "Error response body.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Exact published error message."
          }
        },
        "additionalProperties": false
      }
    }
  }
}
