{
    "format": "ndjson",
    "definitions": {},
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "http://example.com/root.json",
    "type": "object",
    "title": "Spotify Aggregated Streams Schema",
    "required": [
    ],
    "properties": {
        "licensor": {
            "$id": "#/properties/licensor",
            "type": "string",
            "title": "The licensor",
            "default": "",
            "examples": [
                "Wagram"
            ],
            "pattern": "^(.+)$"
        },
        "album": {
            "$id": "#/properties/album",
            "type": "object",
            "properties": {
                "name": {
                    "$id": "#/properties/album/properties/name",
                    "type": "string",
                    "title": "Name of the album",
                    "default": "",
                    "examples": [
                        "Mon Coffret Naissance"
                    ],
                    "pattern": "^(.*)$"
                },
                "href": {
                    "$id": "#/properties/album/properties/href",
                    "type": "string",
                    "title": "Spotify album URI",
                    "default": "",
                    "examples": [
                        "spotify:album:1ZPk485ne31zeP1AY8vSAr"
                    ],
                    "pattern": "^spotify:album:([a-zA-Z0-9]+)$"
                }
            }
        },
        "message_name": {
            "$id": "#/properties/message_name",
            "type": "string",
            "title": "API type",
            "default": "",
            "examples": [
                "APIAggregatedStreamData"
            ],
            "pattern": "^([\\w]*)$"
        },
        "trackv2": {
            "$id": "#/properties/trackv2",
            "type": "object",
            "properties": {
                "name": {
                    "$id": "#/properties/trackv2/properties/name",
                    "type": "string",
                    "title": "Track name/ Video name",
                    "default": "",
                    "examples": [
                        "Bonsoir Madame la Lune"
                    ],
                    "pattern": "^(.*)$"
                },
                "href": {
                    "$id": "#/properties/trackv2/properties/href",
                    "type": "string",
                    "title": "Spotify track URI / Spotify Video URI",
                    "default": "",
                    "examples": [
                        "spotify:track:18wwmUOYAd8vehDVoB6SIz"
                    ],
                    "pattern": "^spotify:track:([a-zA-Z0-9]+)$"
                },
                "isrc": {
                    "$id": "#/properties/trackv2/properties/isrc",
                    "type": "string",
                    "title": "Track/ Video ISRC",
                    "default": "",
                    "examples": [
                        "USMC15804831"
                    ],
                    "pattern": "^([A-Z]{2}-?\\w{3}-?\\d{2}-?\\d{5})?$"
                }
            }
        },
        "label": {
            "$id": "#/properties/label",
            "type": "string",
            "title": "Label name",
            "default": "",
            "examples": [
                "Wagram Music"
            ],
            "pattern": "^(.*)$"
        },
        "version": {
            "$id": "#/properties/version",
            "type": "string",
            "title": "API versionr",
            "default": "",
            "examples": [
                "2"
            ],
            "pattern": "^([\\d]+)$"
        },
        "streams": {
            "$id": "#/properties/streams",
            "type": "object",
            "properties": {
                "total": {
                    "$id": "#/properties/streams/properties/total",
                    "type": "integer",
                    "title": "Total number of streams (for report date)",
                    "examples": [
                        "1"
                    ],
                    "pattern": "^(\\d+)$"
                }
            }
        },
        "skips": {
            "$id": "#/properties/skips",
            "type": "object",
            "properties": {
                "total": {
                    "$id": "#/properties/skips/properties/total",
                    "title": "Total number of fewer than 30 second plays, per country",
                    "type": "integer",
                    "examples": [
                        "2"
                    ],
                    "pattern": "^(\\d+)$"
                },
                "country": {
                    "type": "object",
                    "title": "The country",
                    "patternProperties": {
                        "^[a-zA-Z]{2}$": {
                            "type": "object",
                            "properties": {
                                "total": {
                                    "type": "integer",
                                    "pattern": "^(\\d+)$"
                                }
                            }
                        }
                    }
                }
            }
        },
        "saves": {
            "$id": "#/properties/saves",
            "type": "object",
            "properties": {
                "total": {
                    "$id": "#/properties/saves/properties/total",
                    "title": "Number of saves per country. If user saves a track multiple times (e.g. to multiple playlists), we cap count at 1 save/user.",
                    "type": "integer",
                    "examples": [
                        "3"
                    ],
                    "pattern": "^(\\d+)$"
                },
                "country": {
                    "type": "object",
                    "title": "The country",
                    "patternProperties": {
                        "^[a-zA-Z]{2}$": {
                            "type": "object",
                            "properties": {
                                "total": {
                                    "type": "integer",
                                    "pattern": "^(\\d+)$"
                                },
                                "product": {
                                    "type": "object",
                                    "free": {
                                        "title": "Total number of Savers per country per free product type. If user saves a track multiple times (e.g. to multiple playlists), we cap count at 1 save/user",
                                        "type": "integer",
                                        "examples": [
                                            "3"
                                        ],
                                        "pattern": "^(\\d+)$"
                                    },
                                    "premium": {
                                        "title": "Total number of Savers per country per premium product type. If user saves a track multiple times (e.g. to multiple playlists), we cap count at 1 save/user",
                                        "type": "integer",
                                        "examples": [
                                            "3"
                                        ],
                                        "pattern": "^(\\d+)$"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "country": {
            "$id": "#/properties/country",
            "title": "The country",
            "type": "object",
            "patternProperties": {
                "^[a-zA-Z]{2}$": {
                    "properties": {
                        "sex": {
                            "type": "object",
                            "patternProperties": {
                                "^([a-zA-Z]+)$": {
                                    "properties": {
                                        "age": {
                                            "type": "object",
                                            "patternProperties": {
                                                "^([\\d]+-[\\d]+)$": {
                                                    "type": "string",
                                                    "pattern": "^([\\d]+)$"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        "total": {
                            "type": "integer",
                            "pattern": "^([\\d]+$)"
                        }
                    }
                }
            }
        },
        "age": {
            "$id": "#/properties/age",
            "type": "string",
            "examples": []
        },
        "sex": {
            "$id": "#/properties/sex",
            "type": "string",
            "title": "The user gender",
            "examples": [
                "female",
                "male"
            ],
            "pattern": "^(\\w+)$"
        },
        "date": {
            "$id": "#/properties/date",
            "type": "string",
            "title": "Date requested",
            "examples": [
                "2013-11-28"
            ],
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "artists": {
            "$id": "#/properties/artists",
            "type": "object",
            "properties": {
                "names": {
                    "$id": "#/properties/artists/properties/names",
                    "type": "string",
                    "title": "Artist name. Comma-separated if multiple",
                    "default": "",
                    "examples": [
                        "Solhal,Solhal alterego"
                    ],
                    "pattern": "^(.*)$"
                },
                "hrefs": {
                    "$id": "#/properties/artists/properties/hrefs",
                    "type": "string",
                    "title": "Spotify URI. Comma-separated if multiple.",
                    "default": "",
                    "examples": [
                        "spotify:artist:18wwmUOYAd8vehDVoB6SIz,spotify:artist:18wwmUOYAd8vehDVoB6SIz"
                    ],
                    "pattern": "^(.*)$"
                }
            }
        }
    }
}
