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

# Top Pages

> Get the top K pages that match the given query



## OpenAPI

````yaml /api-reference/openapi.json post /queries/top-pages
openapi: 3.1.0
info:
  title: ZeroEntropy API
  description: This API provides access to ZeroEntropy's SoTA retrieval pipeline. Enjoy!
  version: 0.1.0
servers:
  - url: https://api.zeroentropy.dev/v1
    description: ZeroEntropy API
  - url: https://eu-api.zeroentropy.dev/v1
    description: ZeroEntropy API (EU datacenters)
security: []
paths:
  /queries/top-pages:
    post:
      tags:
        - Queries
      summary: Top Pages
      description: Get the top K pages that match the given query
      operationId: top_pages_queries_top_pages_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TopPagesRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TopPagesResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              example:
                detail: Description of Error
        '404':
          description: Not Found
          content:
            application/json:
              example:
                detail: Description of Error
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    TopPagesRequest:
      properties:
        collection_name:
          type: string
          title: Collection Name
          description: The name of the collection.
        query:
          type: string
          title: Query
          description: >-
            The natural language query to search with. This cannot exceed 4096
            UTF-8 bytes.
        k:
          type: integer
          title: K
          description: >-
            The number of pages to return. If there are not enough pages
            matching your filters, then fewer may be returned. This number must
            be between 1 and 1024, inclusive.
        filter:
          anyOf:
            - $ref: '#/components/schemas/StrJson'
            - type: 'null'
          description: >-
            The query filter to apply. Please read [Metadata
            Filtering](/metadata-filtering) for more information. If not
            provided, then all documents will be searched.
        include_content:
          type: boolean
          title: Include Content
          description: If set to true, then the content of all pages will be returned.
          default: false
        include_metadata:
          type: boolean
          title: Include Metadata
          description: >-
            Whether or not to include the document metadata in the response. If
            not provided, then the default will be `False`.
          default: false
        latency_mode:
          type: string
          enum:
            - low
            - high
          title: Latency Mode
          description: >-
            This option selects between our two latency modes. The higher
            latency mode takes longer, but can allow for more accurate
            responses. If desired, test both to customize your search experience
            for your particular use-case, or use the default of "low" and only
            swap if you need an additional improvement in search result quality.
          default: low
      type: object
      required:
        - collection_name
        - query
        - k
      title: TopPagesRequest
    TopPagesResponse:
      properties:
        results:
          items:
            $ref: '#/components/schemas/PageRetrievalResponse'
          type: array
          title: Results
        document_results:
          items:
            $ref: '#/components/schemas/DocumentRetrievalResponse'
          type: array
          title: Document Results
          description: >-
            The array of associated document information. Note how each result
            page has an associated document path. After deduplicating the
            document paths, this array will contain document info for each
            document path that is referenced by at least one page result.
      type: object
      required:
        - results
        - document_results
      title: TopPagesResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    StrJson:
      anyOf:
        - type: string
        - items:
            type: string
          type: array
        - items:
            $ref: '#/components/schemas/StrJson'
          type: array
        - additionalProperties:
            $ref: '#/components/schemas/StrJson'
          type: object
    PageRetrievalResponse:
      properties:
        path:
          type: string
          title: Path
          description: The path of the document that this page comes from.
        page_index:
          type: integer
          title: Page Index
          description: >-
            The index of this page in the document. This field is 0-indexed. So,
            the 1st page has index 0, and the 2nd page has index 1.
        score:
          type: number
          title: Score
          description: The relevancy score assigned to this page.
        content:
          anyOf:
            - type: string
            - type: 'null'
          title: Content
          description: >-
            The contents of this page. This property will be null when
            `include_content` is `false`, and a string when `include_content` is
            `true`.
        image_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Image Url
          description: >-
            A URL to an image of the page. This field will only be provided if
            the document has finished parsing, and if it is a filetype that is
            capable of producing images (e.g. PDF, DOCX, PPT, etc). In all other
            cases, this field will be `null`.


            NOTE: If a `/documents/update-document` call returned a new document
            id, then this url will be invalidated and must be retrieved again.
      type: object
      required:
        - path
        - page_index
        - score
        - content
        - image_url
      title: PageRetrievalResponse
      description: A Page's metadata.
    DocumentRetrievalResponse:
      properties:
        path:
          type: string
          title: Path
          description: The path of the document.
        score:
          type: number
          title: Score
          description: The relevancy score assigned to this document.
        metadata:
          anyOf:
            - $ref: '#/components/schemas/DocumentMetadataJson'
            - type: 'null'
          description: >-
            The metadata for that document. Will be `None` if `include_metadata`
            is `False`.
        file_url:
          type: string
          title: File Url
          description: >-
            A URL to the document data, which can be used to download the raw
            document content or to display the document in frontend
            applications.


            NOTE: If a `/documents/update-document` call returned a new document
            id, then this url will be invalidated and must be retrieved again.
      type: object
      required:
        - path
        - score
        - metadata
        - file_url
      title: DocumentRetrievalResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    DocumentMetadataJson:
      additionalProperties:
        anyOf:
          - type: string
          - items:
              type: string
            type: array
      type: object
  securitySchemes:
    HTTPBearer:
      type: http
      description: >-
        The `Authorization` header must be provided in the format `Bearer
        <your-api-key>`.


        You can get your API Key at the
        [Dashboard](https://dashboard.zeroentropy.dev/)!
      scheme: bearer

````