{
  "openapi": "3.1.0",
  "info": {
    "title": "Before The Data Intelligence API",
    "version": "1.0.0",
    "description": "Read-only access to BTD’s curated artist shortlist, current metrics, historical movement, spike signals, and signing indicators. Use from a secure server; never expose API keys in browser code.",
    "license": {
      "name": "Proprietary",
      "identifier": "LicenseRef-Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://beforethedata.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/v1/health": {
      "get": {
        "security": [],
        "summary": "API health",
        "operationId": "getHealth",
        "responses": {
          "200": {
            "description": "API process is available",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          }
        }
      }
    },
    "/api/v1/artists": {
      "get": {
        "summary": "List or search artists",
        "operationId": "listArtists",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 120
            },
            "description": "Case-insensitive artist-name search."
          },
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Return one stable artist ID."
          },
          {
            "name": "added_since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "tier",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "history"
              ]
            },
            "description": "Include artist and song metric history."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Opaque next_cursor from the previous response."
          }
        ],
        "responses": {
          "200": {
            "description": "Artist list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArtistListResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/artists/{id}": {
      "get": {
        "summary": "Get detailed artist record",
        "operationId": "getArtist",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Artist detail with metric history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArtistDetailResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/added": {
      "get": {
        "summary": "Artists added recently",
        "operationId": "listAddedArtists",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 90,
              "default": 7
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recently added artists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArtistListResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api/v1/spikes": {
      "get": {
        "summary": "Recent trusted movement signals",
        "operationId": "listSpikes",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 30,
              "default": 3
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Spike signals",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericListResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/signings": {
      "get": {
        "summary": "Signing indicators",
        "operationId": "listSignings",
        "description": "BTD-reviewed status plus P-line label markers. Indicators are not definitive relationship proof.",
        "responses": {
          "200": {
            "description": "Signing indicators",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericListResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "BTD organization API key"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid query parameters.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The key lacks the required scope.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "The requested record was not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Minute or daily quota exceeded.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unavailable": {
        "description": "Authentication, usage controls, or artist data are temporarily unavailable.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "MethodNotAllowed": {
        "description": "Method not allowed",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "request_id"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "type": "string"
              }
            }
          }
        }
      },
      "Health": {
        "type": "object",
        "required": [
          "status",
          "api_version",
          "generated_at"
        ],
        "properties": {
          "status": {
            "const": "ok"
          },
          "api_version": {
            "const": "v1"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "HistoryPoint": {
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "value": {
            "type": "number"
          },
          "estimated": {
            "type": "boolean"
          },
          "stale": {
            "type": "boolean"
          },
          "terminal": {
            "type": "boolean"
          }
        }
      },
      "Song": {
        "type": "object",
        "required": [
          "id",
          "name",
          "metrics"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "artwork": {
            "type": "string",
            "format": "uri"
          },
          "preview_url": {
            "type": "string",
            "format": "uri"
          },
          "source_url": {
            "type": "string"
          },
          "tiktok_url": {
            "type": "string"
          },
          "added_at": {
            "type": "string"
          },
          "metrics": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            }
          },
          "history": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/HistoryPoint"
              }
            }
          },
          "rights": {
            "type": "object",
            "properties": {
              "p_line": {
                "type": "string"
              },
              "checked_at": {
                "type": "string"
              }
            }
          }
        }
      },
      "Artist": {
        "type": "object",
        "required": [
          "id",
          "name",
          "status",
          "signing",
          "links",
          "metrics",
          "songs",
          "freshness",
          "provenance",
          "data_quality"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "photo_url": {
            "type": "string"
          },
          "genres": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "country_code": {
            "type": "string"
          },
          "date_added": {
            "type": "string",
            "format": "date"
          },
          "tier": {
            "type": "string"
          },
          "status": {
            "type": "object",
            "additionalProperties": {
              "type": "boolean"
            }
          },
          "signing": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string"
              },
              "note": {
                "type": "string"
              }
            }
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "metrics": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            }
          },
          "songs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Song"
            }
          },
          "history": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/HistoryPoint"
              }
            }
          },
          "freshness": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "provenance": {
            "type": "object"
          },
          "data_quality": {
            "type": "object"
          },
          "editorial": {
            "type": "object",
            "description": "Present only when the organization key includes editorial:read."
          }
        }
      },
      "Meta": {
        "type": "object",
        "required": [
          "api_version",
          "generated_at",
          "request_id"
        ],
        "properties": {
          "api_version": {
            "const": "v1"
          },
          "count": {
            "type": "integer"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "ArtistListResponse": {
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Artist"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        }
      },
      "ArtistDetailResponse": {
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Artist"
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        }
      },
      "GenericListResponse": {
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        }
      }
    }
  }
}
