{
  "openapi": "3.1.0",
  "info": {
    "title": "Baydaar API",
    "version": "1.1.0",
    "description": "Read-only public API for Baydaar Experiences: published trips, prices and upcoming departures. No API key. Rupees are the money of record; dollar prices appear only on trips Baydaar markets in dollars.",
    "contact": {
      "name": "Baydaar",
      "url": "https://baydaarexperiences.com",
      "email": "hello@baydaarexperiences.com"
    }
  },
  "servers": [
    {
      "url": "https://baydaarexperiences.com/api/v1"
    }
  ],
  "paths": {
    "/trips": {
      "get": {
        "operationId": "listTrips",
        "summary": "List trips",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "description": "domestic or international.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "region",
            "in": "query",
            "description": "Case-insensitive match on the trip’s region or location, e.g. Gilgit, Hunza.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Free-text search over title, location, region and short description.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "experience_type",
            "in": "query",
            "description": "leisure or adventure.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "available",
            "in": "query",
            "description": "true hides sold-out trips; false returns only sold-out ones.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "min_price",
            "in": "query",
            "description": "Per-person price range in PKR (the “from” price).",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "max_price",
            "in": "query",
            "description": "Per-person price range in PKR (the “from” price).",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "min_days",
            "in": "query",
            "description": "Trip length range, in days.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "max_days",
            "in": "query",
            "description": "Trip length range, in days.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "departs_after",
            "in": "query",
            "description": "Only trips with at least one upcoming departure in this range (YYYY-MM-DD, inclusive).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "departs_before",
            "in": "query",
            "description": "Only trips with at least one upcoming departure in this range (YYYY-MM-DD, inclusive).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "description": "Comma-separated top-level fields to return, e.g. id,title,price — smaller responses.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "recommended (default — the order Baydaar chooses), price_asc, price_desc, duration_asc, duration_desc, departure (soonest first).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size, 1–100. Default 25.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of trips to skip. Default 0.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of trips",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TripList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/trips/{id}": {
      "get": {
        "operationId": "getTrip",
        "summary": "Get a trip",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "hunza-valley-adventure"
          }
        ],
        "responses": {
          "200": {
            "description": "The trip",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Trip"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/trips/{id}/reviews": {
      "get": {
        "operationId": "listTripReviews",
        "summary": "Traveller reviews of a trip",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Reviews, newest first"
          }
        }
      }
    },
    "/trips/{id}/guides": {
      "get": {
        "operationId": "listTripGuides",
        "summary": "Tour guides on a trip",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Guides"
          }
        }
      }
    },
    "/products": {
      "get": {
        "operationId": "listProducts",
        "summary": "List shop products",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "popular",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of products"
          }
        }
      }
    },
    "/products/{id}": {
      "get": {
        "operationId": "getProduct",
        "summary": "Get a product",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The product"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/stories": {
      "get": {
        "operationId": "listStories",
        "summary": "Published traveller stories",
        "parameters": [
          {
            "name": "trip_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stories, newest first"
          }
        }
      }
    },
    "/stories/{id}": {
      "get": {
        "operationId": "getStory",
        "summary": "Get a story with its full text",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The story"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/facets": {
      "get": {
        "operationId": "getFacets",
        "summary": "Counts and ranges for building filters",
        "responses": {
          "200": {
            "description": "Facets"
          }
        }
      }
    },
    "/about": {
      "get": {
        "operationId": "getAbout",
        "summary": "Baydaar contact, payment and refund information",
        "responses": {
          "200": {
            "description": "About"
          }
        }
      }
    },
    "/trips/{id}/departures": {
      "get": {
        "operationId": "listDepartures",
        "summary": "List a trip’s upcoming departures",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Upcoming departures, soonest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Departure"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "Departure": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "return_date": {
            "type": "string",
            "format": "date"
          },
          "spots_left": {
            "type": [
              "integer",
              "null"
            ]
          },
          "sold_out": {
            "type": "boolean"
          }
        }
      },
      "Trip": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "book_url": {
            "type": "string",
            "format": "uri"
          },
          "category": {
            "type": "string",
            "enum": [
              "domestic",
              "international"
            ]
          },
          "location": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "duration_days": {
            "type": "integer"
          },
          "duration_nights": {
            "type": "integer"
          },
          "price": {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string",
                "const": "PKR"
              },
              "per_person": {
                "type": "integer",
                "description": "PKR. The lowest option when the trip is priced by room sharing."
              },
              "options": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "per_person": {
                      "type": "integer"
                    }
                  }
                }
              },
              "usd_per_person": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Only on trips Baydaar markets in dollars. Never a conversion."
              },
              "advance_percent": {
                "type": "integer"
              }
            }
          },
          "short_description": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "cover_image": {
            "type": "string",
            "format": "uri"
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "included": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "excluded": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "itinerary": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "day": {
                  "type": "integer"
                },
                "title": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                }
              }
            }
          },
          "activity_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "experience_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "leisure",
              "adventure",
              null
            ]
          },
          "sold_out": {
            "type": "boolean"
          },
          "next_departure": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "departures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Departure"
            }
          },
          "rating": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "average": {
                "type": "number"
              },
              "count": {
                "type": "integer"
              }
            }
          }
        }
      },
      "TripList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Trip"
            }
          },
          "meta": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "limit": {
                "type": "integer"
              },
              "offset": {
                "type": "integer"
              },
              "has_more": {
                "type": "boolean"
              }
            }
          }
        }
      }
    }
  }
}
