{
    "openapi": "3.0.3",
    "info": {
        "title": "Hunza Explorers partner API",
        "version": "1.0.0",
        "description": "Live fixed departures and referral earnings for registered partner websites. Every departure link carries the partner's referral code."
    },
    "servers": [
        {
            "url": "https://hunzaexplorers.com/api/v1"
        }
    ],
    "components": {
        "securitySchemes": {
            "bearerKey": {
                "type": "http",
                "scheme": "bearer",
                "description": "The secret key (hxk_...) of one registered website."
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "required": [
                    "error",
                    "code"
                ],
                "properties": {
                    "error": {
                        "type": "string"
                    },
                    "request_id": {
                        "type": "string"
                    },
                    "code": {
                        "type": "string",
                        "enum": [
                            "bad_request",
                            "invalid_key",
                            "key_replaced",
                            "key_expired",
                            "site_not_active",
                            "ip_not_allowed",
                            "insufficient_scope",
                            "rate_limited",
                            "server_error"
                        ]
                    }
                }
            },
            "Departure": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "title": {
                        "type": "string"
                    },
                    "route": {
                        "type": "string",
                        "nullable": true
                    },
                    "start_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "end_date": {
                        "type": "string",
                        "format": "date",
                        "nullable": true
                    },
                    "duration_days": {
                        "type": "integer",
                        "nullable": true
                    },
                    "price_from": {
                        "type": "number",
                        "nullable": true
                    },
                    "original_price": {
                        "type": "number",
                        "nullable": true
                    },
                    "discount_percent": {
                        "type": "number",
                        "nullable": true
                    },
                    "discount_label": {
                        "type": "string",
                        "nullable": true
                    },
                    "currency": {
                        "type": "string"
                    },
                    "seats_left": {
                        "type": "integer",
                        "nullable": true
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "open",
                            "limited",
                            "full"
                        ]
                    },
                    "url": {
                        "type": "string",
                        "format": "uri",
                        "description": "Booking page, with the partner's ?ref= code."
                    },
                    "image": {
                        "type": "string",
                        "format": "uri",
                        "nullable": true
                    }
                }
            }
        }
    },
    "paths": {
        "/fixed-departures": {
            "get": {
                "summary": "Upcoming fixed departures",
                "description": "Needs the \"departures\" permission.",
                "security": [
                    {
                        "bearerKey": []
                    }
                ],
                "parameters": [
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 50,
                            "default": 24
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "tour",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "A tour slug."
                    },
                    {
                        "name": "group",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "tour"
                            ]
                        },
                        "description": "tour: one entry per tour with its dates inside (each date has a booking_url)."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The departures",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests allowed per minute."
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests left in this minute."
                            },
                            "X-RateLimit-Reset": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Unix time the minute ends."
                            },
                            "X-Request-Id": {
                                "schema": {
                                    "type": "string"
                                },
                                "description": "Quote this when you write to us."
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Departure"
                                            }
                                        },
                                        "meta": {
                                            "type": "object",
                                            "properties": {
                                                "updated_at": {
                                                    "type": "string",
                                                    "format": "date-time"
                                                },
                                                "count": {
                                                    "type": "integer"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "304": {
                        "description": "Not modified (send If-None-Match)"
                    },
                    "400": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/referrals": {
            "get": {
                "summary": "Your referral bookings and commission",
                "description": "Needs the \"referrals\" permission. Never includes who booked.",
                "security": [
                    {
                        "bearerKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Commission rows and totals",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests allowed per minute."
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests left in this minute."
                            },
                            "X-RateLimit-Reset": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Unix time the minute ends."
                            },
                            "X-Request-Id": {
                                "schema": {
                                    "type": "string"
                                },
                                "description": "Quote this when you write to us."
                            }
                        }
                    },
                    "400": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/me": {
            "get": {
                "summary": "About this key",
                "description": "Which website the key belongs to, its permissions and its limit.",
                "security": [
                    {
                        "bearerKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Key details",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests allowed per minute."
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Requests left in this minute."
                            },
                            "X-RateLimit-Reset": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Unix time the minute ends."
                            },
                            "X-Request-Id": {
                                "schema": {
                                    "type": "string"
                                },
                                "description": "Quote this when you write to us."
                            }
                        }
                    },
                    "400": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}