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

# Visit stats

> Save visit event on Doofinder statistics



## OpenAPI

````yaml /openapi/stats-v2.yaml post /api/v2/stats/visit
openapi: 3.0.0
info:
  contact:
    name: Doofinder Support
    url: https://docs.doofinder.com/
  description: >
    # Introduction


    Doofinder Stats API provides statistical information about your search
    engines.


    # Basics


    ## Endpoint


    All requests should be done via `https` to the right endpoint:


    ```

    https://{search-zone}-api.doofinder.com

    ```


    Where `{search-zone}` is the code of the datacenter where your search
    engines are located.


    For instance:


    ```

    https://eu1-api.doofinder.com

    https://us1-api.doofinder.com

    ```


    ## Authentication


    To authenticate you need a Doofinder API key. If you don't have one you can
    generate it in the Doofinder Admin by going to your Account and then to API
    Keys, [here](https://admin.doofinder.com/admin/account/api).


    A valid API key looks like this:


    ```

    ab46030xza33960aac71a10248489b6c26172f07

    ```


    ### API Token


    You can authenticate with the previous API key. The correct way to
    authenticate is to send a HTTP Header with the name `Authorization` and the
    value `Token {api-key}`.


    I.e.:


    ```

    Authorization: Token ab46030xza33960aac71a10248489b6c26172f07

    ```


    ### JWT Token


    If you prefer you can authenticate with a [JSON Web Token](https://jwt.io).
    The token must be signed with an API management key and there are some
    claims required in the JWT payload. These claims are:

      * `iat` (issued at): Creation datetime timestamp, i.e. the moment when the JWT was created.

      * `exp` (expiration time): Expiration datetime timestamp, i.e. the moment when the JWT is going to expire and will no longer be valid. The time span between issued and expiration dates must be shorter than a week.

      * `name`: Your user code. It is your unique identifier as doofinder user. You can find this code in your profile page in the Doofinder's administration panel.

    To authenticate using JWT you must send a HTTP header with the name
    `Authorization` and the value `Bearer {JWT-token}`.


    I.e.:


    ```

    Authorization: Bearer
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdCIsImlhdCI6MTUxNjIzOTAyMn0.QX_3HF-T2-vlvzGDbAzZyc1Cd-J9qROSes3bxlgB4uk

    ```


    ## Conventions


    Along most of the code samples you will find placeholders for some common
    variable values. They are:

      * `{hashid}`: The search engine's unique id. e.g.: d8fdeab7fce96a19d3fc7b0ca7a1e98b.

      * `{index}`: When storing items, they're always stored under a certain _index_. e.g.: product.

      * `{token}`: Your personal authentication token obtained in the control panel.

    ## Api limits


    ### Requests rate


    The API has a limit of 20 requests per second. If you do more than that, the
    next requests will get a `429 Too Many Requests` error. There is no penalty
    associated to that error, but you must wait one second before attempting
    more requests.


    ### Body size


    The body size for requests with data sending (eg: POST or PUT requests) has
    a limit of 8MB. If you do a request with a request body bigger than 8 MB,
    the response will be `413 Payload Too Large`. This is important mostly for
    batch calls like batch create items.


    # Objects


    ## Search Engines


    A search engine is a collection of indices where data is stored. It has some
    properties like name, language, and some other configuration options that
    are shared among all of its indices.


    Each search engine is uniquely identified by its `hashid` which is an
    auto-generated string.


    Search engines have a _"process"_ operation which takes items from all its
    data sources and insert them into their indices. This operation has a zero
    downtime, you can still search into indices while processing.
  termsOfService: https://www.doofinder.com/en/terms-and-conditions
  title: Doofinder Stats API
  version: '2.0'
  x-logo:
    altText: Doofinder Search Engine
    backgroundColor: '#33268C'
    url: https://admin.doofinder.com/images/logo.svg
servers:
  - url: https://{search_zone}-api.doofinder.com
    variables:
      search_zone:
        default: eu1
        enum:
          - eu1
          - us1
          - ap1
  - url: /
security:
  - api_token: []
  - jwt_token: []
tags:
  - description: Session and usage statistics for your search engines.
    name: Usage & Sessions
  - description: Search activity and top search statistics.
    name: Searches
  - description: Click events and user interaction statistics.
    name: Clicks & Interactions
  - description: Sales, checkout, and conversion statistics.
    name: Conversions & Sales
  - description: Feature-specific statistics including banners, facets, quizzes, and more.
    name: Features
  - description: Visit event registration.
    name: Visits
  - description: Internal usage metrics.
    name: Internal
paths:
  /api/v2/stats/visit:
    post:
      tags:
        - Features
      summary: Visit stats
      description: Save visit event on Doofinder statistics
      operationId: registerVisit
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VisitRegisterRequest'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/responses/RegisterResponse'
          description: OK
        '400':
          $ref: '#/components/responses/StatsBadRequest'
components:
  schemas:
    VisitRegisterRequest:
      properties:
        dfid:
          type: string
        hashid:
          $ref: '#/components/schemas/hashid'
        ip:
          $ref: '#/components/schemas/ip'
        page_type:
          type: string
        session_id:
          $ref: '#/components/schemas/session_id'
        store:
          $ref: '#/components/schemas/store'
        url:
          $ref: '#/components/schemas/url'
        user_agent:
          $ref: '#/components/schemas/user_agent'
        user_id:
          $ref: '#/components/schemas/user_id'
      required:
        - store
      type: object
    hashid:
      description: >-
        Unique id of the search engine. In the search engine selector, you will
        find the hashid information
      pattern: ^[a-f0-9]{32}$
      type: string
    ip:
      deprecated: true
      description: >-
        Unique address that identifies a device. Detected automatically by the
        server.
      type: string
    session_id:
      description: Identifier of search session
      maxLength: 32
      nullable: true
      type: string
    store:
      description: >-
        Identifier of store. In the store setup section, you will find the store
        ID information.
      maxLength: 36
      minLength: 1
      type: string
    url:
      description: Page URI visited by the user
      type: string
    user_agent:
      deprecated: true
      description: Identifier of device. Detected automatically by the server.
      type: string
    user_id:
      description: Identifier of user
      maxLength: 36
      type: string
    RegisterResult:
      description: Response returned over register stat operation.
      example:
        status: registered
      properties:
        status:
          description: Result of the stats request. i.e. 'registered'
          type: string
      title: Stats Response
      type: object
    StatsError:
      description: Standard error wrapper for all Stats API error responses.
      properties:
        error:
          properties:
            code:
              description: Machine-readable error code.
              example: not_authenticated
              type: string
            message:
              description: Human-readable error description.
              example: Authentication required
              type: string
          required:
            - code
          type: object
      required:
        - error
      type: object
  responses:
    RegisterResponse:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RegisterResult'
      description: Response returned over register stat operation.
    StatsBadRequest:
      content:
        application/json:
          example:
            error:
              code: bad_params
              message: Bad parameters error
          schema:
            $ref: '#/components/schemas/StatsError'
      description: Bad Request — invalid or missing query parameters.
  securitySchemes:
    api_token:
      description: |
        Doofinder API key. Pass it as:
        Authorization: Token <api_key>
      in: header
      name: Authorization
      type: apiKey
    jwt_token:
      description: |
        JWT Bearer token. Sign a JWT with your API key (HS256) and pass it as:
        Authorization: Bearer <jwt_token>
      in: header
      name: Authorization
      type: apiKey

````