{
    "openapi": "3.1.0",
    "info": {
        "title": "isopen opening hours API",
        "version": "1.0.0",
        "description": "Opening hours for a location by its code, for a date or a range of dates. No key is needed; send one as a bearer token for a higher rate limit. Private locations can only be read with a key belonging to their owner or team, and are 404 to everyone else."
    },
    "servers": [
        {
            "url": "http://isopen.co.uk/api/v1"
        }
    ],
    "security": [
        [],
        {
            "bearerKey": []
        }
    ],
    "paths": {
        "/locations/{code}/hours": {
            "get": {
                "operationId": "getHours",
                "summary": "Opening hours for a date or a range of dates",
                "description": "With no date it returns today in the location's own timezone. Responses carry an ETag; send it back as If-None-Match to get 304.",
                "parameters": [
                    {
                        "name": "code",
                        "in": "path",
                        "required": true,
                        "description": "The location's generated code (32 lowercase letters and digits) or its readable name. Not case sensitive.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "k7m2x9q4d8w3n5v6b1c0z8r4t2y7u9aj"
                    },
                    {
                        "name": "date",
                        "in": "query",
                        "description": "A single day. Cannot be combined with from and to.",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "First day of an inclusive range. Needs to.",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "Last day of an inclusive range. Needs from.",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "set",
                        "in": "query",
                        "description": "The slug of one of the location's other sets of hours, such as kitchen. Without it you get the main hours. 404 when the location has no such set.",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The hours.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Hours"
                                }
                            }
                        }
                    },
                    "304": {
                        "description": "Unchanged since the ETag you sent."
                    },
                    "404": {
                        "description": "No such location.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "A parameter is invalid, or the range is longer than 366 days.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "The API key sent is unknown, revoked or expired.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Too many requests. See the Retry-After header.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/locations/{code}/status": {
            "get": {
                "operationId": "getStatus",
                "summary": "Whether a location is open now, and when that next changes",
                "parameters": [
                    {
                        "name": "code",
                        "in": "path",
                        "required": true,
                        "description": "The location's generated code (32 lowercase letters and digits) or its readable name. Not case sensitive.",
                        "schema": {
                            "type": "string"
                        },
                        "example": "k7m2x9q4d8w3n5v6b1c0z8r4t2y7u9aj"
                    },
                    {
                        "name": "set",
                        "in": "query",
                        "description": "The slug of one of the location's other sets of hours, such as kitchen. Without it you get the main hours. 404 when the location has no such set.",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The current status.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Status"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No such location.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "The API key sent is unknown, revoked or expired.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Too many requests. See the Retry-After header.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/hours": {
            "get": {
                "operationId": "getHoursBatch",
                "summary": "Opening hours for several locations at once",
                "description": "Counts as one request for rate limiting.",
                "parameters": [
                    {
                        "name": "locations",
                        "in": "query",
                        "required": true,
                        "description": "Up to 25 codes or readable names, comma separated.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "date",
                        "in": "query",
                        "description": "A single day. Cannot be combined with from and to.",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "First day of an inclusive range. Needs to.",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "Last day of an inclusive range. Needs from.",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "set",
                        "in": "query",
                        "description": "The slug of one of the location's other sets of hours, such as kitchen. Without it you get the main hours. 404 when the location has no such set.",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "One result per location, in the order asked for.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/HoursBatch"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "A parameter is invalid, too many locations were asked for, or the range is longer than 31 days.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "The API key sent is unknown, revoked or expired.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Too many requests. See the Retry-After header.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/health": {
            "get": {
                "operationId": "getHealth",
                "summary": "Whether the service is working",
                "security": [],
                "responses": {
                    "200": {
                        "description": "Healthy, or partly degraded but answering.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Health"
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Down.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Health"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerKey": {
                "type": "http",
                "scheme": "bearer",
                "description": "An API key from your account, starting isk_."
            }
        },
        "schemas": {
            "Interval": {
                "type": "object",
                "required": [
                    "from",
                    "to"
                ],
                "properties": {
                    "from": {
                        "type": "string",
                        "example": "10:00",
                        "description": "Local opening time, HH:MM."
                    },
                    "to": {
                        "type": "string",
                        "example": "16:00",
                        "description": "Local closing time. Earlier than from means after midnight; equal means 24 hours."
                    }
                }
            },
            "Day": {
                "type": "object",
                "required": [
                    "date",
                    "open",
                    "label",
                    "note",
                    "intervals"
                ],
                "properties": {
                    "date": {
                        "type": "string",
                        "format": "date"
                    },
                    "open": {
                        "type": "boolean"
                    },
                    "label": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "example": "Christmas Day"
                    },
                    "note": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "example": "Closed for staff training"
                    },
                    "intervals": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Interval"
                        }
                    }
                }
            },
            "Hours": {
                "type": "object",
                "required": [
                    "code",
                    "timezone",
                    "updated_at",
                    "confirmed_at",
                    "days"
                ],
                "properties": {
                    "code": {
                        "type": "string"
                    },
                    "timezone": {
                        "type": "string",
                        "example": "Europe/London"
                    },
                    "updated_at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When the location's hours last changed."
                    },
                    "confirmed_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time",
                        "description": "When the owner last changed the hours or confirmed they are still right. Null if never."
                    },
                    "set": {
                        "type": "string",
                        "description": "Only present when a set was asked for."
                    },
                    "days": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Day"
                        }
                    }
                }
            },
            "HoursBatch": {
                "type": "object",
                "required": [
                    "results"
                ],
                "properties": {
                    "results": {
                        "type": "array",
                        "items": {
                            "oneOf": [
                                {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Hours"
                                        },
                                        {
                                            "type": "object",
                                            "required": [
                                                "location"
                                            ],
                                            "properties": {
                                                "location": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    ]
                                },
                                {
                                    "type": "object",
                                    "required": [
                                        "location",
                                        "error"
                                    ],
                                    "properties": {
                                        "location": {
                                            "type": "string"
                                        },
                                        "error": {
                                            "type": "string",
                                            "enum": [
                                                "not_found",
                                                "set_not_found"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "Status": {
                "type": "object",
                "required": [
                    "code",
                    "timezone",
                    "open",
                    "next_change"
                ],
                "properties": {
                    "code": {
                        "type": "string"
                    },
                    "timezone": {
                        "type": "string"
                    },
                    "open": {
                        "type": "boolean"
                    },
                    "next_change": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "Null when nothing changes within a year.",
                        "properties": {
                            "at": {
                                "type": "string",
                                "format": "date-time",
                                "description": "With the location's UTC offset."
                            },
                            "to": {
                                "type": "string",
                                "enum": [
                                    "open",
                                    "closed"
                                ]
                            }
                        }
                    }
                }
            },
            "Health": {
                "type": "object",
                "properties": {
                    "status": {
                        "type": "string",
                        "enum": [
                            "healthy",
                            "partial",
                            "down"
                        ]
                    }
                },
                "additionalProperties": true
            },
            "Error": {
                "type": "object",
                "properties": {
                    "message": {
                        "type": "string"
                    }
                },
                "additionalProperties": true
            }
        }
    }
}