openapi: 3.0.2
info:
  title: Insights API
  description: API powering the Insights feature of Algolia.
  version: 0.0.1
components:
  securitySchemes:
    appId:
      type: apiKey
      in: header
      name: X-Algolia-Application-Id
    apiKey:
      type: apiKey
      in: header
      name: X-Algolia-API-Key
  parameters:
    PathInPath:
      name: path
      in: path
      description: >-
        The path of the API endpoint to target, anything after the /1 needs to
        be specified.
      required: true
      schema:
        type: string
        example: /keys
    Parameters:
      name: parameters
      in: query
      description: Query parameters to be applied to the current query.
      schema:
        type: object
        additionalProperties: true
  schemas:
    ErrorBase:
      description: Error.
      type: object
      additionalProperties: true
      properties:
        message:
          type: string
          example: Invalid Application-Id or API-Key
    eventType:
      type: string
      description: An eventType can be a click, a conversion, or a view.
      enum:
        - click
        - conversion
        - view
  responses:
    BadRequest:
      description: Bad request or request arguments.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBase'
    FeatureNotEnabled:
      description: This feature is not enabled on your Algolia account.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBase'
    MethodNotAllowed:
      description: Method not allowed with this API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBase'
    IndexNotFound:
      description: Index not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBase'
servers:
  - url: https://insights.{region}.algolia.io
    variables:
      region:
        enum:
          - us
          - de
        default: us
  - url: https://insights.algolia.io
security:
  - appId: []
    apiKey: []
paths:
  /1{path}:
    get:
      operationId: get
      summary: Send requests to the Algolia REST API
      description: This method allow you to send requests to the Algolia REST API.
      parameters:
        - $ref: '#/components/parameters/PathInPath'
        - $ref: '#/components/parameters/Parameters'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '402':
          $ref: '#/components/responses/FeatureNotEnabled'
        '403':
          $ref: '#/components/responses/MethodNotAllowed'
        '404':
          $ref: '#/components/responses/IndexNotFound'
    post:
      operationId: post
      requestBody:
        description: The parameters to send with the custom request.
        content:
          application/json:
            schema:
              type: object
      summary: Send requests to the Algolia REST API
      description: This method allow you to send requests to the Algolia REST API.
      parameters:
        - $ref: '#/components/parameters/PathInPath'
        - $ref: '#/components/parameters/Parameters'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '402':
          $ref: '#/components/responses/FeatureNotEnabled'
        '403':
          $ref: '#/components/responses/MethodNotAllowed'
        '404':
          $ref: '#/components/responses/IndexNotFound'
    put:
      operationId: put
      requestBody:
        description: The parameters to send with the custom request.
        content:
          application/json:
            schema:
              type: object
      summary: Send requests to the Algolia REST API
      description: This method allow you to send requests to the Algolia REST API.
      parameters:
        - $ref: '#/components/parameters/PathInPath'
        - $ref: '#/components/parameters/Parameters'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '402':
          $ref: '#/components/responses/FeatureNotEnabled'
        '403':
          $ref: '#/components/responses/MethodNotAllowed'
        '404':
          $ref: '#/components/responses/IndexNotFound'
    delete:
      operationId: del
      summary: Send requests to the Algolia REST API
      description: This method allow you to send requests to the Algolia REST API.
      parameters:
        - $ref: '#/components/parameters/PathInPath'
        - $ref: '#/components/parameters/Parameters'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '402':
          $ref: '#/components/responses/FeatureNotEnabled'
        '403':
          $ref: '#/components/responses/MethodNotAllowed'
        '404':
          $ref: '#/components/responses/IndexNotFound'
  /1/events:
    post:
      operationId: pushEvents
      description: This command pushes an array of events.
      summary: Pushes an array of events
      requestBody:
        required: true
        content:
          application/json:
            schema:
              title: InsightEvents
              type: object
              description: Object containing the events sent.
              additionalProperties: false
              required:
                - events
              properties:
                events:
                  type: array
                  description: Array of events sent.
                  items:
                    title: InsightEvent
                    type: object
                    description: Insights event.
                    additionalProperties: false
                    properties:
                      eventType:
                        $ref: '#/components/schemas/eventType'
                      eventName:
                        type: string
                        description: A user-defined string used to categorize events.
                      index:
                        type: string
                        description: Name of the targeted index.
                      userToken:
                        type: string
                        description: >-
                          A user identifier. Depending if the user is logged-in
                          or not, several strategies can be used from a
                          sessionId to a technical identifier.
                      timestamp:
                        type: integer
                        format: int64
                        description: >-
                          Time of the event expressed in milliseconds since the
                          Unix epoch.
                      queryID:
                        type: string
                        description: >-
                          Algolia queryID. This is required when an event is
                          tied to a search.
                      objectIDs:
                        type: array
                        description: >-
                          An array of index objectID. Limited to 20 objects. An
                          event can’t have both objectIDs and filters at the
                          same time.
                        items:
                          type: string
                      filters:
                        type: array
                        description: >-
                          An array of filters. Limited to 10 filters. An event
                          can’t have both objectIDs and filters at the same
                          time.
                        items:
                          type: string
                      positions:
                        type: array
                        description: >-
                          Position of the click in the list of Algolia search
                          results. This field is required if a queryID is
                          provided. One position must be provided for each
                          objectID.
                        items:
                          type: integer
                    required:
                      - eventType
                      - eventName
                      - index
                      - userToken
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                title: pushEventsResponse
                type: object
                additionalProperties: false
                required:
                  - message
                properties:
                  message:
                    type: string
                    description: A message confirming the event push.
        '400':
          $ref: '#/components/responses/BadRequest'
        '402':
          $ref: '#/components/responses/FeatureNotEnabled'
        '403':
          $ref: '#/components/responses/MethodNotAllowed'
        '404':
          $ref: '#/components/responses/IndexNotFound'
