Swetrix Sessions API

Individual visitor session data

OpenAPI Specification

swetrix-sessions-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Swetrix Admin Annotations Sessions API
  description: The Swetrix Admin API manages analytics projects, funnels, annotations, project views (segments), and organisations. Supports full CRUD operations for all Swetrix account resources. All requests require authentication via the X-Api-Key header. Rate limit is 600 requests/hour.
  version: '1.0'
  contact:
    name: Swetrix Support
    url: https://swetrix.com/contact
  termsOfService: https://swetrix.com/privacy
  license:
    name: AGPL-3.0
    url: https://github.com/Swetrix/swetrix-api/blob/main/LICENSE
servers:
- url: https://api.swetrix.com
  description: Swetrix Production API
security:
- ApiKeyAuth: []
tags:
- name: Sessions
  description: Individual visitor session data
paths:
  /v1/log/sessions:
    get:
      operationId: listSessions
      summary: List Sessions
      description: Returns a paginated list of individual visitor sessions for the specified project and time period. Maximum 150 sessions per request.
      tags:
      - Sessions
      parameters:
      - $ref: '#/components/parameters/pid'
      - $ref: '#/components/parameters/period'
      - $ref: '#/components/parameters/from'
      - $ref: '#/components/parameters/to'
      - $ref: '#/components/parameters/timezone'
      - $ref: '#/components/parameters/filters'
      - $ref: '#/components/parameters/take'
      - $ref: '#/components/parameters/skip'
      responses:
        '200':
          description: Paginated list of sessions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionListResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /v1/log/session:
    get:
      operationId: getSession
      summary: Get Session Details
      description: Returns detailed information for a single visitor session including all pages visited, session metadata, and chart data.
      tags:
      - Sessions
      parameters:
      - $ref: '#/components/parameters/pid'
      - name: psid
        in: query
        required: true
        schema:
          type: string
        description: Session identifier
      - $ref: '#/components/parameters/timezone'
      responses:
        '200':
          description: Session details with pages visited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionDetail'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  parameters:
    filters:
      name: filters
      in: query
      schema:
        type: string
      description: JSON array of filter objects
    pid:
      name: pid
      in: query
      required: true
      schema:
        type: string
      description: Project ID
    take:
      name: take
      in: query
      schema:
        type: integer
        default: 30
        maximum: 150
      description: Number of results to return (max 150)
    to:
      name: to
      in: query
      schema:
        type: string
        format: date
      description: Custom range end date (YYYY-MM-DD)
    period:
      name: period
      in: query
      required: true
      schema:
        type: string
        enum:
        - 1h
        - today
        - yesterday
        - 1d
        - 7d
        - 4w
        - 3M
        - 12M
        - 24M
        - all
      description: Time period for the query
    skip:
      name: skip
      in: query
      schema:
        type: integer
        default: 0
      description: Number of results to skip for pagination
    from:
      name: from
      in: query
      schema:
        type: string
        format: date
      description: Custom range start date (YYYY-MM-DD)
    timezone:
      name: timezone
      in: query
      schema:
        type: string
        default: Etc/GMT
      description: IANA timezone name (default Etc/GMT)
  responses:
    Unauthorized:
      description: Unauthorized - missing or invalid API key
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
  schemas:
    SessionDetail:
      type: object
      properties:
        pages:
          type: array
          items:
            type: object
        sessionDetails:
          type: object
        chart:
          type: object
    SessionSummary:
      type: object
      properties:
        psid:
          type: string
          description: Session identifier
        browser:
          type: string
        os:
          type: string
        country:
          type: string
        device:
          type: string
        duration:
          type: integer
          description: Session duration in seconds
        pageviews:
          type: integer
        created:
          type: string
          format: date-time
    SessionListResponse:
      type: object
      properties:
        sessions:
          type: array
          items:
            $ref: '#/components/schemas/SessionSummary'
        total:
          type: integer
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
      description: API key from Swetrix account settings (https://swetrix.com/user-settings)
externalDocs:
  description: Swetrix Admin API Documentation
  url: https://swetrix.com/docs/admin-api