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

# Retrieve events based on filters



## OpenAPI

````yaml post /events/export
openapi: 3.0.3
info:
  title: HoneyHive API
  version: 1.0.1
servers:
  - url: https://api.honeyhive.ai
security:
  - BearerAuth: []
paths:
  /events/export:
    post:
      tags:
        - Events
      summary: Retrieve events based on filters
      operationId: getEvents
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                project:
                  type: string
                  description: >-
                    Name of the project associated with the event like `New
                    Project`
                filters:
                  type: array
                  items:
                    $ref: '#/components/schemas/EventFilter'
                dateRange:
                  type: object
                  properties:
                    $gte:
                      type: string
                      description: >-
                        ISO String for start of date time filter like
                        `2024-04-01T22:38:19.000Z`
                    $lte:
                      type: string
                      description: >-
                        ISO String for end of date time filter like
                        `2024-04-01T22:38:19.000Z`
                limit:
                  type: number
                  description: >-
                    Limit number of results to speed up query (default is 1000,
                    max is 7500)
                page:
                  type: number
                  description: Page number of results (default is 1)
              required:
                - project
                - filters
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  events:
                    type: array
                    items:
                      $ref: '#/components/schemas/Event'
                  totalEvents:
                    type: number
                    description: Total number of events in the specified filter
      x-codeSamples:
        - lang: python
          label: getEvents
          source: |-
            import honeyhive
            from honeyhive.models import components, operations

            s = honeyhive.HoneyHive(
                bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
            )


            res = s.events.get_events(request=operations.GetEventsRequestBody(
                project='<value>',
                filters=[
                    components.EventFilter(
                        field='event_type',
                        value='model',
                        operator=components.Operator.IS,
                        type=components.Type.STRING,
                    ),
                ],
            ))

            if res.object is not None:
                # handle response
                pass
        - lang: typescript
          label: getEvents
          source: |-
            import { HoneyHive } from "honeyhive";
            import { Operator, TypeT } from "honeyhive/dist/models/components";

            async function run() {
              const sdk = new HoneyHive({
                bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
              });

              const res = await sdk.events.getEvents({
                project: "<value>",
                filters: [
                  {
                    field: "event_type",
                    value: "model",
                    operator: Operator.Is,
                    type: TypeT.String,
                  },
                ],
                dateRange: {},
              });

              if (res.statusCode == 200) {
                // handle response
              }
            }

            run();
components:
  schemas:
    EventFilter:
      type: object
      properties:
        field:
          type: string
          description: >-
            The field name that you are filtering by like `metadata.cost`,
            `inputs.chat_history.0.content`
        value:
          type: string
          description: The value that you are filtering the field for
        operator:
          type: string
          enum:
            - is
            - is not
            - contains
            - not contains
            - greater than
          description: >-
            The type of filter you are performing - "is", "is not", "contains",
            "not contains", "greater than"
        type:
          type: string
          enum:
            - string
            - number
            - boolean
            - id
          description: >-
            The data type you are using - "string", "number", "boolean", "id"
            (for object ids)
      example:
        field: event_type
        operator: is
        value: model
        type: string
    Event:
      type: object
      properties:
        project_id:
          type: string
          description: Name of project associated with the event
        source:
          type: string
          description: Source of the event - production, staging, etc
        event_name:
          type: string
          description: Name of the event
        event_type:
          type: string
          enum:
            - session
            - model
            - tool
            - chain
          description: >-
            Specify whether the event is of "session", "model", "tool" or
            "chain" type
        event_id:
          type: string
          description: Unique id of the event, if not set, it will be auto-generated
        session_id:
          type: string
          description: >-
            Unique id of the session associated with the event, if not set, it
            will be auto-generated
        parent_id:
          type: string
          description: Id of the parent event if nested
        children_ids:
          type: array
          items:
            type: string
          description: Id of events that are nested within the event
        config:
          type: object
          additionalProperties: true
          description: >-
            Associated configuration JSON for the event - model name, vector
            index name, etc
        inputs:
          type: object
          additionalProperties: true
          description: Input JSON given to the event - prompt, chunks, etc
          properties:
            chat_history:
              type: array
              items:
                type: object
                additionalProperties: true
              description: Messages passed to the model
        outputs:
          type: object
          additionalProperties: true
          description: Final output JSON of the event
        error:
          type: string
          description: Any error description if event failed
        start_time:
          type: number
          description: UTC timestamp (in milliseconds) for the event start
        end_time:
          type: integer
          description: UTC timestamp (in milliseconds) for the event end
        duration:
          type: number
          description: How long the event took in milliseconds
        metadata:
          type: object
          additionalProperties: true
          description: Any system or application metadata associated with the event
        feedback:
          type: object
          additionalProperties: true
          description: Any user feedback provided for the event output
        metrics:
          type: object
          additionalProperties: true
          description: Any values computed over the output of the event
        user_properties:
          type: object
          additionalProperties: true
          description: Any user properties associated with the event
      example:
        project_id: New Project
        source: playground
        session_id: caf77ace-3417-4da4-944d-f4a0688f3c23
        event_id: 7f22137a-6911-4ed3-bc36-110f1dde6b66
        parent_id: caf77ace-3417-4da4-944d-f4a0688f3c23
        event_type: model
        event_name: Model Completion
        config:
          model: gpt-3.5-turbo
          version: v0.1 - Fork
          provider: openai
          hyperparameters:
            temperature: 0
            top_p: 1
            max_tokens: 1000
            presence_penalty: 0
            frequency_penalty: 0
            stop: []
            'n': 1
          template:
            - role: system
              content: |-
                Answer the user's question only using provided context.

                Context: {{ context }}
            - role: user
              content: '{{question}}'
          type: chat
        children_ids: []
        inputs:
          context: Hello world
          question: What is in the context?
          chat_history:
            - role: system
              content: |-
                Answer the user's question only using provided context.

                Context: Hello world
            - role: user
              content: What is in the context?
        outputs:
          role: assistant
          content: Hello world
        error: null
        start_time: '2024-04-01 22:38:19'
        end_time: '2024-04-01 22:38:19'
        duration: 824.8056
        metadata:
          cost: 0.00008
          completion_tokens: 23
          prompt_tokens: 35
          total_tokens: 58
        feedback: {}
        metrics:
          Answer Faithfulness: 5
          Answer Faithfulness_explanation: >-
            The AI assistant's answer is a concise and accurate description of
            Ramp's API. It provides a clear explanation of what the API does and
            how developers can use it to integrate Ramp's financial services
            into their own applications. The answer is faithful to the provided
            context.
          Number of words: 18
        user_properties:
          user: google-oauth2|111840237613341303366
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````