> ## 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.

# Scrape Images

> Extract image assets from a web page, including standard URLs, inline SVGs, data URIs, responsive image sources, metadata, CSS backgrounds, video posters, and embeds. The base request costs 1 credit; enrichment costs 1 credit per returned image.

<Badge color="blue">1 Credit</Badge><Badge color="blue">Enriched: 1 Credit / Image</Badge>


## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/context.dev/openapi.documented.yml get /web/scrape/images
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:
  /web/scrape/images:
    get:
      tags:
        - Web Scraping
      summary: Scrape Images
      description: >-
        Extract image assets from a web page, including standard URLs, inline
        SVGs, data URIs, responsive image sources, metadata, CSS backgrounds,
        video posters, and embeds. The base request costs 1 credit; enrichment
        costs 1 credit per returned image.
      parameters:
        - name: url
          in: query
          required: true
          schema:
            type: string
            format: uri
          description: Page URL to inspect. Must include http:// or https://.
        - name: maxAgeMs
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            maximum: 2592000000
            default: 86400000
          description: >-
            Reuse a cached result this many milliseconds old or newer. Default:
            86400000 (1 day). Set to 0 to bypass cache. Maximum: 2592000000 (30
            days).
        - name: enrichment
          in: query
          required: false
          style: deepObject
          explode: true
          schema:
            type: object
            additionalProperties: false
            properties:
              resolution:
                type: boolean
                default: false
                description: Measure image width and height when possible.
              hostedUrl:
                type: boolean
                default: false
                description: >-
                  Host materializable images on the Brand.dev CDN and return
                  their URL and MIME type.
              classification:
                type: boolean
                default: false
                description: Classify each image by visual asset type.
              maxTimePerMs:
                type: integer
                default: 30000
                minimum: 1
                maximum: 60000
                description: >-
                  Per-image enrichment timeout in milliseconds. Default: 30000.
                  Maximum: 60000.
          description: >-
            Optional per-image processing, sent as deep-object query params such
            as enrichment[resolution]=true.
        - name: waitForMs
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            maximum: 30000
          description: >-
            Optional browser wait time in milliseconds after initial page load
            before collecting images. Min: 0. Max: 30000 (30 seconds). 
        - $ref: '#/components/parameters/TimeoutMS'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                    description: Always true on success.
                  images:
                    type: array
                    description: Images found on the page.
                    items:
                      type: object
                      properties:
                        src:
                          type: string
                          description: >-
                            Original image value: URL, inline SVG or HTML, or
                            base64 data URI.
                        element:
                          type: string
                          enum:
                            - img
                            - svg
                            - link
                            - source
                            - video
                            - css
                            - object
                            - meta
                            - background
                          description: Where the image was found.
                        type:
                          type: string
                          enum:
                            - url
                            - html
                            - base64
                          description: Format of src.
                        alt:
                          type: string
                          nullable: true
                          description: Image alt text, or null when unavailable.
                        enrichment:
                          type: object
                          description: >-
                            Requested metadata for images that could be
                            processed.
                          properties:
                            width:
                              type: integer
                              description: Image width in pixels, when measured.
                            height:
                              type: integer
                              description: Image height in pixels, when measured.
                            mimetype:
                              type: string
                              description: Detected MIME type, when hosted.
                            url:
                              type: string
                              format: uri
                              description: Brand.dev CDN URL, when hosted.
                            type:
                              type: string
                              enum:
                                - photography
                                - illustration
                                - logo
                                - wordmark
                                - icon
                                - pattern
                                - graphic
                                - other
                              description: Visual asset category, when classified.
                      required:
                        - src
                        - element
                        - type
                        - alt
                  url:
                    type: string
                    description: Page URL that was scraped.
                required:
                  - success
                  - images
                  - url
        '400':
          description: Invalid URL or scrape failed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message describing the issue
                  error_code:
                    type: string
                    enum:
                      - INPUT_VALIDATION_ERROR
                      - WEBSITE_ACCESS_ERROR
                    description: Error code indicating the type of error
                required:
                  - message
                  - error_code
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                  error_code:
                    type: string
                    enum:
                      - UNAUTHORIZED
                    description: Error code indicating unauthorized access
        '403':
          description: Forbidden - Insufficient permissions or usage limit exceeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                  error_code:
                    type: string
                    enum:
                      - FORBIDDEN
                      - USAGE_EXCEEDED
                      - DISABLED
                      - INSUFFICIENT_PERMISSIONS
                    description: Error code indicating forbidden access
        '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.web.webScrapeImages({ url:
            'https://example.com' });


            console.log(response.images);
        - 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.web.web_scrape_images(
                url="https://example.com",
            )
            print(response.images)
        - lang: Ruby
          source: >-
            require "context_dev"


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


            response = context_dev.web.web_scrape_images(url:
            "https://example.com")


            puts(response)
components:
  parameters:
    TimeoutMS:
      name: timeoutMS
      in: query
      required: false
      schema:
        $ref: '#/components/schemas/TimeoutMS'
      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).
  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

````