API Documentation

Transform natural language queries into structured product filters with our REST API.

Get Started

Get up and running with the Facetize API in minutes. Follow these simple steps to make your first request.

1. Create an Account

Sign up for an account at facetize.io/signup.

2. Add Credits

Add credits to your account from your billing page. Each API request costs $0.01, so you'll need credits before making any requests.

3. Generate an API Key

Navigate to your API keys page and create a new API key. Give it a descriptive name to help you manage multiple keys.

Security Tip: Keep your API keys secure and never commit them to version control. Regenerate keys immediately if you suspect they've been compromised.

4. Make Your First Request

Use the interactive tester in your dashboard or make a request using curl:

curl -X POST https://facetize.io/api/translate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "blue t-shirts under $50"
  }'

Authentication

All API requests require authentication using a Bearer token. Include your API key in the Authorization header of every request.

Bearer Token Format

Include your API key in the Authorization header using the Bearer token format:

Authorization: Bearer facetize_xxxxxxxxxxxxxxxxxxxxx

API keys start with the prefix facetize_

Example Request

curl -X POST https://facetize.io/api/translate \
  -H "Authorization: Bearer facetize_xxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "red running shoes"
  }'

Security Best Practices

  • Never expose your API keys in client-side code or public repositories
  • Use environment variables to store API keys securely
  • Rotate API keys regularly, especially if you suspect unauthorized access
  • Use different API keys for different applications or environments
  • Monitor your API usage regularly to detect any suspicious activity

Invalid API Key Response

If your API key is missing or invalid, you'll receive a 401 Unauthorized response:

{
  "error": "Invalid or expired API key"
}

Rate Limits

Rate limits are applied per user account and are based on your API tier. Tiers automatically upgrade as you use the service more, providing higher limits for established accounts.

Tier System

Your API tier (1-10) determines your rate limits. New accounts start at tier 1, and tiers automatically increase based on your account age and usage patterns.

TierPer MinutePer HourPer Day
1 (Starter)101001,000
2202002,000
3505005,000
41001,00010,000
52002,00020,000
63003,00030,000
75005,00050,000
87507,50075,000
99009,00090,000
10 (Enterprise)1,00010,000100,000

Rate Limit Headers

Every API response includes rate limit information in the response headers:

  • X-RateLimit-Limit-Minute - Maximum requests per minute
  • X-RateLimit-Remaining-Minute - Remaining requests in current minute
  • X-RateLimit-Reset-Minute - When the minute window resets (ISO 8601)
  • X-RateLimit-Limit-Hour - Maximum requests per hour
  • X-RateLimit-Remaining-Hour - Remaining requests in current hour
  • X-RateLimit-Reset-Hour - When the hour window resets (ISO 8601)
  • X-RateLimit-Limit-Day - Maximum requests per day
  • X-RateLimit-Remaining-Day - Remaining requests in current day
  • X-RateLimit-Reset-Day - When the day window resets (ISO 8601)

Rate Limit Exceeded

When you exceed your rate limit, you'll receive a 429 Too Many Requests response:

{
  "error": "Rate limit exceeded",
  "message": "Too many requests. Please wait before making another request.",
  "tier": 1,
  "limits": {
    "perMinute": { "limit": 10, "remaining": 0, "reset": "2024-01-01T12:01:00Z" },
    "perHour": { "limit": 100, "remaining": 50, "reset": "2024-01-01T13:00:00Z" },
    "perDay": { "limit": 1000, "remaining": 900, "reset": "2024-01-02T00:00:00Z" }
  },
  "retryAfter": 45
}

The Retry-After header indicates how many seconds to wait before retrying.

API Reference

POST /api/translate

Translates natural language ecommerce queries into structured taxonomy filters. The endpoint uses AI-powered query parsing combined with vector similarity search to match queries to the taxonomy database.

Request

URL: https://facetize.io/api/translate

Method: POST

Headers:

  • Authorization: Bearer YOUR_API_KEY (required)
  • Content-Type: application/json (required)
Request Body
{
  "query": string,        // Required: Natural language query (1-255 characters)
  "context": string       // Optional: Context to help disambiguate (max 255 characters)
}

Response

Returns a structured JSON object containing matched categories, attributes, values, vendors, price ranges, GTINs, model numbers, availability status, tags, and collections, each with confidence scores where applicable.

{
  "categories": {
    "gid1": {
      "name": "Apparel",
      "confidence": 0.95
    }
  },
  "attributes": {
    "gid2": {
      "name": "Color",
      "confidence": 0.92,
      "values": {
        "gid3": {
          "name": "Blue",
          "confidence": 0.88
        }
      }
    }
  },
  "vendors": ["Nike", "Adidas"],
  "priceRange": {
    "min": 10,
    "max": 50
  },
  "gtin": ["1234567890123"],
  "modelNumbers": ["SKU-ABC123", "MOD-XYZ456"],
  "availability": true,
  "tags": ["sale", "new-arrival"],
  "collections": ["Summer"],
  "queryTerms": ["iPhone 15 Pro", "Nike Air Max"],
  "options": [...]
}

Response Fields

categories (object, required): Matched product categories (verticals) with their GIDs as keys. Each category includes a name and confidence score (0-1).

attributes (object, required): Matched product attributes with their associated values. Each attribute includes a name, confidence score, and a values object containing matched attribute values.

