{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mediastash.pages.dev/schema/mediastash.instagram-1.json",
  "title": "MediaStash Instagram record (mediastash.instagram/1)",
  "description": "Metadata of one Instagram post, embedded by the MediaStash browser extension in every downloaded file (MP4/M4A `comment` tag, MP3 ID3 COMM frame, JPEG COM segment + XMP dc:description, WebP XMP dc:description) and written as one line per post to _index.jsonl. Counts are a snapshot taken at `captured_at`. New optional fields may be added within version 1; readers should ignore unknown fields.",
  "type": "object",
  "required": [
    "schema",
    "platform",
    "type",
    "url",
    "author",
    "posted_at",
    "caption",
    "captured_at",
    "tool"
  ],
  "properties": {
    "schema": {
      "const": "mediastash.instagram/1",
      "description": "Schema id and version."
    },
    "platform": {
      "const": "instagram",
      "description": "Platform the record describes."
    },
    "type": {
      "enum": [
        "reel",
        "carousel",
        "post",
        "video",
        "story",
        "profile_picture",
        "audio"
      ],
      "description": "Post type. profile_picture and audio records omit the post-only fields."
    },
    "url": {
      "type": [
        "string",
        "null"
      ],
      "description": "URL of the post, reel, story, profile or audio page.",
      "format": "uri"
    },
    "shortcode": {
      "type": [
        "string",
        "null"
      ],
      "description": "Code in the post URL; null for stories."
    },
    "media_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Instagram media id (numeric, as a string)."
    },
    "author": {
      "type": "object",
      "required": [
        "username",
        "full_name",
        "verified"
      ],
      "properties": {
        "username": {
          "type": [
            "string",
            "null"
          ],
          "description": "Username without @."
        },
        "full_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Display name."
        },
        "verified": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Verified badge at the time of download."
        },
        "id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Account id (profile pictures only)."
        }
      }
    },
    "posted_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "Publication time, ISO 8601 (UTC).",
      "format": "date-time"
    },
    "caption": {
      "type": [
        "string",
        "null"
      ],
      "description": "Full caption text."
    },
    "hashtags": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Unique hashtags from the caption, with #."
    },
    "mentions": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Unique @mentions from the caption, with @."
    },
    "location": {
      "type": [
        "object",
        "null"
      ],
      "description": "Tagged location.",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Place name."
        },
        "city": {
          "type": [
            "string",
            "null"
          ],
          "description": "City."
        },
        "lat": {
          "type": [
            "number",
            "null"
          ],
          "description": "Latitude."
        },
        "lng": {
          "type": [
            "number",
            "null"
          ],
          "description": "Longitude."
        }
      }
    },
    "music": {
      "type": [
        "object",
        "null"
      ],
      "description": "Sound used by the post.",
      "properties": {
        "title": {
          "type": [
            "string",
            "null"
          ],
          "description": "Track title."
        },
        "artist": {
          "type": [
            "string",
            "null"
          ],
          "description": "Artist or account."
        },
        "original_audio": {
          "type": "boolean",
          "description": "true for the creator’s own sound."
        }
      }
    },
    "collaborators": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Usernames of collab-post co-authors."
    },
    "tagged_users": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Usernames tagged in the media."
    },
    "paid_partnership": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "Marked as a paid partnership."
    },
    "caption_edited": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "Caption edited after posting."
    },
    "stats": {
      "type": "object",
      "description": "Public counts at captured_at; null when unknown or hidden.",
      "properties": {
        "views": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Views or plays."
        },
        "likes": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Likes."
        },
        "comments": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Comments."
        },
        "shares": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Shares."
        },
        "reposts": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Reposts."
        },
        "saves": {
          "type": "null",
          "description": "Not public on Instagram: always null."
        }
      }
    },
    "stats_hidden_by_creator": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "The creator hid like and view counts."
    },
    "stats_note": {
      "type": "string",
      "description": "Reminder that counts are a snapshot."
    },
    "captured_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the file was saved (ISO 8601, UTC)."
    },
    "tool": {
      "type": "string",
      "pattern": "^mediastash/",
      "description": "mediastash/<extension version>."
    },
    "item": {
      "type": "object",
      "description": "Which part of the post this file is (embedded in files only, not in _index.jsonl).",
      "properties": {
        "index": {
          "type": "integer",
          "minimum": 1,
          "description": "1-based position (carousel slide)."
        },
        "count": {
          "type": "integer",
          "minimum": 1,
          "description": "Number of items in the post."
        },
        "kind": {
          "enum": [
            "image",
            "video",
            "audio",
            "cover"
          ],
          "description": "What this file holds."
        },
        "width": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Pixels."
        },
        "height": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Pixels."
        },
        "duration": {
          "type": [
            "number",
            "null"
          ],
          "description": "Seconds."
        }
      }
    },
    "audio": {
      "type": "object",
      "description": "Audio-only files of songs and audio pages.",
      "properties": {
        "id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Audio asset id."
        },
        "title": {
          "type": [
            "string",
            "null"
          ],
          "description": "Track title."
        },
        "artist": {
          "type": [
            "string",
            "null"
          ],
          "description": "Artist."
        },
        "original_audio": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "The creator’s own sound."
        },
        "duration_ms": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Duration in milliseconds."
        }
      }
    },
    "source_post": {
      "type": [
        "string",
        "null"
      ],
      "description": "Audio-page downloads: a reel that uses the sound.",
      "format": "uri"
    },
    "files": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "_index.jsonl only: names of the files saved for this post."
    }
  },
  "additionalProperties": true
}
