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

# Metrics Data

> Access CodeRabbit metrics data programmatically via REST API.

export const EnterprisePlanBadge = ({tip = "This feature is available exclusively as part of the Enterprise plan. Please refer to our pricing page for more information about our plans and features.", title = "Enterprise Plan", cta = "Read more", href = "https://coderabbit.ai/pricing", disabled = false}) => {
  return <Tooltip tip={tip} cta={cta} href={href}>
        <Badge icon="building-2" disabled={disabled || undefined}>
            {title}
        </Badge>
    </Tooltip>;
};

<EnterprisePlanBadge />

Returns metrics for merged pull requests including complexity scores, review times, and comment breakdowns by severity and category.

## CSV Format

When using `format=csv`, the API returns a flat CSV structure with one row per pull request. The nested `coderabbit_comments` object is flattened into individual columns (e.g., `total_coderabbit_comments_posted`, `critical_comments_accepted`).

For the complete list of CSV columns and field descriptions, see [Data Export - Exported fields](/guides/data-export#exported-fields).


## OpenAPI

````yaml get /v1/metrics/reviews
openapi: 3.0.3
info:
  title: CodeRabbit API spec
  version: 1.0.0
servers:
  - url: https://api.coderabbit.ai
security:
  - ApiKeyAuth: []
paths:
  /v1/metrics/reviews:
    get:
      summary: Metrics Data
      description: Access CodeRabbit metrics data programmatically via REST API.
      operationId: review-metrics
      parameters:
        - name: x-coderabbitai-api-key
          description: Your CodeRabbit API key
          required: true
          example: cr-xxxxxxxxxx
          schema:
            type: string
          in: header
        - name: start_date
          description: Start date in ISO 8601 format (YYYY-MM-DD)
          required: true
          example: '2026-01-01'
          schema:
            type: string
            format: date
          in: query
        - name: end_date
          description: End date in ISO 8601 format (YYYY-MM-DD)
          required: true
          example: '2026-01-20'
          schema:
            type: string
            format: date
          in: query
        - name: organization_ids
          description: >-
            Filter by organization Git provider IDs (comma-separated, max 10).
            Self-hosted instances only.
          required: false
          schema:
            type: string
          in: query
        - name: repository_ids
          description: Filter by repository Git provider IDs (comma-separated, max 10).
          required: false
          example: 672319970,849426160
          schema:
            type: string
          in: query
        - name: user_ids
          description: Filter by author Git provider IDs (comma-separated, max 10).
          required: false
          schema:
            type: string
          in: query
        - name: format
          description: Response format
          required: false
          schema:
            type: string
            enum:
              - json
              - csv
            default: json
          in: query
        - name: limit
          description: Maximum records to return
          required: false
          schema:
            type: integer
            default: 1000
          in: query
        - name: cursor
          description: Pagination cursor for fetching next page of results
          required: false
          schema:
            type: string
          in: query
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ReviewMetric'
                  next_cursor:
                    type: string
                    description: >-
                      Cursor for fetching the next page of results. Not present
                      if no more results.
                required:
                  - data
              example:
                data:
                  - pr_url: https://github.com/org/repo/pull/123
                    organization_id: '132028505'
                    organization_name: my-org
                    repository_id: '672319970'
                    repository_name: my-repo
                    author_id: '14079159'
                    author_username: john123
                    created_at: '2025-01-15T10:00:00Z'
                    first_human_review_at: '2025-01-15T10:00:00Z'
                    last_commit_at: '2025-01-15T10:00:00Z'
                    merged_at: '2025-01-16T14:30:00Z'
                    estimated_complexity: 3
                    estimated_review_minutes: 45
                    coderabbit_comments:
                      total:
                        posted: 8
                        accepted: 5
                      severity:
                        critical:
                          posted: 2
                          accepted: 1
                        major:
                          posted: 3
                          accepted: 2
                        minor:
                          posted: 2
                          accepted: 1
                        trivial:
                          posted: 1
                          accepted: 1
                        info:
                          posted: 0
                          accepted: 0
                      category:
                        security_and_privacy:
                          posted: 2
                          accepted: 1
                        performance_and_scalability:
                          posted: 1
                          accepted: 1
                        functional_correctness:
                          posted: 2
                          accepted: 1
                        maintainability_and_code_quality:
                          posted: 2
                          accepted: 1
                        data_integrity_and_integration:
                          posted: 1
                          accepted: 1
                        stability_and_availability:
                          posted: 0
                          accepted: 0
                next_cursor: '2025-01-16T10:30:00Z'
            text/csv:
              schema:
                type: string
                description: >-
                  CSV file with one row per PR. The coderabbit_comments object
                  is flattened into individual columns.
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                errors:
                  - code: INVALID_PARAMETER
                    message: 'start_date: start_date is required'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                message: Invalid or missing API key
                code: UNAUTHORIZED
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                message: API access requires an Enterprise plan subscription
                code: FORBIDDEN
        '413':
          description: Payload Too Large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                message: >-
                  Response exceeds maximum size of 16MB. Please use a smaller
                  date range or add filters.
                code: RESPONSE_TOO_LARGE
        '429':
          description: Too Many Requests
          headers:
            X-RateLimit-Limit:
              description: Maximum number of requests allowed per minute
              schema:
                type: integer
                example: 10
            X-RateLimit-Remaining:
              description: Number of requests remaining in the current rate limit window
              schema:
                type: integer
                example: 0
            X-RateLimit-Reset:
              description: Unix timestamp when the rate limit window resets
              schema:
                type: integer
                example: 1704067200
            Retry-After:
              description: Number of seconds to wait before retrying
              schema:
                type: integer
                example: 60
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                message: Rate limit exceeded. Please retry after 60 seconds.
                code: RATE_LIMITED
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |-
            curl --request GET \
              --url 'https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20' \
              --header 'x-coderabbitai-api-key: <api-key>'
        - lang: Python
          label: Python
          source: |-
            import requests

            url = 'https://api.coderabbit.ai/v1/metrics/reviews'

            headers = {'x-coderabbitai-api-key': '<api-key>'}

            params = {'start_date': '2026-01-01', 'end_date': '2026-01-20'}

            response = requests.get(url, headers=headers, params=params)

            print(response.text)
        - lang: JavaScript
          label: JavaScript
          source: >-
            const options = {method: 'GET', headers: {'x-coderabbitai-api-key':
            '<api-key>'}};


            fetch('https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20',
            options)
              .then(res => res.json())
              .then(res => console.log(res))
              .catch(err => console.error(err));
        - lang: PHP
          label: PHP
          source: |-
            <?php
            $curl = curl_init();

            curl_setopt_array($curl, [
              CURLOPT_URL => 'https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20',
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_ENCODING => '',
              CURLOPT_MAXREDIRS => 10,
              CURLOPT_TIMEOUT => 30,
              CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
              CURLOPT_CUSTOMREQUEST => 'GET',
              CURLOPT_HTTPHEADER => [
                'x-coderabbitai-api-key: <api-key>'
              ],
            ]);

            $response = curl_exec($curl);
            $err = curl_error($curl);
            curl_close($curl);

            if ($err) {
              echo 'cURL Error #:' . $err;
            } else {
              echo $response;
            }
            ?>
        - lang: Go
          label: Go
          source: "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io\"\n)\n\nfunc main() {\n\n\turl := \"https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"x-coderabbitai-api-key\", \"<api-key>\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := io.ReadAll(res.Body)\n\n\tfmt.Println(string(body))\n\n}"
        - lang: Java
          label: Java
          source: >-
            HttpResponse<String> response =
            Unirest.get("https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20")
              .header("x-coderabbitai-api-key", "<api-key>")
              .asString();
        - lang: Ruby
          label: Ruby
          source: >-
            require 'uri'

            require 'net/http'


            url =
            URI("https://api.coderabbit.ai/v1/metrics/reviews?start_date=2026-01-01&end_date=2026-01-20")


            http = Net::HTTP.new(url.host, url.port)

            http.use_ssl = true


            request = Net::HTTP::Get.new(url)

            request["x-coderabbitai-api-key"] = "<api-key>"


            response = http.request(request)

            puts response.read_body
components:
  schemas:
    ReviewMetric:
      type: object
      properties:
        pr_url:
          type: string
          description: Full URL to the pull request
        author_id:
          type: string
          description: Unique identifier assigned by Git provider
        author_username:
          type: string
          description: Username of the PR author
        organization_id:
          type: string
          description: Unique identifier for the organization assigned by Git provider
        organization_name:
          type: string
          description: Organization name
        repository_id:
          type: string
          description: Unique identifier assigned by Git provider
        repository_name:
          type: string
          description: Repository name
        created_at:
          type: string
          format: date-time
          description: When the PR was created
        first_human_review_at:
          type: string
          format: date-time
          description: When the first human review was submitted
        last_commit_at:
          type: string
          format: date-time
          description: When the last non-merge, non-rebased commit was pushed
        merged_at:
          type: string
          format: date-time
          description: When the PR was merged
        estimated_complexity:
          type: integer
          description: Complexity score (1-5)
        estimated_review_minutes:
          type: integer
          description: Estimated time to review in minutes
        coderabbit_comments:
          type: object
          description: CodeRabbit comment metrics grouped by total, severity, and category
          properties:
            total:
              $ref: '#/components/schemas/CommentCount'
            severity:
              type: object
              properties:
                critical:
                  $ref: '#/components/schemas/CommentCount'
                major:
                  $ref: '#/components/schemas/CommentCount'
                minor:
                  $ref: '#/components/schemas/CommentCount'
                trivial:
                  $ref: '#/components/schemas/CommentCount'
                info:
                  $ref: '#/components/schemas/CommentCount'
            category:
              type: object
              properties:
                security_and_privacy:
                  $ref: '#/components/schemas/CommentCount'
                performance_and_scalability:
                  $ref: '#/components/schemas/CommentCount'
                functional_correctness:
                  $ref: '#/components/schemas/CommentCount'
                maintainability_and_code_quality:
                  $ref: '#/components/schemas/CommentCount'
                data_integrity_and_integration:
                  $ref: '#/components/schemas/CommentCount'
                stability_and_availability:
                  $ref: '#/components/schemas/CommentCount'
    Error:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
              message:
                type: string
            required:
              - code
              - message
      required:
        - errors
    CommentCount:
      type: object
      properties:
        posted:
          type: integer
          description: Number of comments posted
        accepted:
          type: integer
          description: Number of comments accepted
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-coderabbitai-api-key
      description: >-
        API key for authentication. You can create an API key from the
        CodeRabbit dashboard.

````