{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/sociallisteningapi/main/json-schema/sociallisteningapi-discovery-search-response-schema.json",
  "title": "DiscoverySearchResponse",
  "x-generated": "2026-09-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sociallisteningapi-openapi.yml#/components/schemas/DiscoverySearchResponse",
  "type": "object",
  "required": [
    "success",
    "platform",
    "endpoint",
    "data",
    "pagination",
    "request_id",
    "credits_used",
    "credits_remaining"
  ],
  "properties": {
    "success": {
      "type": "boolean",
      "const": true
    },
    "platform": {
      "type": "string",
      "const": "instagram"
    },
    "endpoint": {
      "type": "string"
    },
    "data": {
      "$ref": "#/$defs/DiscoverySearchData"
    },
    "pagination": {
      "$ref": "#/$defs/Pagination"
    },
    "raw": {
      "$ref": "#/$defs/RawResponse"
    },
    "request_id": {
      "type": "string"
    },
    "credits_used": {
      "type": "integer",
      "minimum": 0
    },
    "credits_remaining": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0
    }
  },
  "additionalProperties": false,
  "$defs": {
    "DiscoveryResult": {
      "type": "object",
      "required": [
        "id",
        "platform",
        "type",
        "name",
        "username",
        "url",
        "image_url",
        "verified",
        "count",
        "ext"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "platform": {
          "type": "string",
          "const": "instagram"
        },
        "type": {
          "type": "string",
          "enum": [
            "user",
            "hashtag",
            "place"
          ]
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "username": {
          "type": [
            "string",
            "null"
          ]
        },
        "url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "image_url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "verified": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "count": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "ext": {
          "type": "object",
          "description": "Platform-specific normalized discovery fields.",
          "additionalProperties": true
        }
      },
      "additionalProperties": false
    },
    "DiscoverySearchData": {
      "type": "object",
      "required": [
        "items"
      ],
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DiscoveryResult"
          }
        }
      },
      "additionalProperties": false
    },
    "Pagination": {
      "type": "object",
      "required": [
        "next_cursor",
        "has_more",
        "page_size"
      ],
      "properties": {
        "next_cursor": {
          "type": [
            "string",
            "null"
          ],
          "description": "A provider cursor for a future paginated request, when available."
        },
        "has_more": {
          "type": "boolean"
        },
        "page_size": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "RawResponse": {
      "description": "The unchanged upstream provider response. Returned only when the request sets raw to true."
    }
  }
}