{
  "openapi": "3.1.0",
  "info": {
    "title": "Shopno Books House API",
    "summary": "Public Machine-Readable API for Shopno Books House Online Bookstore",
    "description": "Provides programmatic access to book catalog, author biographies, book series, literary genres, district delivery rates, and order placement for autonomous agents and LLMs.",
    "version": "1.0.0",
    "contact": {
      "name": "Shopno Books House Support",
      "url": "https://shopnobookshouse.store/contact",
      "email": "contact@shopnobookshouse.store"
    },
    "license": {
      "name": "Proprietary / Open Catalog",
      "url": "https://shopnobookshouse.store/terms"
    }
  },
  "servers": [
    {
      "url": "https://shopnobookshouse.store/api",
      "description": "Production API Server"
    }
  ],
  "paths": {
    "/books": {
      "get": {
        "summary": "List and search books",
        "description": "Returns a list of books with optional keyword search, genre filtering, and pagination.",
        "operationId": "getBooks",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Search query"
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Genre/Category slug"
          },
          {
            "name": "series",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by series"
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of books",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Book"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/books/{slug}": {
      "get": {
        "summary": "Get book details by slug",
        "operationId": "getBookBySlug",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Book details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Book"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Book not found"
          }
        }
      }
    },
    "/series": {
      "get": {
        "summary": "List book series",
        "operationId": "getSeries",
        "responses": {
          "200": {
            "description": "Series list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Series"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/authors": {
      "get": {
        "summary": "List authors directory",
        "operationId": "getAuthors",
        "responses": {
          "200": {
            "description": "Authors directory",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Author"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/districts": {
      "get": {
        "summary": "List Bangladesh districts and delivery charges",
        "description": "Lists 64 districts in Bangladesh with verified delivery rates (Dhaka ?70, All others ?120).",
        "operationId": "getDistricts",
        "responses": {
          "200": {
            "description": "Districts list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/District"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders": {
      "post": {
        "summary": "Submit new customer order",
        "operationId": "submitOrder",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrderRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Order created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "success"
                    },
                    "order_number": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Book": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "author": {
            "type": "string"
          },
          "regular_price": {
            "type": "number"
          },
          "sale_price": {
            "type": "number"
          },
          "cover_image": {
            "type": "string"
          },
          "genre": {
            "type": "string"
          },
          "stock_status": {
            "type": "string",
            "enum": [
              "in_stock",
              "out_of_stock",
              "pre_order"
            ]
          },
          "description": {
            "type": "string"
          },
          "specs": {
            "type": "object",
            "properties": {
              "paper_quality": {
                "type": "string",
                "example": "80 GSM Swedish Cream Paper"
              },
              "binding": {
                "type": "string",
                "example": "Hardcover with 180 thread-sewn spine"
              }
            }
          }
        }
      },
      "Series": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "book_count": {
            "type": "integer"
          }
        }
      },
      "Author": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "bio": {
            "type": "string"
          }
        }
      },
      "District": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "name_bn": {
            "type": "string"
          },
          "delivery_charge": {
            "type": "number",
            "example": 70
          }
        }
      },
      "OrderRequest": {
        "type": "object",
        "required": [
          "customer_name",
          "phone",
          "address",
          "district",
          "items"
        ],
        "properties": {
          "customer_name": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "district": {
            "type": "string"
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "cod",
              "advance_cod",
              "bkash",
              "nagad"
            ]
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "book_id": {
                  "type": "string"
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          }
        }
      }
    }
  }
}