Prisma Aggregation API

Count, aggregate, and groupBy operations for analytics

Operations 3

Each operation below carries the questions people ask an LLM about it and the instructions they give an agent to run it. Generated by API Evangelist overlay

GET /{model}/count Count records that match a filter · Prisma Count matching records #
Ask an LLM
“How many rows in my User model match a given filter?”
“Can I see how many non-null values each field has in a model?”
Tell an agent
Count the {model} records where {where}.
Count non-null values of {select} in {model}.
GET /{model}/aggregate Compute sums, averages, min and max on a model · Prisma Aggregate records #
Ask an LLM
“What's the average and total of a numeric column across my records?”
“Can I get the minimum and maximum value of a field in one call?”
Tell an agent
Get the average of {avg_fields} across all {model} rows.
Sum {sum_fields} for {model} records matching {where}.
GET /{model}/groupBy Group records and aggregate each group · Prisma Group records and aggregate #
Ask an LLM
“How do I group my orders by status and total each group?”
“Can I drop groups whose aggregate doesn't meet a threshold?”
Tell an agent
Group {model} records by {by}.
Group {model} by {by}, keeping only groups where {having}.

Documentation

Specifications

Other Resources

🔗
Reference
https://www.prisma.io/docs/accelerate/reference/api-reference
🔗
FAQ
https://www.prisma.io/docs/accelerate/more/faq
🔗
SDKs
https://www.prisma.io/docs/rest-api/sdk
🔗
Reference
https://www.prisma.io/docs/orm/reference/prisma-client-reference
🔗
SDKs
https://www.npmjs.com/package/@prisma/client
🔗
SDKs
https://www.npmjs.com/package/@prisma/extension-optimize
🔗
APIsJSON
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/apis.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-accelerate-query-and-invalidate-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-client-list-and-count-records-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-client-upsert-record-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-optimize-record-and-analyze-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-platform-bootstrap-environment-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-platform-rotate-api-key-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-postgres-add-database-to-project-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-postgres-backup-and-restore-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-postgres-find-and-delete-project-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-postgres-provision-project-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-postgres-rotate-connection-workflow.yml
🔗
Arazzo
https://raw.githubusercontent.com/api-evangelist/prisma/refs/heads/main/arazzo/prisma-pulse-named-stream-resume-workflow.yml

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/prisma:prisma-aggregation-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

prisma-aggregation-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Prisma Client Aggregation API
  description: Auto-generated, type-safe query builder for Node.js and TypeScript that provides programmatic database access.
  version: 1.0.0
  contact:
    name: Prisma Support
    email: support@prisma.io
    url: https://www.prisma.io/support
  license:
    name: Apache-2.0
    url: https://opensource.org/licenses/Apache-2.0
  termsOfService: https://www.prisma.io/terms
servers:
- url: https://localhost:3000/api
  description: Local development server. Prisma Client is typically used as a library, not a REST API. This specification documents the operations available when exposed via a REST layer.
tags:
- name: Aggregation
  description: Count, aggregate, and groupBy operations for analytics
paths:
  /{model}/count:
    get:
      operationId: count
      summary: Prisma Count matching records
      description: Returns the count of records matching the filter criteria. Optionally provides field-level counts showing how many non-null values exist for each specified field.
      tags:
      - Aggregation
      parameters:
      - $ref: '#/components/parameters/ModelName'
      - name: where
        in: query
        description: JSON-encoded filter conditions
        schema:
          type: string
      - name: select
        in: query
        description: JSON-encoded field selection for field-level counts
        schema:
          type: string
      responses:
        '200':
          description: Successfully retrieved count
          content:
            application/json:
              schema:
                oneOf:
                - type: integer
                  description: Total count when no field selection
                - type: object
                  description: Field-level counts
                  additionalProperties:
                    type: integer
        '400':
          $ref: '#/components/responses/BadRequest'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /{model}/aggregate:
    get:
      operationId: aggregate
      summary: Prisma Aggregate records
      description: Performs aggregate calculations on matching records. Supports _count, _avg, _sum, _min, and _max operations on numeric fields with optional filtering and ordering.
      tags:
      - Aggregation
      parameters:
      - $ref: '#/components/parameters/ModelName'
      - name: where
        in: query
        description: JSON-encoded filter conditions
        schema:
          type: string
      - name: _count
        in: query
        description: Fields to count or true for total count
        schema:
          type: string
      - name: _avg
        in: query
        description: JSON-encoded specification of fields to average
        schema:
          type: string
      - name: _sum
        in: query
        description: JSON-encoded specification of fields to sum
        schema:
          type: string
      - name: _min
        in: query
        description: JSON-encoded specification of fields to find minimum
        schema:
          type: string
      - name: _max
        in: query
        description: JSON-encoded specification of fields to find maximum
        schema:
          type: string
      responses:
        '200':
          description: Successfully performed aggregation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AggregateResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /{model}/groupBy:
    get:
      operationId: groupBy
      summary: Prisma Group records and aggregate
      description: Groups records by one or more fields and applies aggregate functions within each group. Supports filtering groups with having conditions and ordering groups by field values or aggregate results.
      tags:
      - Aggregation
      parameters:
      - $ref: '#/components/parameters/ModelName'
      - name: by
        in: query
        required: true
        description: JSON-encoded list of fields to group by
        schema:
          type: string
      - name: where
        in: query
        description: JSON-encoded filter conditions applied before grouping
        schema:
          type: string
      - name: having
        in: query
        description: JSON-encoded filter conditions applied after grouping
        schema:
          type: string
      - name: orderBy
        in: query
        description: JSON-encoded sort specification for groups
        schema:
          type: string
      responses:
        '200':
          description: Successfully grouped and aggregated records
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GroupByResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    AggregateResult:
      type: object
      description: Result of an aggregation operation
      properties:
        _count:
          type: object
          description: Count of records or field-level counts
          additionalProperties:
            type: integer
        _avg:
          type: object
          description: Average values for numeric fields
          additionalProperties:
            type: number
        _sum:
          type: object
          description: Sum of numeric field values
          additionalProperties:
            type: number
        _min:
          type: object
          description: Minimum values per field
          additionalProperties: true
        _max:
          type: object
          description: Maximum values per field
          additionalProperties: true
    GroupByResult:
      type: object
      description: A single group result from a groupBy operation
      additionalProperties: true
    PrismaError:
      type: object
      description: Error response from Prisma Client. Error codes follow the Pxxxx format documented at https://www.prisma.io/docs/orm/reference/error-reference
      properties:
        code:
          type: string
          description: Prisma error code (e.g., P2002 for unique constraint violation)
          pattern: ^P[0-9]{4}$
          examples:
          - P2002
          - P2025
        message:
          type: string
          description: Human-readable error description
        meta:
          type: object
          description: Additional error context
          additionalProperties: true
      required:
      - code
      - message
  responses:
    BadRequest:
      description: The request was invalid or malformed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PrismaError'
    InternalServerError:
      description: An unexpected error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PrismaError'
  parameters:
    ModelName:
      name: model
      in: path
      required: true
      description: The Prisma model name (e.g., user, post, comment) as defined in the Prisma schema file
      schema:
        type: string
        examples:
        - user
        - post
externalDocs:
  description: Prisma Client API Reference
  url: https://www.prisma.io/docs/orm/reference/prisma-client-reference