{
  "openapi": "3.1.0",
  "info": {
    "title": "G Network Australian Lottery API",
    "version": "v1",
    "summary": "Australian lottery draw results as JSON: Saturday Lotto, Oz Lotto, Powerball and Weekday Windfall.",
    "description": "Latest draw results for the four national Australian lotto games. Free for personal, non-commercial use with a free API key: create a G Network account at https://gnetwork.com.au/auth/signup, confirm your email, turn on API access in your profile and generate a key (it is shown once). 60 requests per rolling hour per key. Results are updated by about 01:05 AEST the morning after each draw. For the full history, download every past draw as CSV or JSON at https://gnetwork.com.au/tools/download instead of calling the API repeatedly. Wherever you show or publish this data, credit \"Source: G Network (gnetwork.com.au)\"; every response carries this line in meta.attribution.",
    "termsOfService": "https://gnetwork.com.au/tos/",
    "contact": { "name": "G Network", "url": "https://gnetwork.com.au/contact" }
  },
  "externalDocs": { "description": "API documentation and examples", "url": "https://gnetwork.com.au/australian-lottery-api" },
  "servers": [ { "url": "https://api.gnetwork.com.au" } ],
  "security": [ { "bearerKey": [] }, { "queryKey": [] } ],
  "paths": {
    "/v1": {
      "get": {
        "operationId": "getApiIndex",
        "summary": "API index (no key needed)",
        "description": "Self-describing index: endpoints, output modes, how to get a free key, and alternatives for full history.",
        "security": [],
        "responses": {
          "200": { "description": "The index", "content": { "application/json": { "schema": { "type": "object", "additionalProperties": true } } } }
        }
      }
    },
    "/v1/draws/recent": {
      "get": {
        "operationId": "getRecentDraw",
        "summary": "Most recent draw for a draw night",
        "description": "Returns the latest draw held on the given night. tuesday = Oz Lotto, thursday = Powerball, saturday = Saturday Lotto (Gold Lotto, Tattslotto), monday / wednesday / friday = Weekday Windfall. /v1/draws is an alias.",
        "parameters": [
          {
            "name": "day", "in": "query", "required": true,
            "description": "Draw night.",
            "schema": { "type": "string", "enum": ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] },
            "example": "saturday"
          },
          {
            "name": "output", "in": "query", "required": true,
            "description": "1 = draw details and numbers, 2 = division results and payouts, 3 = everything (numbers, divisions and the draw video's YouTube id).",
            "schema": { "type": "integer", "enum": [1, 2, 3] },
            "example": 3
          }
        ],
        "responses": {
          "200": { "description": "The draw", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DrawResponse" } } } },
          "400": { "$ref": "#/components/responses/Error" },
          "401": { "$ref": "#/components/responses/Error" },
          "404": { "$ref": "#/components/responses/Error" },
          "429": { "$ref": "#/components/responses/Error" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerKey": { "type": "http", "scheme": "bearer", "description": "Free API key sent as \"Authorization: Bearer {key}\"." },
      "queryKey": { "type": "apiKey", "in": "query", "name": "api_key", "description": "The same key as ?api_key={key}." }
    },
    "responses": {
      "Error": {
        "description": "Error (missing or bad parameter, no or bad key, not found, or rate limited)",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
      }
    },
    "schemas": {
      "DrawResponse": {
        "type": "object",
        "required": ["ok", "draw", "meta"],
        "properties": {
          "ok": { "type": "boolean", "const": true },
          "draw": { "$ref": "#/components/schemas/Draw" },
          "meta": {
            "type": "object",
            "properties": {
              "generated_at": { "type": "string", "format": "date-time" },
              "rate_limit": { "type": "object", "properties": { "limit": { "type": "integer" }, "remaining": { "type": "integer" }, "window": { "type": "string" } } },
              "data_freshness": { "type": "string" },
              "source": { "type": "string", "example": "G Network (gnetwork.com.au)" },
              "attribution": { "type": "string", "description": "The credit to show with this data." },
              "terms": { "type": "string", "format": "uri" }
            }
          }
        }
      },
      "Draw": {
        "type": "object",
        "description": "Fields depend on output: 1 has the details and numbers, 2 has draw_number, draw_date and divisions, 3 has everything.",
        "properties": {
          "game": { "type": "string", "enum": ["saturday-lotto", "oz-lotto", "powerball", "weekday-windfall"] },
          "game_name": { "type": "string" },
          "draw_number": { "type": "integer", "example": 4721 },
          "draw_date": { "type": "string", "format": "date", "example": "2026-10-17" },
          "day_of_week": { "type": "string", "example": "Saturday" },
          "numbers": { "type": "array", "items": { "type": "integer" }, "description": "Winning numbers in draw order." },
          "supplementary": { "type": "array", "items": { "type": "integer" }, "description": "Supplementary numbers (none for Powerball)." },
          "powerball": { "type": "integer", "description": "Powerball draws only." },
          "divisions": { "type": "array", "items": { "$ref": "#/components/schemas/Division" } },
          "youtube_id": { "type": ["string", "null"], "description": "YouTube id of the official draw video, when known." }
        }
      },
      "Division": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "div": { "type": "integer", "description": "Prize division, 1 is the top prize." },
          "winners": { "type": "integer", "description": "Winning entries nationally." },
          "pool": { "type": "number", "description": "Total prize pool for the division, AUD." },
          "amount": { "type": "number", "description": "Prize per winning entry, AUD." }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "const": false },
          "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "additionalProperties": true }
        }
      }
    }
  }
}
