{
  "openapi": "3.1.0",
  "info": {
    "title": "Namma3D Storefront API",
    "version": "1.0.0",
    "summary": "Read-only catalog, prices and order lookup for Namma3D.",
    "description": "Namma3D is a small studio making 3D-printed products to order in India. This API is read-only and needs no API key: it lists the products on sale with live prices in Indian rupees (INR), and looks up an existing order by its order id. Orders are placed and paid by a person in a web browser through the Cashfree checkout; there is no operation for placing an order or taking payment, and checkout must not be automated. Every page of the site is also available as markdown by sending `Accept: text/markdown`.",
    "termsOfService": "https://namma3d.com/terms",
    "contact": {
      "name": "Namma3D support",
      "email": "support@namma3d.com",
      "url": "https://namma3d.com/contact"
    }
  },
  "externalDocs": {
    "description": "Developer guide",
    "url": "https://namma3d.com/developers"
  },
  "servers": [
    {
      "url": "https://namma3d.com",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Catalog",
      "description": "Products on sale and what they cost."
    },
    {
      "name": "Orders",
      "description": "Look up an order that has already been placed."
    },
    {
      "name": "Status",
      "description": "Whether the store is up."
    }
  ],
  "paths": {
    "/api/products": {
      "get": {
        "operationId": "listProducts",
        "tags": [
          "Catalog"
        ],
        "summary": "List every product on sale",
        "description": "Returns every active product with its price in INR, its sizes and designs where it has them, its photos and videos, and the flat shipping rates charged per order. Use it to answer what Namma3D sells and what it costs. The response may be cached for 60 seconds.",
        "responses": {
          "200": {
            "description": "The catalog and the shipping rates. `products` is empty if the catalog cannot be read right now.",
            "headers": {
              "Cache-Control": {
                "description": "`public, max-age=60`.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Catalog"
                }
              }
            }
          }
        }
      }
    },
    "/api/order": {
      "get": {
        "operationId": "getOrder",
        "tags": [
          "Orders"
        ],
        "summary": "Look up one order by its order id",
        "description": "Returns the status, line items and totals of one order. The order id is the only credential: the buyer receives it at checkout, and it cannot be guessed or listed. The buyer's email, phone and street address are masked in the response. Limited to 30 requests a minute per IP address.",
        "parameters": [
          {
            "name": "order_id",
            "in": "query",
            "required": true,
            "description": "The order id given to the buyer at checkout: `n3_` followed by 20 lowercase hexadecimal characters.",
            "schema": {
              "type": "string",
              "pattern": "^n3_[a-f0-9]{20}$"
            },
            "example": "n3_0123456789abcdef0123"
          }
        ],
        "responses": {
          "200": {
            "description": "The order.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderResponse"
                }
              }
            }
          },
          "400": {
            "description": "`order_id` is missing or is not a well-formed order id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No order has this id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests from this IP address.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before trying again.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Order lookup is temporarily unavailable. Try again shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "tags": [
          "Status"
        ],
        "summary": "Check whether the store is up",
        "description": "Reports whether the store can reach its database, its media storage and its payment configuration.",
        "responses": {
          "200": {
            "description": "The store is up.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "503": {
            "description": "A dependency is unavailable; `checks` says which.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Catalog": {
        "type": "object",
        "required": [
          "products",
          "shipping"
        ],
        "properties": {
          "products": {
            "type": "array",
            "description": "Products on sale, cheapest first.",
            "items": {
              "$ref": "#/components/schemas/Product"
            }
          },
          "shipping": {
            "$ref": "#/components/schemas/ShippingRates"
          }
        }
      },
      "Product": {
        "type": "object",
        "required": [
          "id",
          "name",
          "price",
          "media",
          "variants",
          "designs"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Product id. The product page is `https://namma3d.com/p/{id}`.",
            "examples": [
              "shadow-lamp"
            ]
          },
          "name": {
            "type": "string",
            "description": "Product name."
          },
          "price": {
            "type": "number",
            "minimum": 0,
            "description": "Price in INR. For a product with `variants`, each variant carries its own price and this is the base price."
          },
          "mrp": {
            "type": [
              "number",
              "null"
            ],
            "description": "Compare-at price in INR shown struck through, or null when there is none."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the product is."
          },
          "material": {
            "type": [
              "string",
              "null"
            ],
            "description": "What it is printed from."
          },
          "dimensions": {
            "type": [
              "string",
              "null"
            ],
            "description": "Size, as free text."
          },
          "lead_time": {
            "type": [
              "string",
              "null"
            ],
            "description": "How long printing takes before dispatch, as free text."
          },
          "image": {
            "type": [
              "string",
              "null"
            ],
            "description": "Legacy single image URL. Prefer `media`."
          },
          "requires_artwork": {
            "type": "boolean",
            "description": "True when the buyer must upload an image to order this product."
          },
          "requires_personalization": {
            "type": "boolean",
            "description": "True when the buyer must type the text to print, such as a name."
          },
          "media": {
            "type": "array",
            "description": "Photos and videos in display order.",
            "items": {
              "type": "object",
              "required": [
                "kind",
                "url"
              ],
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "image",
                    "video"
                  ],
                  "description": "What the file is."
                },
                "url": {
                  "type": "string",
                  "description": "Path of the file, relative to `https://namma3d.com`."
                }
              }
            }
          },
          "variants": {
            "type": "array",
            "description": "Sizes the buyer chooses between, each with its own price. Empty when the product has one price.",
            "items": {
              "type": "object",
              "required": [
                "id",
                "label",
                "price",
                "position"
              ],
              "properties": {
                "id": {
                  "type": "integer",
                  "description": "Variant id."
                },
                "label": {
                  "type": "string",
                  "description": "Size name.",
                  "examples": [
                    "A4"
                  ]
                },
                "price": {
                  "type": "number",
                  "minimum": 0,
                  "description": "Price of this size in INR."
                },
                "position": {
                  "type": "integer",
                  "description": "Display order, lowest first."
                }
              }
            }
          },
          "designs": {
            "type": "array",
            "description": "Ready-made designs the buyer chooses between. Empty when the product has none.",
            "items": {
              "type": "object",
              "required": [
                "id",
                "name",
                "image",
                "position"
              ],
              "properties": {
                "id": {
                  "type": "integer",
                  "description": "Design id."
                },
                "name": {
                  "type": "string",
                  "description": "Design name."
                },
                "image": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Path of the design's preview image, relative to `https://namma3d.com`, or null."
                },
                "position": {
                  "type": "integer",
                  "description": "Display order, lowest first."
                }
              }
            }
          }
        }
      },
      "ShippingRates": {
        "type": "object",
        "description": "Flat shipping charge per order within India, in INR.",
        "required": [
          "regular",
          "express"
        ],
        "properties": {
          "regular": {
            "type": "number",
            "minimum": 0,
            "description": "Regular delivery, in INR."
          },
          "express": {
            "type": "number",
            "minimum": 0,
            "description": "Express delivery, in INR."
          }
        }
      },
      "OrderResponse": {
        "type": "object",
        "required": [
          "order"
        ],
        "properties": {
          "order": {
            "$ref": "#/components/schemas/Order"
          }
        }
      },
      "Order": {
        "type": "object",
        "required": [
          "id",
          "status",
          "created_at",
          "amount",
          "currency",
          "items"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^n3_[a-f0-9]{20}$",
            "description": "Order id."
          },
          "status": {
            "type": "string",
            "enum": [
              "PENDING",
              "FAILED",
              "EXPIRED",
              "TERMINATED",
              "PAID",
              "FULFILLED",
              "SHIPPED",
              "REFUNDED",
              "CANCELLED"
            ],
            "description": "Where the order is. PENDING, FAILED, EXPIRED and TERMINATED are unpaid. PAID means payment is confirmed and the item is queued for printing, FULFILLED means it is printed, SHIPPED means it has been dispatched. REFUNDED and CANCELLED are final."
          },
          "created_at": {
            "type": "string",
            "description": "When the order was created, in UTC, as `YYYY-MM-DD HH:MM:SS`."
          },
          "paid_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When payment was confirmed, in UTC, as `YYYY-MM-DD HH:MM:SS`, or null if unpaid."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Buyer's name."
          },
          "email": {
            "type": "string",
            "description": "Buyer's email, masked."
          },
          "phone": {
            "type": "string",
            "description": "Buyer's phone number, masked to its last four digits."
          },
          "address": {
            "type": "string",
            "description": "Delivery address with the street line masked."
          },
          "subtotal": {
            "type": [
              "number",
              "null"
            ],
            "description": "Sum of the line items in INR, before discount and shipping."
          },
          "discount_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "Discount code applied, or null."
          },
          "discount_amount": {
            "type": "number",
            "minimum": 0,
            "description": "Discount taken off, in INR."
          },
          "shipping_method": {
            "type": "string",
            "enum": [
              "regular",
              "express"
            ],
            "description": "Delivery speed chosen."
          },
          "shipping_amount": {
            "type": "number",
            "minimum": 0,
            "description": "Shipping charged, in INR."
          },
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "description": "Total charged, in the order's currency."
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217 currency code.",
            "examples": [
              "INR"
            ]
          },
          "items": {
            "type": "array",
            "description": "What was ordered.",
            "items": {
              "type": "object",
              "properties": {
                "product_id": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Id of the product ordered."
                },
                "name": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Product name at the time of the order."
                },
                "price": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "Unit price in INR."
                },
                "qty": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "description": "Quantity."
                },
                "variant": {
                  "type": "string",
                  "description": "Size chosen, when the product has sizes."
                },
                "design": {
                  "type": "string",
                  "description": "Design chosen, when the product has designs."
                },
                "personalization": {
                  "type": "string",
                  "description": "Text the buyer asked to have printed."
                }
              }
            }
          }
        }
      },
      "Health": {
        "type": "object",
        "required": [
          "ok",
          "service",
          "checks"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "description": "True when every dependency is available."
          },
          "service": {
            "type": "string",
            "description": "Always `namma3d-storefront`."
          },
          "version": {
            "type": "string",
            "description": "Deployed version. Present when `ok` is true."
          },
          "error": {
            "type": "string",
            "enum": [
              "required_binding_unavailable",
              "database_unavailable"
            ],
            "description": "What failed. Present when `ok` is false."
          },
          "latency_ms": {
            "type": "integer",
            "description": "Milliseconds the database check took. Present when `ok` is true."
          },
          "checks": {
            "type": "object",
            "description": "Each dependency and whether it is available.",
            "required": [
              "database",
              "media",
              "payments"
            ],
            "properties": {
              "database": {
                "type": "boolean",
                "description": "The product and order database."
              },
              "media": {
                "type": "boolean",
                "description": "Product photo and video storage."
              },
              "payments": {
                "type": "boolean",
                "description": "Payment gateway configuration."
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable reason the request failed."
          }
        }
      }
    }
  }
}
