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

> Scrape font information from a website including font families, usage statistics, fallbacks, and element/word counts.

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


## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/context.dev/openapi.documented.yml get /web/fonts
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/fonts:
    get:
      tags:
        - Web Extraction
      summary: Scrape Fonts
      description: >-
        Scrape font information from a website including font families, usage
        statistics, fallbacks, and element/word counts.
      parameters:
        - name: domain
          in: query
          required: false
          schema:
            type: string
          description: >-
            Domain name to extract fonts from (e.g., 'example.com',
            'google.com'). The domain will be automatically normalized and
            validated. You must provide either 'domain' or 'directUrl', but not
            both.
        - name: directUrl
          in: query
          required: false
          schema:
            type: string
            format: uri
          description: >-
            A specific URL to fetch fonts from directly, bypassing domain
            resolution (e.g., 'https://example.com/design-system'). When
            provided, fonts are extracted from this exact URL. You must provide
            either 'domain' or 'directUrl', but not both.
        - $ref: '#/components/parameters/TimeoutMS'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: Status of the response, e.g., 'ok'
                  domain:
                    type: string
                    description: The normalized domain that was processed
                  fonts:
                    type: array
                    description: Array of font usage information
                    items:
                      type: object
                      properties:
                        font:
                          type: string
                          description: Font family name
                        uses:
                          type: array
                          items:
                            type: string
                          description: >-
                            Array of CSS selectors or element types where this
                            font is used
                        fallbacks:
                          type: array
                          items:
                            type: string
                          description: Array of fallback font families
                        num_elements:
                          type: number
                          description: Number of elements using this font
                        num_words:
                          type: number
                          description: Number of words using this font
                        percent_words:
                          type: number
                          description: Percentage of words using this font
                        percent_elements:
                          type: number
                          description: Percentage of elements using this font
                      required:
                        - font
                        - uses
                        - fallbacks
                        - num_elements
                        - num_words
                        - percent_words
                        - percent_elements
                  fontLinks:
                    type: object
                    description: >-
                      Font assets keyed by family name as it appears in the
                      fonts array (non-generic names only). Clients match
                      entries in fonts to pick a file URL from files. Omitted
                      when no families resolve to Google or custom @font-face
                      URLs.
                    additionalProperties:
                      type: object
                      required:
                        - type
                        - files
                      properties:
                        type:
                          type: string
                          enum:
                            - google
                            - custom
                        files:
                          type: object
                          additionalProperties:
                            type: string
                          description: >-
                            Upright font files keyed by weight string (e.g.
                            "400" for regular, "500", "700"). Values are
                            absolute URLs.
                        category:
                          type: string
                          description: >-
                            Google Fonts category when type is google (e.g.
                            sans-serif, serif, monospace, display, handwriting).
                            Omitted for custom fonts when unknown.
                        displayName:
                          type: string
                          description: >-
                            Present when type is custom: human-readable name
                            derived from the fontLinks key (strip build/hash
                            suffixes, split camelCase / PascalCase, normalize
                            separators). Google entries omit this.
                  code:
                    type: integer
                    description: HTTP status code, e.g., 200
                required:
                  - status
                  - domain
                  - fonts
                  - code
        '400':
          description: Bad request - Invalid input parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message describing the validation error
                  error_code:
                    type: string
                    enum:
                      - INPUT_VALIDATION_ERROR
                    description: Error code indicating input validation error
        '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.extractFonts();

            console.log(response.code);
        - 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.extract_fonts()
            print(response.code)
        - lang: Ruby
          source: |-
            require "context_dev"

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

            response = context_dev.web.extract_fonts

            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

````