vendors (array of strings, required): Extracted vendor/brand names from the query. Empty array if none found.

priceRange (object, optional): Price constraints extracted from the query. Contains optional min and max numeric values.

gtin (array of strings, optional): GTIN, EAN, UPC, or barcode numbers extracted from the query. Only included when product identifiers are mentioned in the query.

modelNumbers (array of strings, optional): Model numbers, part numbers, SKUs, or product codes extracted from the query. Only included when model identifiers are mentioned.

availability (boolean, optional): Availability status extracted from the query. true for "in stock" or "available" queries, false for "out of stock" or "unavailable" queries. Only included when availability is explicitly mentioned.

tags (array of strings, optional): Product tags extracted from the query. Only included when tags are explicitly mentioned (e.g., "tagged with", "with tag", "products with tags").

collections (array of strings, optional): Product collections extracted from the query. Collections are store-specific product groupings (e.g., "Summer collection", "Holiday collection") separate from taxonomy categories. Only included when explicitly mentioned in the query (e.g., "from Summer collection", "in the Holiday collection").

queryTerms (array of strings, optional): Product names and brand names extracted from the query for name-based product search. Includes specific product model names, product titles, and brand names (e.g., "iPhone 15 Pro", "Nike Air Max"). Excludes categories, attributes, prices, availability, tags, and collections. Only included when product names or brand names are mentioned in the query.

options (array, required): Structured representation of attributes and their values, matching the format used in the query parsing.

Example Request

curl -X POST https://facetize.io/api/translate \
  -H "Authorization: Bearer facetize_xxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "blue t-shirts under $50",
    "context": "this is a clothing store"
  }'

Example Response

{
  "categories": {
    "gid_123": {
      "name": "Apparel",
      "confidence": 0.95
    }
  },
  "attributes": {
    "gid_456": {
      "name": "Color",
      "confidence": 0.92,
      "values": {
        "gid_789": {
          "name": "Blue",
          "confidence": 0.88
        }
      }
    },
    "gid_101": {
      "name": "Product Type",
      "confidence": 0.85,
      "values": {
        "gid_102": {
          "name": "T-Shirt",
          "confidence": 0.82
        }
      }
    }
  },
  "vendors": [],
  "priceRange": {
    "max": 50
  },
  "gtin": [],
  "modelNumbers": [],
  "availability": undefined,
  "tags": [],
  "collections": [],
  "options": [
    {
      "name": "Color",
      "values": ["Blue"]
    },
    {
      "name": "Product Type",
      "values": ["T-Shirt"]
    }
  ]
}

Example with GTIN, Model Numbers, and Availability

Here's an example showing how the API extracts GTINs, model numbers, and availability status:

curl -X POST https://facetize.io/api/translate \
  -H "Authorization: Bearer facetize_xxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "Find product with GTIN 1234567890123, model SKU-ABC123 that is in stock"
  }'
{
  "categories": {},
  "attributes": {},
  "vendors": [],
  "priceRange": undefined,
  "gtin": ["1234567890123"],
  "modelNumbers": ["SKU-ABC123"],
  "availability": true,
  "tags": [],
  "collections": [],
  "options": []
}

Error Handling

The API uses standard HTTP status codes to indicate success or failure. All error responses include a JSON body with an error message and optional details.

Status Codes

200 OK

Request successful. Response contains the translated query data.

400 Bad Request

Invalid request body. Missing required fields or validation errors.

{
  "error": "Invalid request body",
  "details": "query: Query is required"
}

401 Unauthorized

Missing or invalid API key.

{
  "error": "Invalid or expired API key"
}

429 Too Many Requests

Rate limit exceeded. See Rate Limits section for details.

500 Internal Server Error

An unexpected error occurred on the server. Please try again later.

{
  "error": "Internal server error",
  "message": "Failed to process request"
}

Error Response Format

All error responses follow a consistent format:

{
  "error": "Error type",
  "message": "Human-readable error message",
  "details": "Optional additional details"
}

Handling Errors

When implementing error handling in your application:

  • Check the HTTP status code first to determine the error type
  • For 429 errors, respect the Retry-After header
  • For 401 errors, verify your API key is correct and hasn't been revoked
  • For 400 errors, check the details field for specific validation issues
  • Implement exponential backoff for retries on 500 errors

Pricing

Facetize uses a simple, usage-based pricing model. Pay only for what you use with no monthly commitments or hidden fees.

Cost Per Request

Each API request costs $0.01 USD (1 cent). This includes the full processing pipeline:

  • AI-powered query parsing
  • Vector similarity search
  • Text-based taxonomy matching
  • Structured response generation

Account Balance

You maintain a prepaid balance in your account. Each successful API request deducts $0.01 from your balance. You can add credits anytime from your billing page.

Note: Requests are only charged if they complete successfully. Failed requests (4xx/5xx errors) are not charged.

Insufficient Balance

If your account balance is insufficient, you'll receive a 402 Payment Required response:

{
  "error": "Insufficient balance",
  "message": "Your account balance is too low to process this request. Please add credits to continue."
}

Monitoring Usage

Track your API usage and costs in real-time from your usage dashboard. You can view:

  • Request history and logs
  • Current account balance
  • Usage statistics and trends
  • Cost breakdown by time period