openapi: 3.1.0

info:
  contact:
    email: contact@speedvitals.com
    name: SpeedVitals Dev Team
    url: https://speedvitals.com
  description: |
    The SpeedVitals REST API. Please see [https://docs.speedvitals.com/api](https://docs.speedvitals.com/api/) for more details.
  termsOfService: https://speedvitals.com/terms-of-use
  title: SpeedVitals API
  version: 0.1.0

servers:
  - url: https://api.speedvitals.com

externalDocs:
  description: Home
  url: https://speedvitals.com

x-topics:
  - title: Rate Limits
    content: |
      SpeedVitals API has a rate limit to protect our service from attacks and ensure its stability. For normal use case, the limits are quite high and wouldn't cause any issue.

      There are primarily two rate limits:
      - Global rate limit: The global rate limit is the maximum number of requests that can be made in a given time period across all API endpoints. The global rate limit is **120** requests in a minute. When this exceeds, the 429 Status Code will show up along with the rate limit headers, as described in the table.
      - Concurrency limit: This rate limit applies on the number of tests running in parallel. The concurrency limit is **2** for single lighthouse test and **1** for batch lighthouse test. When this exceeds, the 429 Status Code will be returned and new test won't start until current tests finishes.

      If you are facing any issues regarding rate limits, please [Contact Us](https://speedvitals.com/contact-us).
    example: |
      **List of response headers when global rate limit exceeds:**

      |         Header           |                                 Description                                   |
      | -------------------------|-------------------------------------------------------------------------------|
      |   Retry-After            |  The minimum time to wait in seconds before making next request               |
      |   X-RateLimit-Limit      |  The maximum number of requests available in the current time window.         |
      |   X-RateLimit-Remaining  |  The number of remaining requests in the current time window                  |
      |   X-RateLimit-Reset      |  The time at which the current rate limit window resets in UTC epoch seconds  |
  - title: Errors
    content: |
      SpeedVitals uses conventional HTTP response codes to indicate the success or failure of an API request.

      In general, Codes in the `2xx` range indicate success. Codes in the `4xx` range indicate an error that
      failed given the information provided (e.g., a required parameter was omitted, lighthouse test failed,
      etc.). Codes in the `5xx` range indicate an error with SpeedVitals servers (these are rare).
    example: |
      **List of common errors codes:**

      |  HTTP Status  |           Description             |
      | ------------- | --------------------------------- |
      |      401      |          Unauthorized             |
      |      429      |       Rate Limit Exceeded         |
      |      500      |      Internal Server Error        |
      |      502      |     Server Under Maintenance      |

tags:
  - name: Ping
  - name: Devices
  - name: Locations
  - name: Lighthouse Tests
  - name: Lighthouse Batch Tests
  - name: TTFB Regions
  - name: TTFB Tests
  - name: Account

paths:
  /ping:
    get:
      tags: [ Ping ]
      summary: Check API status
      description: Responds a pong if the API is up and running.
      operationId: Ping
      security: []
      responses:
        '200':
          description: Success
          content:
            'application/json':
              schema:
                $ref: '#/components/schemas/pong'
  /v1/devices:
    get:
      tags: [ Devices ]
      summary: List all devices
      description: Returns a list of SpeedVitals supported devices
      operationId: GetDevices
      security: []
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                description: An object containing a list of device objects
                type: object
                properties:
                  data:
                    type: array
                    description: An array of device objects
                    items:
                      $ref: '#/components/schemas/device'
              examples:
                default:
                  $ref: '#/components/examples/devices'
  /v1/devices/{id}:
    get:
      tags: [ Devices ]
      summary: Get a device
      description: Retrieves a device info
      operationId: GetDevice
      security: []
      parameters:
      - in: path
        name: id
        description: Device id
        required: true
        schema:
          maxLength: 5000
          type: string
        style: simple
      responses:
        '200':
          content:
            application/json:
              schema:
                '$ref': '#/components/schemas/device'
              examples:
                default:
                  value:
                    id: macbookAirM1
                    name: MacBook Air (2020)
                    category: desktop
          description: Successful response.
        '404':
          description: Device not found
          $ref: '#/components/responses/NotFound'
  /v1/locations:
    get:
      tags: [ Locations ]
      summary: List all locations
      description: Returns a list of SpeedVitals supported locations
      operationId: GetLocations
      security: []
      responses:
        '200':
          content:
            application/json:
              schema:
                description: An object containing a list of location objects
                type: object
                properties:
                  data:
                    type: array
                    description: An array of location objects
                    items:
                      $ref: '#/components/schemas/location'
              examples:
                default:
                  $ref: '#/components/examples/locations'
          description: Successful response.
  /v1/locations/{id}:
    get:
      tags: [ Locations ]
      summary: Get a location
      description: Retrieves a location info
      operationId: GetLocation
      security: []
      parameters:
      - in: path
        name: id
        description: Location id
        required: true
        schema:
          maxLength: 5000
          type: string
        style: simple
      responses:
        '200':
          content:
            application/json:
              schema:
                '$ref': '#/components/schemas/location'
              examples:
                default:
                  value:
                    id: us
                    name: United States
                    full_name: South Carolina, US
                    region: America
          description: Successful response.
        '404':
          description: Location not found
          $ref: '#/components/responses/NotFound'
  /v1/ttfb-regions:
    get:
      tags: [ TTFB Regions ]
      summary: List all TTFB regions
      description: Returns a list of SpeedVitals supported regions for TTFB test
      operationId: GetTtfbRegions
      security: []
      responses:
        '200':
          content:
            application/json:
              schema:
                description: An object containing a list of ttfb regions
                type: object
                properties:
                  data:
                    type: array
                    description: An array of region objects
                    items:
                      $ref: '#/components/schemas/ttfb_region'
              examples:
                default:
                  $ref: '#/components/examples/ttfb_regions'
          description: Successful response.
  /v1/ttfb-regions/{id}:
    get:
      tags: [ TTFB Regions ]
      summary: Get a TTFB region
      description: Retrieves a TTFB region info
      operationId: GetTtfbRegion
      security: []
      parameters:
      - in: path
        name: id
        description: Region id
        required: true
        schema:
          maxLength: 5000
          type: string
        style: simple
      responses:
        '200':
          content:
            application/json:
              schema:
                '$ref': '#/components/schemas/ttfb_region'
          description: Successful response.
        '404':
          description: TTFB Region not found
          $ref: '#/components/responses/NotFound'
  /v1/lighthouse-tests:
    post:
      tags: [ Lighthouse Tests ]
      summary: Run a lighthouse test
      description: Runs a new lighthouse test.
      operationId: RunLighthouseTest
      requestBody:
        description: This is the lighthouse test body object
        content:
          application/json:
            schema:
              properties:
                url:
                  description: 'The url of webpage'
                  type: string
                device:
                  $ref: '#/components/schemas/device_id'
                location:
                  $ref: '#/components/schemas/location_id'
                config:
                  $ref: '#/components/schemas/lighthouse_config'
            examples:
              default:
                $ref: '#/components/examples/run_lighthouse_test_request'
      responses:
        '201':
          description: A lighthouse report to be returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/lighthouse_report'
              examples:
                default:
                  $ref: '#/components/examples/run_lighthouse_test_response'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientCredits'
        '429':
          $ref: '#/components/responses/RateLimitExceeded'
        '500':
          $ref: '#/components/responses/InternalServerError'
    get:
      tags: [ Lighthouse Tests ]
      summary: List all lighthouse reports
      description: Returns a list of your lighthouse tests. The tests are returned sorted by creation date,
        with the most recently created test appearing first.
      operationId: GetLighthouseTests
      parameters:
        - name: page_number
          description: The page number to return. The default page number is 1.
          in: query
          required: false
          schema:
            type: integer
          example: 1
          style: form
        - name: page_size
          description: A size of the number of objects to be returned. Page size can range
            between 1 and 100, and the default is 10.
          in: query
          required: false
          schema:
            type: integer
          style: form
        - name: created_at[gt]
          description: Filter tests where the created_at field is greater than this value
          in: query
          required: false
          schema:
            type: integer
          example: 1657537257521
        - name: created_at[gte]
          description: Filter tests where the created_at field is greater than this value.
          in: query
          required: false
          schema:
            type: integer
        - name: created_at[lt]
          description: Filter tests where the created_at field is less than this value.
          in: query
          required: false
          schema:
            type: integer
        - name: created_at[lte]
          description: Filter tests where the created_at field is less than or equal to this value.
          in: query
          required: false
          schema:
            type: integer
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                description: A object with a data property that contains an array of your lighthouse tests,
                  sorted by creation date. Each entry in the array is a separate lighthouse test object.
                  If no more tests are available, the resulting array will be empty. This request should
                  never throw an error.
                properties:
                  data:
                    items:
                      '$ref': '#/components/schemas/lighthouse_report'
                    type: array
                required:
                - data
                type: object
              examples:
                default:
                  $ref: '#/components/examples/lighthouse_reports'
        '400':
          $ref: '#/components/responses/BadRequest'
  /v1/lighthouse-tests/{id}:
    get:
      tags: [ Lighthouse Tests ]
      summary:  Retrieve a lighthouse report
      description: Retrieves the report of lighthouse test. Supply the unique
        test ID from either a lighthouse test creation request or the lighthouse
        tests list, and SpeedVitals will return the corresponding test information.
      operationId: GetLighthouseReport
      parameters:
        - in: path
          name: id
          required: true
          schema:
            maxLength: 5000
            type: string
            example: lt_LthsZedDcOUfYFHxN
          style: simple
      responses:
        '200':
          content:
            application/json:
              schema:
                '$ref': '#/components/schemas/lighthouse_report'
          description: Successful response.
        '404':
          $ref: '#/components/responses/NotFound'
  /v1/lighthouse-tests/{id}/resources/{resource_name}:
    get:
      tags: [ Lighthouse Tests ]
      summary:  Get a report resource
      description: Retrieves the resource of lighthouse report. Supply the unique
        test ID from either a lighthouse test creation request or the lighthouse
        tests list along with resource name to get that resource.
      operationId: GetLighthouseReportResource
      parameters:
        - in: path
          name: id
          required: true
          schema:
            maxLength: 5000
            type: string
          style: simple
        - in: path
          name: resource_name
          required: true
          schema:
            maxLength: 5000
            type: string
            enum:
              - pdf
              - har
              - video
          style: simple
      responses:
        '200':
          content:
            image/jpeg:
              schema:
                type: string
                format: binary
            video/mp4:
              schema:
                type: string
                format: binary
            application/json:
                schema:
                  type: object
          description: Successful response.
        '404':
          $ref: '#/components/responses/NotFound'
  /v1/lighthouse-batch-tests:
    post:
      tags: [ Lighthouse Batch Tests ]
      summary: Run a lighthouse batch test
      description: Runs a new lighthouse batch test.
      operationId: RunLighthouseBatchTest
      requestBody:
        description: This is the lighthouse batch test body object
        content:
          application/json:
            schema:
              properties:
                urls:
                  title: list of urls
                  description: For multiple-urls batch type, provide an array of urls to test. For other
                    batch types, provide a single url in array and if multiple urls are provided, only
                    first in the list will be used for the test. All invalid urls in the array will be
                    ignored.
                  type: array
                  items:
                    maxLength: 5000
                    type: string
                devices:
                  title: list of devices
                  description: For multiple-devices batch type, provide an array of device ids to test or
                    leave it empty for testing on all preset devices. For other batch types, provide a single
                    device id in array and if multiple device ids are provided, only first in the list
                    will be used for the test. All invalid device ids in the array will be ignored.
                  type: array
                  items:
                    maxLength: 5000
                    $ref: '#/components/schemas/device_id'
                locations:
                  title: list of locations
                  description: For multiple-locations batch type, provide an array of location ids to test or
                    leave it empty for testing on all preset locations. For other batch types, provide just a single
                    location id in array and if multiple location ids are provided, only first in the list will be
                    used for the test. All invalid location ids in the array will be ignored.
                  type: array
                  items:
                    maxLength: 5000
                    $ref: '#/components/schemas/location_id'
                batch_type:
                  description: The type of batch test to run
                  type: string
                  enum:
                    - multiple-urls
                    - multiple-devices
                    - multiple-locations
                config:
                  $ref: '#/components/schemas/lighthouse_config'
            examples:
              default:
                $ref: '#/components/examples/run_lighthouse_batch_test_request'
      responses:
        '201':
          description: A lighthouse batch report to be returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/lighthouse_batch_report'
              examples:
                default:
                  $ref: '#/components/examples/run_lighthouse_batch_test_response'
        '400':
          $ref: '#/components/responses/BadRequest'
        '402':
          $ref: '#/components/responses/InsufficientCredits'
  /v1/lighthouse-batch-tests/{id}:
    get:
      tags: [ Lighthouse Batch Tests ]
      summary: Retrieve a lighthouse batch report
      description: Retrieves the report of lighthouse test. Supply the unique
        test ID from either a lighthouse test creation request or the lighthouse
        tests list, and SpeedVitals will return the corresponding test information.
      operationId: GetLighthouseBatchReport
      parameters:
      - in: path
        name: id
        required: true
        schema:
          maxLength: 5000
          type: string
        style: simple
      responses:
        '200':
          content:
            application/json:
              schema:
                '$ref': '#/components/schemas/lighthouse_batch_report'
          description: Successful response.
        '404':
          $ref: '#/components/responses/NotFound'
  /v1/ttfb-tests:
    post:
      tags: [ TTFB Tests ]
      summary: Run a TTFB test
      description: Runs a new TTFB test for a region.
      operationId: RunTTFBTest
      requestBody:
        description: This is the TTFB test body object
        content:
          application/json:
            schema:
              properties:
                url:
                  description: The url of the webpage
                  type: string
                  example: https://speedvitals.com
                region:
                  description: The id of a ttfb region
                  $ref: '#/components/schemas/ttfb_region_id'
                  example: asia
      responses:
        '201':
          description: A TTFB result to be returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ttfb_result'
              examples:
                default:
                  $ref: '#/components/examples/ttfb_result'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientCredits'
        '429':
          $ref: '#/components/responses/RateLimitExceeded'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /v1/account/credits:
    get:
      tags: [ Account ]
      summary: Check credits
      description: Fetch lighthouse and ttfb credits available in account
      operationId: GetCredits
      responses:
        '200':
          description: A credits data object to be returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/credits'

security:
  - apiKey: []

components:
  responses:
    NotFound:
      description: Resource Not Found
    BadRequest:
      description: Invalid Request body or missing required parameters
      content:
        'application/json':
          schema:
            $ref: '#/components/schemas/error'
    RateLimitExceeded:
      description: Rate Limit Exceeded
    Unauthorized:
      description: Invalid API Key
    InternalServerError:
      description: Internal Server Error
    InsufficientCredits:
      description: Insufficient Credits
      content:
        'application/json':
          schema:
            $ref: '#/components/schemas/error'
  schemas:
    device:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/device_id'
        name:
          type: string
          example: MacBook Air (2020)
        category:
          type: string
          example:  desktop
          enum:
            - mobile
            - desktop
            - tablet
    device_id:
      type: string
      example: macbookAirM1
      enum:
        - mobile
        - desktop
        - macbookAirM1
        - highEndLaptop
        - ipad102
        - galaxyTabS7
        - iphone13ProMax
        - iphone11
        - galaxyS10Plus
        - redmiNote8Pro
        - iphone7
        - galaxyA50
        - galaxyJ8
        - motoG5
        - redmi5A
    location:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/location_id'
        name:
          type: string
          example: 'United States'
        full_name:
          type: string
          example: 'South Carolina, US'
        region:
          type: string
          example: 'America'
          enum:
            - America
            - Europe
            - Asia Pacific
    location_id:
      type: string
      example: 'us'
      enum:
        - us
        - ca
        - br
        - de
        - uk
        - nl
        - pl
        - ch
        - jp
        - in
        - sg
        - au
        - id
        - kr
        - tw
    ttfb_region:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ttfb_region_id'
        name:
          type: string
          example: 'Asia Pacific and Africa'
        locations:
          type: array
          items:
            $ref: '#/components/schemas/ttfb_location'
    ttfb_region_id:
      type: string
      example: 'asia'
      enum:
        - asia
        - america
        - europe
    ttfb_location:
      type: object
      properties:
        id:
          type: string
          example: del
        name:
          type: string
          example: Delhi
    lighthouse_metrics:
      type: [object, "null"]
      properties:
        cumulative_layout_shift:
          description: Cumulative Layout Shift
          type: number
          example: 0.01
        first_contentful_paint:
          type: number
          description: First Contentful Paint time (in milliseconds)
          example: 1232
        first_meaningful_paint:
          description: First Meaningful Paint time (in milliseconds)
          type: number
          example: 1245
        time_to_interactive:
          description: Time to Interactive (in milliseconds)
          type: number
          example: 1458
        largest_contentful_paint:
          description: Largest Contentful Paint time (in milliseconds)
          type: number
          example: 1245
        server_response_time:
          description: TTFB (in milliseconds)
          type: number
          example: 70
        speed_index:
          description: Speed Index (in milliseconds)
          type: number
          example: 1367
        total_blocking_time:
          description: Total Blocking time (in milliseconds)
          type: number
          example: 39
        performance_score:
          description: Performance Score (in percentage)
          type: number
          example: 96
    lighthouse_config:
      type: object
      properties:
        connection:
          description: Connection Type
          type: [string, "null"]
          enum:
            - fiber
            - cable
            - dsl
            - 5g
            - wifi_fast
            - wifi
            - 4g_fast
            - 4g
            - 3g_fast
            - 3g
            - 3g_slow
            - 2g_edge
            - 2g
            - null
          maxLength: 5000
        throttling_method:
          description: Choose between simulated throttling and applied throttling
          type: [string, "null"]
          maxLength: 5000
          default: simulated
        http_version:
          description: Force HTTP/1.1 or HTTP/2(default)
          type: [string, "null"]
          maxLength: 5000
          default: '2'
        video:
          description: Enable page load video
          type: [boolean, "null"]
          maxLength: 5000
          default: false
        adblock:
          description: Enable Adblock
          type: [boolean, "null"]
          default: false
        user_agent:
          description: Run test with custom user agent
          type: [string, "null"]
          maxLength: 5000
        auth_username:
          description: Username for authentication
          type: [string, "null"]
          maxLength: 5000
        auth_password:
          description: Password for authentication
          type: [string, "null"]
          maxLength: 5000
        cookies:
          description: List of session cookies
          type: [array, "null"]
          items:
            type: string
          maxLength: 5000
        whitelist:
          description: List of whitelisted urls(Max 5)
          type: [array, "null"]
          items:
            type: string
        blacklist:
          description: List of blacklisted urls(Max 10)
          type: [array, "null"]
          items:
            type: string
    lighthouse_report:
      type: object
      required:
        - url
        - device
        - location
        - status
        - lighthouse_version
      properties:
        id:
          type: string
        url:
          type: string
        device:
          $ref: '#/components/schemas/device_id'
        location:
          $ref: '#/components/schemas/location_id'
        config:
          $ref: '#/components/schemas/lighthouse_config'
        status:
          type: string
          enum:
            - idle
            - active
            - success
            - failed
        lighthouse_version:
          description: The version of the lighthouse used to generate the report
          type: string
        metrics:
          $ref: '#/components/schemas/lighthouse_metrics'
        report_url:
          description: The URL at which SpeedVitals report is accessible (Present when status is success)
          type: [string, "null"]
        created_at:
          description: Time at which the test was created. Measured in seconds since the Unix epoch.
          type: number
        expires_at:
          description: Time at which the report will expire. Measured in seconds since the Unix epoch.
          type: number
        error:
          description: Contains error code and description(present only if status is failed)
          type: [object, "null"]
          properties:
            code:
              description: Error code specific to lighthouse error
              type: string
            message:
              description: Error message describing the summary of lighthouse error
              type: string
      example:
        id: lt_LthsZedDcOUfYFHxN
        url: https://speedvitals.com
        device: macbookAirM1
        location: us
        config:
          http_version: "2"
          video: true
          adblock: true
        status: idle
        lighthouse_version: '9.6.2'
        metrics:
          cumulative_layout_shift: 0.0
          first_contentful_paint: 515
          first_meaningful_paint: 566
          time_to_interactive: 725
          largest_contentful_paint: 515
          server_response_time: 21
          speed_index: 1123
          total_blocking_time: 69
          performance_score: 99
        report_url: https://speedvitals.com/report/speedvitals.com/Q6qWx6/
        created_at: 1657537268453
        expires_at: 1660129268453
        error: null
    lighthouse_batch_report:
      type: object
      required:
        - urls
        - devices
        - locations
        - batch_type
      properties:
        id:
          type: string
        urls:
          type: array
          items:
            type: string
        devices:
          type: array
          items:
            $ref: '#/components/schemas/device_id'
        locations:
          type: array
          items:
            $ref: '#/components/schemas/location_id'
        batch_type:
          type: string
          enum:
            - multiple-urls
            - multiple-devices
            - multiple-locations
        config:
          $ref: '#/components/schemas/lighthouse_config'
        status:
          type: string
          enum:
            - idle
            - active
            - completed
        lighthouse_version:
          description: The version of the lighthouse used to run the tests
          type: string
        report_url:
          type: string
        created_at:
          description: Time at which the batch test was created. Measured in seconds since the Unix epoch.
          type: number
        expires_at:
          description: Time at which the batch report will expire. Measured in seconds since the Unix epoch.
          type: number
        reports:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              url:
                type: string
              device:
                $ref: '#/components/schemas/device_id'
              location:
                $ref: '#/components/schemas/location_id'
              status:
                type: string
                enum:
                  - idle
                  - active
                  - success
                  - failed
              metrics:
                $ref: '#/components/schemas/lighthouse_metrics'
              report_url:
                description: The URL at which SpeedVitals report is accessible (Present when status is success)
                type: [string, "null"]
              error:
                description: Contains error code and description(present only if status is failed)
                type: [object, "null"]
                properties:
                  code:
                    description: Error code specific to lighthouse error
                    type: string
                  message:
                    description: Error message describing the summary of lighthouse error
                    type: string
      example:
        id: lbt_IU8rN0XQmIWEqGkP
        urls: [https://speedvitals.com, https://blog.speedvitals.com]
        devices: [ macbookAirM1 ]
        locations: [ us ]
        batch_type: multiple-urls
        status: active
        lighthouse_version: '9.6.2'
        report_url: https://speedvitals.com/result/afd98w0l/
        created_at: 1657539924734
        expires_at: 1660131924733
        reports:
          - id: lt_dObdG5EW4d231hto
            url: https://speedvitals.com
            device: macbookAirM1
            location: us
            status: success
            metrics:
              cumulative_layout_shift: 0.0
              first_contentful_paint: 292
              first_meaningful_paint: 297
              time_to_interactive: 297
              largest_contentful_paint: 434
              server_response_time: 32
              speed_index: 900
              total_blocking_time: 0
              performance_score: 100
            report_url: https://speedvitals.com/report/speedvitals.com/IvWenx/
            error: null
          - id: lt_dmpbeQ2xk1XPh4UP
            url: https://blog.speedvitals.com
            device: macbookAirM1
            location: us
            status: idle
            metrics:
              cumulative_layout_shift: 0.0
              first_contentful_paint: 322
              first_meaningful_paint: 365
              time_to_interactive: 368
              largest_contentful_paint: 488
              server_response_time: 68
              speed_index: 1406
              total_blocking_time: 0
              performance_score: 99
            report_url: https://speedvitals.com/report/blog.speedvitals.com/3t4lm7
            error: null
    ttfb_result:
      type: object
      required:
        - url
        - region
      properties:
        url:
          type: string
        region:
          $ref: '#/components/schemas/ttfb_region_id'
        result:
          type: array
          items:
            type: object
            properties:
              location_id:
                type: string
              location_name:
                type: string
              status:
                type: string
                enum:
                  - success
                  - failed
              data:
                type: [object, "null"]
                properties:
                  timings:
                    type: object
                    properties:
                      dns_lookup:
                        description: DNS Lookup time (in milliseconds)
                        type: integer
                      server_processing:
                        description: Server Processing time (in milliseconds)
                        type: integer
                      tcp_connection:
                        description: TCP Connection time (in milliseconds)
                        type: integer
                      tls_handshake:
                        description: TLS Handshake time (in milliseconds)
                        type: integer
                      total:
                        description: Total time (in milliseconds)
                        type: integer
                      ttfb:
                        description: Time to First Byte (in milliseconds)
                        type: integer
                  http_version:
                    type: integer
                  http_status:
                    type: integer
                  response_headers:
                    type: object
              error:
                description: Contains error code and description(Present only if status failed)
                type: [object, "null"]
                properties:
                  code:
                    description: Error code
                    type: string
                  message:
                    description: Error message describing the summary of ttfb error
                    type: string
    credits:
      description: An object containing information about the remaining lighthouse and ttfb credits
      type: object
      properties:
        lighthouse:
          type: object
          properties:
            available_credits:
              type: number
              example: 100
            available_paid_credits:
              type: number
              example: 0
        ttfb:
          type: object
          properties:
            available_credits:
              type: number
              example: 32
            available_paid_credits:
              type: number
              example: 0
        credits_refill_date:
          type: string
          example: "1657535713"
    pong:
      type: string
      description: Responds with a pong
      example: pong
    error:
      description: An error response from the SpeedVitals API
      type: object
      properties:
        code:
          description: An error code specific to the error.
          type: string
        message:
          description: A human-readable message providing more details about the error.
          type: string
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-KEY
  examples:
    devices:
      value:
        data:
          - id: macbookAirM1
            name: MacBook Air (2020)
            category: desktop
          - id: iphone13ProMax
            name: iPhone 13 Pro Max
            category: mobile
    locations:
      value:
        data:
          - id: us
            name: United States
            full_name: South Carolina, US
            region: America
          - id: de
            name: Germany
            full_name: Frankfurt, Germany
            region: Europe
    ttfb_regions:
      value:
        data:
          - id: asia
            name: Asia Pacific and Africa
            locations:
              - id: del
                name: Delhi
              - id: sgp
                name: Singapore
    ttfb_result:
      value:
        url: https://speedvitals.com
        region: america
        result:
          - location_id: del
            location_name: Delhi
            status: success
            data:
              timings:
                dns_lookup: 2
                server_processing: 18
                tcp_connection: 10
                tls_handshake: 25
                total: 56
                ttfb: 55
              http_version: 2
              http_status: 200
              response_headers:
                accept-ranges: bytes
                age: 520141
                cache-control: max-age=604800
                vary: Accept-Encoding
                x-cache: HIT
            error: null
    run_lighthouse_test_request:
      value:
        url: https://speedvitals.com
        device: macbookAirM1
        location: us
        config:
          connection: fiber
          video: true
          adblock: true
    run_lighthouse_test_response:
      value:
        url: https://speedvitals.com
        device: macbookAirM1
        location: us
        config:
          connection: fiber
          video: true
          adblock: true
        status: success
        lighthouse_version: '9.6.2'
        metrics: null
        report_url: null
        created_at: 1657537268453
        expires_at: 1660129268453
        error: null
    lighthouse_report:
      value:
        id: lt_LthsZedDcOUfYFHxN
        url: https://speedvitals.com
        device: macbookAirM1
        location: us
        config:
          http_version: "2"
          video: true
          adblock: true
        status: idle
        lighthouse_version: '9.6.2'
        metrics:
          cumulative_layout_shift: 0.0
          first_contentful_paint: 515
          first_meaningful_paint: 566
          time_to_interactive: 725
          largest_contentful_paint: 515
          server_response_time: 21
          speed_index: 1123
          total_blocking_time: 69
          performance_score: 99
        report_url: https://speedvitals.com/report/speedvitals.com/Q6qWx6/
        created_at: 1657537268453
        expires_at: 1660129268453
        error: null
    lighthouse_reports:
      value:
        data:
          - id: lt_LthsZedDcOUfYFHxN
            url: https://speedvitals.com
            device: macbookAirM1
            location: us
            config:
              http_version: "2"
              video: true
              adblock: true
            status: idle
            lighthouse_version: '9.6.2'
            metrics:
              cumulative_layout_shift: 0.0
              first_contentful_paint: 515
              first_meaningful_paint: 566
              time_to_interactive: 725
              largest_contentful_paint: 515
              server_response_time: 21
              speed_index: 1123
              total_blocking_time: 69
              performance_score: 99
            report_url: https://speedvitals.com/report/speedvitals.com/Q6qWx6/
            created_at: 1657537268453
            expires_at: 1660129268453
            error: null
    run_lighthouse_batch_test_request:
      value:
        urls: [https://speedvitals.com, https://blog.speedvitals.com]
        devices: [ macbookAirM1 ]
        locations: [ us ]
        batch_type: multiple-urls
    run_lighthouse_batch_test_response:
      value:
        id: lbt_IU8rN0XQmIWEqGkP
        urls: [https://speedvitals.com, https://blog.speedvitals.com]
        devices: [ macbookAirM1 ]
        locations: [ us ]
        # removed config: null as it is optional and strict object type forbids null
        batch_type: multiple-urls
        status: idle
        lighthouse_version: '9.6.2'
        report_url: https://speedvitals.com/result/afd98w0l/
        created_at: 1657539924734
        expires_at: 1660131924733
        reports:
          - id: lt_dObdG5EW4d231hto
            url: https://speedvitals.com
            device: macbookAirM1
            location: us
            status: success
            metrics:
              cumulative_layout_shift: 0.0
              first_contentful_paint: 292
              first_meaningful_paint: 297
              time_to_interactive: 297
              largest_contentful_paint: 434
              server_response_time: 32
              speed_index: 900
              total_blocking_time: 0
              performance_score: 100
            report_url: https://speedvitals.com/report/speedvitals.com/IvWenx/
            error: null
          - id: lt_dmpbeQ2xk1XPh4UP
            url: https://blog.speedvitals.com
            device: macbookAirM1
            location: us
            status: idle
            metrics:
              cumulative_layout_shift: 0.0
              first_contentful_paint: 322
              first_meaningful_paint: 365
              time_to_interactive: 368
              largest_contentful_paint: 488
              server_response_time: 68
              speed_index: 1406
              total_blocking_time: 0
              performance_score: 99
            report_url: https://speedvitals.com/report/blog.speedvitals.com/3t4lm7
            error: null
    lighthouse_batch_report:
      value:
        id: lbt_IU8rN0XQmIWEqGkP
        urls: [https://speedvitals.com, https://blog.speedvitals.com]
        devices: [ macbookAirM1 ]
        locations: [ us ]
        batch_type: multiple-urls
        # removed config: null
        status: active
        lighthouse_version: '9.6.2'
        report_url: https://speedvitals.com/result/afd98w0l/
        created_at: 1657539924734
        expires_at: 1660131924733
        reports:
          - id: lt_dObdG5EW4d231hto
            url: https://speedvitals.com
            device: macbookAirM1
            location: us
            status: success
            metrics:
              cumulative_layout_shift: 0.0
              first_contentful_paint: 292
              first_meaningful_paint: 297
              time_to_interactive: 297
              largest_contentful_paint: 434
              server_response_time: 32
              speed_index: 900
              total_blocking_time: 0
              performance_score: 100
            report_url: https://speedvitals.com/report/speedvitals.com/IvWenx/
            error: null
          - id: lt_dmpbeQ2xk1XPh4UP
            url: https://blog.speedvitals.com
            device: macbookAirM1
            location: us
            status: idle
            metrics:
              cumulative_layout_shift: 0.0
              first_contentful_paint: 322
              first_meaningful_paint: 365
              time_to_interactive: 368
              largest_contentful_paint: 488
              server_response_time: 68
              speed_index: 1406
              total_blocking_time: 0
              performance_score: 99
            report_url: https://speedvitals.com/report/blog.speedvitals.com/3t4lm7
            error: null