PostHog Web Analytics API
The web_analytics API from PostHog — 1 operation(s) for web_analytics.
The web_analytics API from PostHog — 1 operation(s) for web_analytics.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/posthog-web-analytics-api"
curl "https://apis.io/api/v1/apis?limit=25"
Discovery needs no key. Ratings and market analysis are Pro.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: PostHog Web Analytics API
version: 1.0.0
description: ''
tags:
- name: Web Analytics
paths:
/api/environments/{project_id}/web_analytics/weekly_digest/:
get:
operationId: web_analytics_weekly_digest
description: 'Summarizes a project''s web analytics over a lookback window (default 7 days): unique visitors, pageviews, sessions, bounce rate, and average session duration with period-over-period comparisons, plus the top 5 pages, top 5 traffic sources, and goal conversions.'
summary: Summarize web analytics
parameters:
- in: query
name: compare
schema:
type: boolean
default: true
description: When true (default), include period-over-period change for each metric comparing against the prior equal-length period. Set to false to skip the comparison query (faster).
- in: query
name: days
schema:
type: integer
default: 7
description: Lookback window in days (1–90). Defaults to 7.
- $ref: '#/components/parameters/ProjectIdPath'
tags:
- Web Analytics
security:
- PersonalAPIKeyAuth:
- web_analytics:read
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/WeeklyDigestResponse'
description: ''
x-explicit-tags:
- web_analytics
components:
schemas:
TopPage:
type: object
properties:
host:
type: string
description: Host for the page, if recorded.
path:
type: string
description: URL path.
visitors:
type: integer
description: Unique visitors in the period.
change:
allOf:
- $ref: '#/components/schemas/WoWChange'
description: Period-over-period change in visitors, null when not meaningful.
required:
- change
- host
- path
- visitors
WoWChange:
type: object
properties:
percent:
type: integer
description: Absolute percentage change, rounded to nearest integer.
direction:
allOf:
- $ref: '#/components/schemas/DirectionEnum'
description: 'Direction of the change relative to the prior period.
* `Up` - Up
* `Down` - Down'
color:
type: string
description: Hex color indicating whether the change is a positive or negative signal.
text:
type: string
description: Short label, e.g. 'Up 12%'.
long_text:
type: string
description: Verbose label, e.g. 'Up 12% from prior period'.
required:
- color
- direction
- long_text
- percent
- text
DurationMetric:
type: object
properties:
current:
type: string
description: Human-readable duration, e.g. '2m 34s'.
previous:
type:
- string
- 'null'
description: Prior-period duration, e.g. '2m 10s'.
change:
allOf:
- $ref: '#/components/schemas/WoWChange'
description: Period-over-period change, null when not meaningful.
required:
- change
- current
- previous
Goal:
type: object
properties:
name:
type: string
description: Goal name (action name).
conversions:
type: integer
description: Total conversions in the period.
change:
allOf:
- $ref: '#/components/schemas/WoWChange'
description: Period-over-period change in conversions, null when not meaningful.
required:
- change
- conversions
- name
NumericMetric:
type: object
properties:
current:
type: number
format: double
description: Value for the most recent period.
previous:
type:
- number
- 'null'
format: double
description: Value for the prior period, if available.
change:
allOf:
- $ref: '#/components/schemas/WoWChange'
description: Period-over-period change, null when not meaningful.
required:
- change
- current
- previous
TopSource:
type: object
properties:
name:
type: string
description: Initial referring domain.
visitors:
type: integer
description: Unique visitors from this source.
change:
allOf:
- $ref: '#/components/schemas/WoWChange'
description: Period-over-period change in visitors, null when not meaningful.
required:
- change
- name
- visitors
WeeklyDigestResponse:
type: object
properties:
visitors:
allOf:
- $ref: '#/components/schemas/NumericMetric'
description: Unique visitors.
pageviews:
allOf:
- $ref: '#/components/schemas/NumericMetric'
description: Total pageviews.
sessions:
allOf:
- $ref: '#/components/schemas/NumericMetric'
description: Total sessions.
bounce_rate:
allOf:
- $ref: '#/components/schemas/NumericMetric'
description: Bounce rate (0–100).
avg_session_duration:
allOf:
- $ref: '#/components/schemas/DurationMetric'
description: Average session duration.
top_pages:
type: array
items:
$ref: '#/components/schemas/TopPage'
description: Top 5 pages by unique visitors.
top_sources:
type: array
items:
$ref: '#/components/schemas/TopSource'
description: Top 5 traffic sources by unique visitors.
goals:
type: array
items:
$ref: '#/components/schemas/Goal'
description: Goal conversions.
dashboard_url:
type: string
format: uri
description: Link to the Web analytics dashboard for this project.
required:
- avg_session_duration
- bounce_rate
- dashboard_url
- goals
- pageviews
- sessions
- top_pages
- top_sources
- visitors
DirectionEnum:
enum:
- Up
- Down
type: string
description: '* `Up` - Up
* `Down` - Down'
parameters:
ProjectIdPath:
in: path
name: project_id
required: true
schema:
type: string
description: Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.
securitySchemes:
PersonalAPIKeyAuth:
type: http
scheme: bearer
x-tagGroups:
- name: All endpoints
tags:
- LLM Analytics
- actions
- activity_log
- activity_logs
- advanced_activity_logs
- alerts
- annotations
- approval_policies
- batch_exports
- cdp
- change_requests
- code
- code-invites
- cohorts
- comments
- conversations
- core
- customer_analytics
- customer_journeys
- customer_profile_configs
- dashboard_templates
- dashboards
- data_color_themes
- data_modeling_jobs
- data_warehouse
- dataset_items
- datasets
- desktop_recordings
- domains
- early_access_feature
- early_access_features
- elements
- endpoints
- environments
- error_tracking
- evaluation_runs
- evaluations
- event_definitions
- event_filter
- event_schemas
- events
- experiment_holdouts
- experiment_saved_metrics
- experiments
- exports
- external_data_schemas
- external_data_sources
- feature_flags
- file_system
- file_system_shortcut
- flag_value
- groups
- groups_types
- health_issues
- heatmap_screenshots
- heatmaps
- hog_flows
- hog_function_templates
- hog_functions
- insight_variables
- insights
- integrations
- invites
- js-snippet
- legal_documents
- lineage
- live_debugger_breakpoints
- llm_analytics
- llm_prompts
- llm_skills
- logs
- managed_viewsets
- max
- max_tools
- mcp_server_installations
- mcp_servers
- mcp_store
- mcp_tools
- members
- notebooks
- oauth_applications
- object_media_previews
- organizations
- persisted_folder
- persons
- platform_features
- plugin_configs
- product_analytics
- product_tours
- project_secret_api_keys
- projects
- property_definitions
- proxy_records
- public_hog_function_templates
- query
- replay
- reverse_proxy
- role_external_references
- roles
- sandbox-environments
- sandbox_environments
- saved
- schema_property_groups
- sdk_doctor
- session_group_summaries
- session_recording_playlists
- session_recordings
- session_summaries
- sessions
- signals
- subscriptions
- surveys
- taggers
- task-automations
- task-runs
- task_automations
- tasks
- uploaded_media
- user_home_settings
- user_interviews
- users
- visual_review
- warehouse_dag
- warehouse_model_paths
- warehouse_saved_queries
- warehouse_saved_query_folders
- warehouse_tables
- warehouse_view_link
- warehouse_view_links
- web_analytics
- web_experiments
- web_vitals
- welcome
- workflows