Skip to content

Latest commit

 

History

History
118 lines (88 loc) · 3.18 KB

File metadata and controls

118 lines (88 loc) · 3.18 KB

Closet Agent API Documentation

This document outlines the REST APIs available for integrating the Closet Agent with external applications, such as your Chrome Extension.

Base URL

The base URL for all API endpoints is your deployed application's URL. Example: `https://your-app-url.run.app\`


1. Evaluate Purchase API

Evaluates a potential clothing purchase against the user's current wardrobe to provide a buy/skip recommendation.

Endpoint: `/api/evaluate`
Method: `POST`
Content-Type: `application/json`

Request Body

```json { "purchaseImageUrl": "data:image/jpeg;base64,...", // Required: Base64 encoded image of the item to buy "wardrobe": [ // Required: Array of the user's current wardrobe items { "category": "Top", "color": "White", "style": "Casual", "description": "White cotton t-shirt" } ] } ```

Response

Returns a structured evaluation from the AI stylist.

```json { "decision": "BUY", // Enum: "BUY" | "MAYBE" | "SKIP" "reasoning": "This item perfectly complements your existing casual wardrobe...", "pros": [ "Matches white t-shirt", "Good for summer" ], "cons": [ "Might be hard to clean" ], "itemDescription": "A detailed visual description of the evaluated item..." } ```


2. Virtual Try-On API

Generates a realistic virtual try-on image by replacing the clothing in the user's photo with the described clothing item.

Endpoint: `/api/try-on`
Method: `POST`
Content-Type: `application/json`

Request Body

```json { "userPhotoDataUrl": "data:image/jpeg;base64,...", // Required: Base64 encoded photo of the user "clothingDescription": "- [TOP] Red Casual: Red cotton t-shirt", // Required: Formatted description of the clothes to try on "measurements": { // Required: User's body measurements for realistic fitting "height": "170cm", "weight": "65kg", "bodyType": "Athletic" } } ```

Response

Returns the generated image as a base64 data URL.

```json { "imageUrl": "data:image/jpeg;base64,..." // Base64 encoded generated image } ```


3. Get User Profile API

Retrieves the user's saved profile, including their photo and body measurements. This is useful for the extension to automatically populate the measurements and userPhotoDataUrl fields when calling the Try-On API.

Endpoint: /api/profile
Method: GET

Response

Returns the user's profile data. If no profile has been set up yet, it returns an empty object.

{
  "photoUrl": "data:image/jpeg;base64,...",
  "measurements": {
    "height": "170cm",
    "weight": "65kg",
    "bodyType": "Athletic"
  }
}

Notes for Chrome Extension Integration

  1. CORS: Cross-Origin Resource Sharing (CORS) is enabled on these endpoints, allowing your Chrome Extension to call them directly from any e-commerce website.
  2. Payload Size: The payload limit is set to 50mb to accommodate high-resolution base64 encoded images.
  3. Authentication: Currently, these endpoints are open for your extension's use. If you plan to release the extension publicly, consider adding an API key or token authentication layer in the future.