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

# List top customers

> Find the customers who bought the most or paid you the most in a date range, largest first. Defaults to the last six months, including this one.



## OpenAPI

````yaml /api-reference/openapi.yaml get /reports/top_customers
openapi: 3.0.3
info:
  title: Streamlined API
  description: >
    Access customers, customer applications, customer groups, products, payouts,
    invoices, transactions, deposit links, and the reports behind your dashboard
    programmatically through this API, and receive webhooks when deposit links
    change. All requests must be authenticated with an API key.
  version: 1.8.0
  license:
    name: Proprietary
    url: https://streamlinedpayments.com/terms
servers:
  - url: https://api.staging.streamlinedpayments.com/api/v1
    description: Sandbox
  - url: https://api.streamlinedpayments.com/api/v1
    description: Production
security:
  - AppIdAuth: []
    ApiKeyAuth: []
tags:
  - name: Customers
    description: Create, update and delete the businesses you sell to.
  - name: Customer applications
    description: >-
      List the applications your customers submit, and approve them. Approving
      can also set net terms and export the customer to Shopify. See [Approve
      customer applications](/guides/customer-applications).
  - name: Customer groups
    description: >-
      Organize customers into groups and manage who's in each one. A group can
      be linked to a Shopify B2B company.
  - name: Customer files
    description: Upload and manage files attached to a customer.
  - name: Customer addresses
    description: Manage a customer's addresses and choose their default billing address.
  - name: Orders
    description: Create orders, add and remove line items, and schedule them.
  - name: Invoices
    description: Create invoices from orders, then list, look up and update them.
  - name: Transactions
    description: List transactions and look one up.
  - name: Payouts
    description: List payouts, including pending ones, and look one up.
  - name: Products
    description: >-
      Create and update the products and services you sell, import them in bulk,
      and merge duplicates.
  - name: Deposit links
    description: Collect money from a customer before an invoice exists.
  - name: Webhooks
    description: >-
      Register HTTPS endpoints to receive events when something changes. See
      [Webhooks](/guides/webhooks) for signatures, retries and delivery
      guarantees.
  - name: Reports
    description: >-
      Read the aging, sales, collections, and customer figures your dashboard
      and customer pages show. Amounts are in cents, in the currency each
      response names. See [Reports](/guides/reports) for how each figure is
      worked out.
paths:
  /reports/top_customers:
    get:
      tags:
        - Reports
      summary: List top customers
      description: >-
        Find the customers who bought the most or paid you the most in a date
        range, largest first. Defaults to the last six months, including this
        one.
      operationId: listTopCustomers
      parameters:
        - name: basis
          in: query
          required: false
          description: >-
            `sales` ranks by invoices issued in the range. `cash` ranks by
            payments received in it.
          schema:
            type: string
            enum:
              - sales
              - cash
            default: sales
        - name: start_date
          in: query
          required: false
          description: >-
            First day of the range, as `YYYY-MM-DD`. The range can be at most 24
            months.
          schema:
            type: string
            format: date
        - name: end_date
          in: query
          required: false
          description: Last day of the range, as `YYYY-MM-DD`.
          schema:
            type: string
            format: date
        - $ref: '#/components/parameters/ReportPage'
        - $ref: '#/components/parameters/ReportPerPage'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TopCustomers'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  parameters:
    ReportPage:
      name: page
      in: query
      description: Page number, from 1 to 10000.
      required: false
      schema:
        type: integer
        default: 1
        minimum: 1
        maximum: 10000
    ReportPerPage:
      name: per_page
      in: query
      description: Number of rows per page, from 1. Values above 100 are treated as 100.
      required: false
      schema:
        type: integer
        default: 20
        minimum: 1
  schemas:
    TopCustomers:
      type: object
      properties:
        currency:
          $ref: '#/components/schemas/Currency'
        basis:
          type: string
          enum:
            - sales
            - cash
          description: What the list ranks by, as sent.
        customer_count:
          type: integer
          description: Number of customers with an amount in the range, across every page.
          example: 86
        total:
          type: integer
          description: >-
            Every customer's amount in the range, in cents. Matches Get monthly
            sales and payments for the same months.
          example: 511000000
        data:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/ReportCustomer'
              - type: object
                properties:
                  amount:
                    type: integer
                    description: In cents.
                    example: 107000000
                  share:
                    type: number
                    nullable: true
                    description: >-
                      The customer's share of `total`, as a fraction from 0 to
                      1.
                    example: 0.21
        meta:
          $ref: '#/components/schemas/PaginationMeta'
    Currency:
      type: string
      description: >-
        ISO currency code. Most resources support these. Products are limited to
        USD, CAD, EUR, GBP, AUD.
      enum:
        - USD
        - CAD
        - GBP
        - EUR
        - AUD
        - JPY
        - INR
    ReportCustomer:
      type: object
      properties:
        uuid:
          type: string
          format: uuid
          description: The customer's UUID.
        name:
          type: string
          description: The customer's name.
          example: Harbor Foods
    PaginationMeta:
      type: object
      properties:
        current_page:
          type: integer
        per_page:
          type: integer
        total_pages:
          type: integer
        total_count:
          type: integer
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
  responses:
    BadRequest:
      description: >-
        A parameter is malformed, out of range, or not one of its allowed values
        (`invalid_parameter`). `message` says which. Values aren't ignored,
        except that `per_page` above 100 is treated as 100.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: invalid_parameter
            message: weeks must be one of 13, 26, 52
    Unauthorized:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            AuthenticationRequired:
              value:
                error: Authentication required
                message: >-
                  API endpoint requires authentication. Please provide valid
                  X-App-Id and X-Api-Key headers.
            InvalidCredentials:
              value:
                error: Invalid credentials
                message: >-
                  The provided API credentials are invalid. Please check your
                  X-App-Id and X-Api-Key values.
  securitySchemes:
    AppIdAuth:
      type: apiKey
      in: header
      name: X-App-Id
      description: App ID for authentication
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
      description: API Key for authentication

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.