> ## Documentation Index
> Fetch the complete documentation index at: https://docs.context.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Extract a single product from a URL

> Given a single URL, determines if it is a product page and extracts the product information.

<Badge color="orange">10 Credits</Badge>


## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/context.dev/openapi.documented.yml post /brand/ai/product
openapi: 3.0.0
info:
  title: Context API
  description: API for retrieving context data from any website
  version: 1.0.0
servers:
  - url: https://api.context.dev/v1
security: []
paths:
  /brand/ai/product:
    post:
      tags:
        - Web Extraction
      summary: Extract a single product from a URL
      description: >-
        Given a single URL, determines if it is a product page and extracts the
        product information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - url
              properties:
                url:
                  type: string
                  format: uri
                  description: The product page URL to extract product data from.
                maxAgeMs:
                  type: integer
                  minimum: 0
                  maximum: 2592000000
                  default: 604800000
                  description: >-
                    Return a cached result if a prior scrape for the same
                    parameters exists and is younger than this many
                    milliseconds. Defaults to 7 days (604800000 ms) when
                    omitted. Max is 30 days (2592000000 ms). Set to 0 to always
                    scrape fresh.
                timeoutMS:
                  $ref: '#/components/schemas/TimeoutMS'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  is_product_page:
                    type: boolean
                    description: Whether the given URL is a product detail page
                  platform:
                    type: string
                    nullable: true
                    enum:
                      - amazon
                      - tiktok_shop
                      - etsy
                      - generic
                    description: >-
                      The detected ecommerce platform, or null if not a product
                      page
                  product:
                    type: object
                    nullable: true
                    description: The extracted product data, or null if not a product page
                    properties:
                      name:
                        type: string
                        description: Name of the product
                      description:
                        type: string
                        description: Description of the product
                      price:
                        type: number
                        nullable: true
                        description: Price of the product
                      currency:
                        type: string
                        nullable: true
                        description: Currency code for the price (e.g., USD, EUR)
                      billing_frequency:
                        type: string
                        nullable: true
                        enum:
                          - monthly
                          - yearly
                          - one_time
                          - usage_based
                        description: Billing frequency for the product
                      pricing_model:
                        type: string
                        nullable: true
                        enum:
                          - per_seat
                          - flat
                          - tiered
                          - freemium
                          - custom
                        description: Pricing model for the product
                      url:
                        type: string
                        nullable: true
                        description: URL to the product page
                      category:
                        type: string
                        nullable: true
                        description: Category of the product
                      features:
                        type: array
                        description: List of product features
                        items:
                          type: string
                      target_audience:
                        type: array
                        description: Target audience for the product (array of strings)
                        items:
                          type: string
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: string
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product image
                      images:
                        type: array
                        description: URLs to product images on the page (up to 7)
                        items:
                          type: string
                      sku:
                        type: string
                        nullable: true
                        description: >-
                          Stock Keeping Unit (product identifier). Null if no
                          identifier is found.
                    required:
                      - name
                      - description
                      - features
                      - target_audience
                      - tags
                      - images
                      - sku
        '400':
          description: Bad Request - validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                  error_code:
                    type: string
                    enum:
                      - INTERNAL_ERROR
                      - VALID
                      - NOT_FOUND
                      - FORBIDDEN
                      - USAGE_EXCEEDED
                      - RATE_LIMITED
                      - UNAUTHORIZED
                      - DISABLED
                      - INSUFFICIENT_PERMISSIONS
                      - TIMEOUT_EXCEEDS_MAXIMUM
                      - WEBSITE_ACCESS_ERROR
                      - INPUT_VALIDATION_ERROR
                    description: Error code indicating the type of error
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error_code:
                    type: string
                    enum:
                      - INTERNAL_ERROR
                      - VALID
                      - NOT_FOUND
                      - FORBIDDEN
                      - USAGE_EXCEEDED
                      - RATE_LIMITED
                      - UNAUTHORIZED
                      - DISABLED
                      - INSUFFICIENT_PERMISSIONS
                      - TIMEOUT_EXCEEDS_MAXIMUM
                      - WEBSITE_ACCESS_ERROR
                      - INPUT_VALIDATION_ERROR
                    description: Error code indicating the type of error
        '408':
          description: Request Timeout
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Timeout error message
                  error_code:
                    type: string
                    enum:
                      - REQUEST_TIMEOUT
                    description: Error code indicating request timeout
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                  error_code:
                    type: string
                    enum:
                      - INTERNAL_ERROR
                    description: Error code indicating internal server error
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import ContextDev from 'context.dev';


            const client = new ContextDev({
              apiKey: process.env['CONTEXT_DEV_API_KEY'], // This is the default and can be omitted
            });


            const response = await client.ai.extractProduct({ url:
            'https://example.com' });


            console.log(response.is_product_page);
        - lang: Python
          source: |-
            import os
            from context.dev import ContextDev

            client = ContextDev(
                api_key=os.environ.get("CONTEXT_DEV_API_KEY"),  # This is the default and can be omitted
            )
            response = client.ai.extract_product(
                url="https://example.com",
            )
            print(response.is_product_page)
        - lang: Ruby
          source: >-
            require "context_dev"


            context_dev = ContextDev::Client.new(api_key: "My API Key")


            response = context_dev.ai.extract_product(url:
            "https://example.com")


            puts(response)
components:
  schemas:
    TimeoutMS:
      type: integer
      minimum: 1000
      maximum: 300000
      description: >-
        Optional timeout in milliseconds for the request. If the request takes
        longer than this value, it will be aborted with a 408 status code.
        Maximum allowed value is 300000ms (5 minutes).
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````