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

# Search Events By Tags

Search events by tags.


## OpenAPI

````yaml get /api/v1/users/event_tags/search/{user_id}
openapi: 3.1.0
info:
  title: Memobase API
  summary: APIs for Memobase, a user memory system for LLM Apps
  version: 0.0.40
servers:
  - url: https://api.memobase.dev
  - url: https://api.memobase.cn
security:
  - BearerAuth: []
paths:
  /api/v1/users/event_tags/search/{user_id}:
    get:
      tags:
        - event
      summary: Search User Events By Tags
      operationId: search_user_events_by_tags_api_v1_users_event_tags_search__user_id__get
      parameters:
        - name: user_id
          in: path
          required: true
          schema:
            anyOf:
              - type: string
                format: uuid4
              - type: string
                format: uuid5
            description: The ID of the user
            title: User Id
          description: The ID of the user
        - name: tags
          in: query
          required: false
          schema:
            type: string
            description: >-
              Comma-separated list of tag names that events must have
              (e.g.'emotion,romance')
            title: Tags
          description: >-
            Comma-separated list of tag names that events must have
            (e.g.'emotion,romance')
        - name: tag_values
          in: query
          required: false
          schema:
            type: string
            description: >-
              Comma-separated tag=value pairs for exact matches (e.g.,
              'emotion=happy,topic=work')
            title: Tag Values
          description: >-
            Comma-separated tag=value pairs for exact matches (e.g.,
            'emotion=happy,topic=work')
        - name: topk
          in: query
          required: false
          schema:
            type: integer
            description: Number of events to retrieve, default is 10
            default: 10
            title: Topk
          description: Number of events to retrieve, default is 10
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserEventsDataResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-code-samples:
        - lang: python
          source: >+
            # To use the Python SDK, install the package:

            # pip install memobase


            from memobase import MemoBaseClient


            client = MemoBaseClient(project_url='PROJECT_URL',
            api_key='PROJECT_TOKEN')

            u = client.get_user(uid)


            # Search for events with specific tags

            events = u.search_event_by_tags(tags=["emotion", "romance"])


            # Search for events with specific tag values

            events = u.search_event_by_tags(tag_values={"emotion": "happy",
            "topic": "work"})


            # Combine both filters

            events = u.search_event_by_tags(tags=["emotion"],
            tag_values={"topic": "work"})

          label: Python
components:
  schemas:
    UserEventsDataResponse:
      properties:
        data:
          anyOf:
            - $ref: '#/components/schemas/UserEventsData'
            - type: 'null'
          description: Response containing user events
        errno:
          $ref: '#/components/schemas/CODE'
          description: Error code, 0 means success
          default: 0
        errmsg:
          type: string
          title: Errmsg
          description: Error message, empty when success
          default: ''
      type: object
      title: UserEventsDataResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    UserEventsData:
      properties:
        events:
          items:
            $ref: '#/components/schemas/UserEventData'
          type: array
          title: Events
          description: List of user events
        gists:
          items:
            $ref: '#/components/schemas/UserEventGistData'
          type: array
          title: Gists
          description: List of user event gists
      type: object
      required:
        - events
      title: UserEventsData
    CODE:
      type: integer
      enum:
        - 0
        - 400
        - 401
        - 403
        - 404
        - 405
        - 409
        - 422
        - 500
        - 501
        - 502
        - 503
        - 504
        - 520
      title: CODE
    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
    UserEventData:
      properties:
        id:
          anyOf:
            - type: string
              format: uuid4
            - type: string
              format: uuid5
          title: Id
          description: The event's unique identifier
        event_data:
          $ref: '#/components/schemas/EventData'
          description: User event data in JSON
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Timestamp when the event was created
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: Timestamp when the event was last updated
        similarity:
          anyOf:
            - type: number
            - type: 'null'
          title: Similarity
          description: Similarity score
      type: object
      required:
        - id
      title: UserEventData
    UserEventGistData:
      properties:
        id:
          anyOf:
            - type: string
              format: uuid4
            - type: string
              format: uuid5
          title: Id
          description: The event gist's unique identifier
        gist_data:
          $ref: '#/components/schemas/EventGistData'
          description: User event gist data
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Timestamp when the event gist was created
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: Timestamp when the event gist was last updated
        similarity:
          anyOf:
            - type: number
            - type: 'null'
          title: Similarity
          description: Similarity score
      type: object
      required:
        - id
      title: UserEventGistData
    EventData:
      properties:
        profile_delta:
          anyOf:
            - items:
                $ref: '#/components/schemas/ProfileDelta'
              type: array
            - type: 'null'
          title: Profile Delta
          description: List of profile data
        event_tip:
          anyOf:
            - type: string
            - type: 'null'
          title: Event Tip
          description: Event tip
        event_tags:
          anyOf:
            - items:
                $ref: '#/components/schemas/EventTag'
              type: array
            - type: 'null'
          title: Event Tags
          description: List of event tags
      type: object
      title: EventData
    EventGistData:
      properties:
        content:
          type: string
          title: Content
          description: The event gist content
      type: object
      required:
        - content
      title: EventGistData
    ProfileDelta:
      properties:
        content:
          type: string
          title: Content
          description: The profile content
        attributes:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Attributes
          description: User profile attributes in JSON, containing 'topic', 'sub_topic'
      type: object
      required:
        - content
        - attributes
      title: ProfileDelta
    EventTag:
      properties:
        tag:
          type: string
          title: Tag
          description: The event tag
        value:
          type: string
          title: Value
          description: The event tag value
      type: object
      required:
        - tag
        - value
      title: EventTag
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````