{
  "openapi": "3.1.0",
  "info": {
    "title": "World Radio Now public station directory API",
    "version": "1.0.0",
    "description": "Read-only metadata search for an independent radio listening directory. No account or API key required. Snapshot metadata is not a guarantee of current playback. page_url and listen_url open World Radio Now HTML pages; official_url identifies the broadcaster. Documentation: https://worldradionow.top/developers/"
  },
  "servers": [
    {
      "url": "https://worldradionow.top"
    }
  ],
  "security": [],
  "paths": {
    "/api/stations": {
      "get": {
        "operationId": "searchStations",
        "summary": "Find stations by name, country, language or topic",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Case-insensitive station/name/country/location/language/topic words. All words must match.",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "country",
            "in": "query",
            "description": "ISO 3166-1 alpha-2 country code, e.g. GB.",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{2}$"
            }
          },
          {
            "name": "language",
            "in": "query",
            "description": "Exact source language label or mapped ISO code, e.g. english or en.",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 60
            }
          },
          {
            "name": "genre",
            "in": "query",
            "description": "Exact source topic tag, e.g. news.",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 60
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Results per page.",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Zero-based result offset.",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 5000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching records from the directory snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schema_version": {
                      "type": "string"
                    },
                    "snapshot_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "source": {
                      "type": "string"
                    },
                    "ranking": {
                      "const": "name_match_then_alphabetical"
                    },
                    "q": {
                      "type": "string"
                    },
                    "country": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "language": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "genre": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Station"
                      }
                    },
                    "next": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Next JSON result page, or null"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid filter or pagination",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/stations/{id}": {
      "get": {
        "operationId": "getStation",
        "summary": "Read a station record by its directory UUID",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Station metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schema_version": {
                      "type": "string"
                    },
                    "snapshot_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "source": {
                      "type": "string"
                    },
                    "station": {
                      "$ref": "#/components/schemas/Station"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Station is not present in this snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Station": {
        "type": "object",
        "required": [
          "id",
          "name",
          "page_url",
          "listen_url",
          "country",
          "country_code",
          "languages",
          "genres"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Radio Browser station UUID"
          },
          "name": {
            "type": "string"
          },
          "page_url": {
            "type": "string",
            "format": "uri"
          },
          "listen_url": {
            "type": "string",
            "format": "uri",
            "description": "Canonical World Radio Now HTML listening page, not a raw audio URL"
          },
          "country": {
            "type": "string"
          },
          "country_code": {
            "type": "string"
          },
          "location": {
            "type": "string"
          },
          "languages": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Source directory labels; English aliases and ISO codes are accepted by the language filter where mapped"
          },
          "genres": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bitrate_kbps": {
            "type": [
              "integer",
              "null"
            ]
          },
          "official_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Broadcaster website, distinct from the listening page"
          },
          "country_url": {
            "type": "string",
            "format": "uri"
          },
          "language_codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "language_urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "genre_urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "location_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "page_title": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
