Skip to content

Amplitude

Amplitude raw events, charts, funnels, retention, users, cohorts and tracking plan as SQL

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/amplitude/index.md to help me query Amplitude with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Count product events for a day

Set the timestamp range to the day you want to analyze.

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT event_type, count(*) AS n
FROM amplitude.main.events()
WHERE event_time >= TIMESTAMPTZ '2026-11-14 00:00:00+00' AND event_time < TIMESTAMPTZ '2026-11-15 00:00:00+00'
GROUP BY event_type
ORDER BY n DESC

Quick start

Choose where to run Amplitude, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'amplitude' AS amplitude (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-amplitude'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

amplitude credentials

An Amplitude project's API key and secret key (HTTP Basic auth), plus its data region

Get these credentials →
secret.sql
CREATE SECRET amplitude (
    TYPE amplitude,
    api_key    '<AMPLITUDE_API_KEY>',  -- secret
    secret_key '<SECRET_KEY>',  -- secret
    region     '<region>',
    base_url   '<base_url>'
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT event_type, count(*) AS n
FROM amplitude.main.events()
WHERE event_time >= TIMESTAMPTZ '2026-11-14 00:00:00+00' AND event_time < TIMESTAMPTZ '2026-11-15 00:00:00+00'
GROUP BY event_type
ORDER BY n DESC
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'amplitude' AS amplitude (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Amplitude product analytics as SQL: raw events from the Export API, segmentation, funnel, retention and revenue charts, user lookups, cohorts and the tracking plan, read-only.

Catalog

Everything amplitude exposes once attached — read straight from the worker's released build.

amplitude 2 schemas
main 9 tables · 14 functions

Amplitude-native events, charts, users, cohorts and tracking plan, read-only.

Schema examples (12)
Examples (12)

Event counts for one day (only that day's upload hours are exported)

SELECT event_type, count(*) AS n
FROM amplitude.main.events()
WHERE event_time >= TIMESTAMPTZ '2026-11-14 00:00:00+00' AND event_time < TIMESTAMPTZ '2026-11-15 00:00:00+00'
GROUP BY event_type
ORDER BY n DESC;

Top spenders among events uploaded since a time

SELECT user_id, sum(revenue) AS revenue
FROM amplitude.main.events(late_hours := 0)
WHERE server_upload_time >= TIMESTAMPTZ '2026-11-14 00:00:00+00' AND revenue > 0
GROUP BY user_id
ORDER BY revenue DESC
LIMIT 10;

Daily unique purchasers for a week

SELECT period, value AS daily_purchasers
FROM amplitude.main.segmentation('Purchase', DATE '2026-11-01', DATE '2026-11-07')
ORDER BY period;

Purchases per country (grouped in Amplitude)

SELECT series_label AS country, sum(value) AS purchases
FROM amplitude.main.segmentation('Purchase', DATE '2026-11-01', DATE '2026-11-07', metric := 'totals', group_by := ['country'])
GROUP BY ALL
ORDER BY purchases DESC;
8 more examples

Sign-up to purchase conversion

SELECT step, event_type, users, round(conversion_rate, 3) AS conversion
FROM amplitude.main.funnel(['Sign Up', 'Purchase'], DATE '2026-11-01', DATE '2026-11-07')
ORDER BY step;

Combined N-day retention of new users

SELECT day, round(retention_rate, 3) AS retention
FROM amplitude.main.retention('_new', '_all', DATE '2026-11-01', DATE '2026-11-07')
WHERE cohort IS NULL
ORDER BY day;

Daily active users for a week

SELECT period, users AS dau
FROM amplitude.main.active_users(DATE '2026-11-01', DATE '2026-11-07')
ORDER BY period;

Average session minutes per day

SELECT period, round(avg_seconds / 60, 1) AS minutes
FROM amplitude.main.average_session_length(DATE '2026-11-01', DATE '2026-11-07')
ORDER BY period;

Mean sessions per user over a week

SELECT avg(sessions_per_user) AS mean
FROM amplitude.main.sessions_per_user(DATE '2026-11-01', DATE '2026-11-07');

Session length histogram

SELECT bin, sessions
FROM amplitude.main.session_length_distribution(DATE '2026-11-01', DATE '2026-11-07')
ORDER BY bin_index;

Users per platform

SELECT value AS platform, users
FROM amplitude.main.user_composition(DATE '2026-11-01', DATE '2026-11-07', 'platform')
ORDER BY users DESC;

30-day ARPU per acquisition day

SELECT cohort_date, value AS arpu_30d
FROM amplitude.main.revenue_ltv(DATE '2026-10-01', DATE '2026-10-07')
WHERE day = 30
ORDER BY cohort_date;
Tables
annotations 1 example7 cols

Chart annotations (releases, incidents, campaigns) with their time range and category

Columns
idnot null VARCHAR
Amplitude's identifier of the annotation (opaque text).
label VARCHAR
Short text shown on the chart, e.g. 'v3.2'.
details VARCHAR
Longer free-text explanation of the annotation.
start_time TIMESTAMP WITH TIME ZONE
When the annotation starts.
end_time TIMESTAMP WITH TIME ZONE
When a ranged annotation ends (NULL for a point).
category_name VARCHAR
Annotation category, e.g. 'Releases' or 'Incidents'.
chart_id VARCHAR
Chart the annotation is limited to (NULL = all charts).
ConstraintsPRIMARY KEY (id)
Example

Annotations this month (the date bound is sent to Amplitude)

SELECT start_time, label, category_name
FROM amplitude.main.annotations
WHERE start_time >= TIMESTAMPTZ '2026-11-01'
ORDER BY start_time;
Link
cohorts 1 example26 cols

Behavioral cohorts: name, size, definition, owners, sync targets (Behavioral Cohorts API)

Columns
idnot null VARCHAR
Amplitude's cohort identifier (pass it to cohort_members).
name VARCHAR
Cohort name.
description VARCHAR
Free-text description written by the cohort's owner.
size BIGINT
Count of users in the cohort at its last computation.
type VARCHAR
Cohort type.
archived BOOLEAN
True once the cohort has been archived (no longer recomputed).
published BOOLEAN
True when the cohort is shared with the whole organization.
finished BOOLEAN
Computation finished.
hidden BOOLEAN
True when the cohort is hidden from cohort lists.
is_predictive BOOLEAN
A predictive cohort.
is_official_content BOOLEAN
Marked official.
owners VARCHAR[]
Owner logins.
viewers VARCHAR[]
Viewer logins.
created_at TIMESTAMP WITH TIME ZONE
Created.
last_modified TIMESTAMP WITH TIME ZONE
When the cohort definition was last changed.
last_computed TIMESTAMP WITH TIME ZONE
When Amplitude last recomputed the membership.
last_viewed TIMESTAMP WITH TIME ZONE
When someone last opened the cohort.
view_count BIGINT
Number of times the cohort has been viewed.
popularity BIGINT
Amplitude's popularity score (a unitless ranking value).
source_chart_id VARCHAR
Chart the cohort was created from, if any.
edit_id VARCHAR
Identifier of the cohort's current revision.
location_id VARCHAR
Space / location id.
app_id VARCHAR
Identifier of the Amplitude project the cohort belongs to.
metadata VARCHAR[]
Metadata tags.
definition JSON
Cohort definition (JSON).
sync_metadata JSON
Sync targets (JSON array).
ConstraintsPRIMARY KEY (id)
Example

The largest active cohorts

SELECT name, size
FROM amplitude.main.cohorts
WHERE NOT archived
ORDER BY size DESC
LIMIT 10;
Link
event_categories 1 example2 cols

Event categories defined in the Amplitude tracking plan (Taxonomy API)

Columns
idnot null VARCHAR
Amplitude's identifier of the category (opaque text).
name VARCHAR
Category name as shown in the tracking plan, e.g. 'Conversion'.
ConstraintsPRIMARY KEY (id)
Example

Every event category

SELECT id, name FROM amplitude.main.event_categories ORDER BY name;
Link
event_properties 2 examples11 cols

Event properties in the Amplitude tracking plan, per event type plus shared properties (Taxonomy API)

Columns
event_type VARCHAR
Event type the property belongs to (NULL for shared properties).
is_sharednot null BOOLEAN
True for a shared property listed without an event type.
event_propertynot null VARCHAR
Property name.
description VARCHAR
Free-text description of the property from the tracking plan.
type VARCHAR
Data type: string, number, boolean, enum, any …
regex VARCHAR
Validation regular expression.
enum_values VARCHAR[]
Allowed values.
is_array_type BOOLEAN
Whether the property is an array.
is_required BOOLEAN
Whether the property is required.
is_hidden BOOLEAN
Whether the property is hidden.
classifications VARCHAR[]
Data classifications, e.g. PII.
Examples (2)

Properties of one event (only that event type is requested)

SELECT event_property, type
FROM amplitude.main.event_properties
WHERE event_type = 'Purchase'
ORDER BY event_property;

Event properties classified as PII

SELECT event_type, event_property
FROM amplitude.main.event_properties
WHERE list_contains(classifications, 'PII')
ORDER BY ALL;
Link
event_totals 1 example7 cols

Visible event types with their total count this week (Dashboard REST API event list)

Columns
event_typenot null VARCHAR
Event type (name).
display_name VARCHAR
Name shown in Amplitude charts (may differ from the raw event type).
totals_this_week BIGINT
Count of events of this type received so far this week.
is_hidden BOOLEAN
Hidden in charts.
is_deleted BOOLEAN
Deleted.
is_non_active BOOLEAN
Marked inactive.
is_flow_hidden BOOLEAN
Hidden from Pathfinder / flows.
ConstraintsPRIMARY KEY (event_type)
Example

The ten most frequent events this week

SELECT event_type, totals_this_week
FROM amplitude.main.event_totals
ORDER BY totals_this_week DESC
LIMIT 10;
Link
event_types 2 examples12 cols

Event types in the Amplitude tracking plan with category, description, visibility and owner (Taxonomy API)

Columns
event_typenot null VARCHAR
Event type (name) as sent by the SDKs.
display_name VARCHAR
Display name shown in Amplitude charts.
description VARCHAR
Free-text description of the event from the tracking plan (NULL if undocumented).
category VARCHAR
Category name.
is_active BOOLEAN
Whether the event is active (has recent data).
is_deleted BOOLEAN
Whether the event type was deleted from the plan.
is_hidden_from_dropdowns BOOLEAN
Hidden from chart dropdowns.
is_hidden_from_persona_results BOOLEAN
Hidden from Personas results.
is_hidden_from_pathfinder BOOLEAN
Hidden from Pathfinder.
is_hidden_from_timeline BOOLEAN
Hidden from the user timeline.
tags VARCHAR[]
Free-form labels attached to the event in the tracking plan.
owner VARCHAR
Login (email) of the person responsible for the event.
ConstraintsPRIMARY KEY (event_type)
Examples (2)

Event types per category

SELECT category, count(*) AS events
FROM amplitude.main.event_types
WHERE NOT is_deleted
GROUP BY category
ORDER BY events DESC;

Undocumented event types

SELECT event_type
FROM amplitude.main.event_types
WHERE description IS NULL AND NOT is_deleted
ORDER BY event_type;
Link
group_properties 1 example9 cols

Shared group properties in the Amplitude tracking plan (Taxonomy API, Accounts add-on)

Columns
group_typenot null VARCHAR
Group type the property belongs to, e.g. 'org'.
group_propertynot null VARCHAR
Property name (grp: prefix).
description VARCHAR
Free-text description of the group property.
type VARCHAR
Data type.
regex VARCHAR
Validation regular expression.
enum_values VARCHAR[]
Allowed values.
is_array_type BOOLEAN
Whether the property is an array.
is_hidden BOOLEAN
Whether the property is hidden.
classifications VARCHAR[]
Data classifications.
ConstraintsPRIMARY KEY (group_type, group_property)
Example

Group properties by group type

SELECT group_type, group_property
FROM amplitude.main.group_properties
ORDER BY ALL;
Link
realtime_active_users 1 example3 cols

Real-time active users in 5-minute buckets for today and yesterday

Columns
series_labelnot null VARCHAR
'Today' or 'Yesterday'.
time_of_daynot null VARCHAR
Bucket start (HH:MM).
users BIGINT
Active users in the bucket.
ConstraintsPRIMARY KEY (series_label, time_of_day)
Example

Active users in the latest bucket today

SELECT time_of_day, users
FROM amplitude.main.realtime_active_users
WHERE series_label = 'Today'
ORDER BY time_of_day DESC
LIMIT 1;
Link
user_properties 1 example9 cols

User properties in the Amplitude tracking plan (Taxonomy API)

Columns
user_propertynot null VARCHAR
Property name.
description VARCHAR
Free-text description of the user property.
type VARCHAR
Data type.
regex VARCHAR
Validation regular expression.
enum_values VARCHAR[]
Allowed values.
is_array_type BOOLEAN
Whether the property is an array.
is_hidden BOOLEAN
Whether the property is hidden.
is_deleted BOOLEAN
Whether the property was deleted.
classifications VARCHAR[]
Data classifications, e.g. PII.
ConstraintsPRIMARY KEY (user_property)
Example

Live user properties

SELECT user_property, type
FROM amplitude.main.user_properties
WHERE NOT is_deleted
ORDER BY user_property;
Link
Table functions
active_users (start_date DATE, end_date DATE, granularity := VARCHAR, group_by := VARCHAR, metric := VARCHAR, segments := VARCHAR) 1 example

Active or new user counts per day, week or month, optionally grouped or segmented

Positional arguments
start_date DATE
First day of the range, in the project time zone.
end_date DATE
Last day of the range, inclusive.
Named arguments
granularity := VARCHAR
Period (named): day (default), week, month. · default "day"
group_by := VARCHAR
One property to group by (named). · default null
metric := VARCHAR
active (default) or new (named). · default "active"
segments := VARCHAR
Segment definitions in Amplitude's `s` JSON format (named); NULL means all users. · default null
Returns columns
series_index INTEGER
Series (segment / group) index, 0-based.
series_label VARCHAR
Group-by value or segment label (NULL when ungrouped).
period VARCHAR
The x value: a date (YYYY-MM-DD, project time zone), an hour, or a time of day.
users BIGINT
Users in the period.
Example

Daily active users for a week

SELECT period, users AS dau
FROM amplitude.main.active_users(DATE '2026-11-01', DATE '2026-11-07')
ORDER BY period;
Link
average_session_length (start_date DATE, end_date DATE) 1 example

Average session length in seconds per day

Arguments
start_date DATE
First day of the range, in the project time zone.
end_date DATE
Last day of the range, inclusive.
Returns columns
period VARCHAR
Day (YYYY-MM-DD, project time zone).
avg_seconds DOUBLE
Average session length in seconds.
Example

Average session minutes per day

SELECT period, round(avg_seconds / 60, 1) AS minutes
FROM amplitude.main.average_session_length(DATE '2026-11-01', DATE '2026-11-07')
ORDER BY period;
Link
cohort_members (cohort_id VARCHAR, include_properties := BOOLEAN, max_wait_seconds := INTEGER, poll_seconds := INTEGER, property_keys := VARCHAR[]) 2 examples

Download a behavioral cohort's members (async export job; optional user properties)

Positional arguments
cohort_id VARCHAR
Cohort id from amplitude.main.cohorts (positional).
Named arguments
include_properties := BOOLEAN
Include user properties in `properties` (named; default false; slower). · default false
max_wait_seconds := INTEGER
How long to wait for Amplitude to prepare the export (named; default 600). · default 600
poll_seconds := INTEGER
Seconds between status polls (named; default 5). · default 5
property_keys := VARCHAR[]
User property names to include (named); setting it implies include_properties. · default null
Returns columns
cohort_id VARCHAR
The cohort read.
amplitude_id BIGINT
Member's Amplitude id.
user_id VARCHAR
Member's user id (NULL for anonymous users).
properties JSON
Requested user properties (JSON object; empty unless include_properties).
Examples (2)

How many users a cohort has right now

SELECT count(*) AS members FROM amplitude.main.cohort_members('abc123');

Cohort members by plan

SELECT properties->>'plan' AS plan, count(*) AS users
FROM amplitude.main.cohort_members('abc123', property_keys := ['plan'])
GROUP BY plan
ORDER BY users DESC;
Link
events (chunk_hours := INTEGER, late_hours := INTEGER, lookback_hours := INTEGER) 2 examples

Raw Amplitude events from the Export API, streamed hour by hour with time-range pushdown

Named arguments
chunk_hours := INTEGER
Upload hours per Export API request (named, default 24, max 8760). A chunk that exceeds Amplitude's size limit is halved automatically. · default 24
late_hours := INTEGER
How long after an event's time its upload may arrive: an event_time upper bound reads uploads up to this many hours later (named, default 24; 0 = only events uploaded within the same hour). · default 24
lookback_hours := INTEGER
Hours to read back from now when the query has no lower bound on event_time or server_upload_time (named, default 24). · default 24
Returns columns
uuid VARCHAR
Event uuid.
event_type VARCHAR
Event type.
event_time TIMESTAMP WITH TIME ZONE
When the event happened (UTC, clock-corrected).
server_upload_time TIMESTAMP WITH TIME ZONE
Upload time; the Export API's hour range filters on it.
server_received_time TIMESTAMP WITH TIME ZONE
Server receive time.
client_event_time TIMESTAMP WITH TIME ZONE
Event time by the client clock.
client_upload_time TIMESTAMP WITH TIME ZONE
Upload time by the client clock.
processed_time TIMESTAMP WITH TIME ZONE
Processing time.
user_creation_time TIMESTAMP WITH TIME ZONE
When the user was first seen.
user_id VARCHAR
User id (NULL if anonymous).
device_id VARCHAR
Device id.
amplitude_id BIGINT
Amplitude's user id.
event_id BIGINT
Per-device event counter.
session_id BIGINT
Session start, epoch ms (NULL: none).
insert_id VARCHAR
Dedup id ($insert_id).
app BIGINT
Project id.
platform VARCHAR
Platform (iOS, Web …).
os_name VARCHAR
OS name.
os_version VARCHAR
OS version.
device_brand VARCHAR
Device brand.
device_manufacturer VARCHAR
Device manufacturer.
device_model VARCHAR
Device model.
device_family VARCHAR
Device family.
device_type VARCHAR
Device type.
device_carrier VARCHAR
Carrier.
country VARCHAR
Country (IP geo).
region VARCHAR
Region.
city VARCHAR
City.
dma VARCHAR
DMA.
language VARCHAR
Language.
ip_address VARCHAR
Client IP.
location_lat DOUBLE
Latitude.
location_lng DOUBLE
Longitude.
version_name VARCHAR
App version.
start_version VARCHAR
First app version.
library VARCHAR
Sending SDK.
paying BOOLEAN
User has paid.
revenue DOUBLE
Revenue: $revenue, else $price × $quantity.
event_properties JSON
Event properties.
user_properties JSON
User properties then.
group_properties JSON
Group properties.
groups JSON
Groups (type → names).
data JSON
Internal data.
amplitude_event_type VARCHAR
System event type.
amplitude_attribution_ids VARCHAR
Attribution ids.
adid VARCHAR
Google ad id.
idfa VARCHAR
Apple IDFA.
sample_rate DOUBLE
Sample rate.
Examples (2)

Event counts for one day (only that day's upload hours are exported)

SELECT event_type, count(*) AS n
FROM amplitude.main.events()
WHERE event_time >= TIMESTAMPTZ '2026-11-14 00:00:00+00' AND event_time < TIMESTAMPTZ '2026-11-15 00:00:00+00'
GROUP BY event_type
ORDER BY n DESC;

Top spenders among events uploaded since a time

SELECT user_id, sum(revenue) AS revenue
FROM amplitude.main.events(late_hours := 0)
WHERE server_upload_time >= TIMESTAMPTZ '2026-11-14 00:00:00+00' AND revenue > 0
GROUP BY user_id
ORDER BY revenue DESC
LIMIT 10;
Link
funnel (events VARCHAR[], start_date DATE, end_date DATE, conversion_seconds := BIGINT, granularity := VARCHAR, group_by := VARCHAR, group_limit := INTEGER, mode := VARCHAR, segments := VARCHAR, user_type := VARCHAR) 1 example

Funnel analysis: users reaching each step, conversion and time-to-convert, per group

Positional arguments
events VARCHAR[]
Funnel steps in order (positional): a list of event names or event JSON objects.
start_date DATE
First day of the range, in the project time zone.
end_date DATE
Last day of the range, inclusive.
Named arguments
conversion_seconds := BIGINT
Conversion window in seconds (named; default 2,592,000 = 30 days). · default null
granularity := VARCHAR
Interval (named): 'day' (default), 'week', 'month'; segmentation and funnel also take 'hour' (≤ 7 days) and 'realtime' (5-minute, ≤ 2 days). · default "day"
group_by := VARCHAR
One property to group by (named), e.g. 'country' or 'gp:plan'. · default null
group_limit := INTEGER
Group-by values returned (named; max 1000). · default null
mode := VARCHAR
Step order (named): ordered (default), unordered, sequential. · default "ordered"
segments := VARCHAR
Segment definitions in Amplitude's `s` JSON format (named); NULL means all users. · default null
user_type := VARCHAR
Users counted (named): active (default) or new. · default "active"
Returns columns
group_index INTEGER
Group index, 0-based (one group when ungrouped).
group_label VARCHAR
Group-by value (NULL when ungrouped).
step INTEGER
Step number, 1-based.
event_type VARCHAR
The step's event.
users BIGINT
Users who reached this step.
conversion_rate DOUBLE
Fraction of step-1 users who reached this step.
step_conversion_rate DOUBLE
Fraction of the previous step's users who reached this step.
median_seconds DOUBLE
Median time from the previous step, in seconds.
avg_seconds DOUBLE
Average time from the previous step, in seconds.
Example

Sign-up to purchase conversion

SELECT step, event_type, users, round(conversion_rate, 3) AS conversion
FROM amplitude.main.funnel(['Sign Up', 'Purchase'], DATE '2026-11-01', DATE '2026-11-07')
ORDER BY step;
Link
retention (start_event VARCHAR, return_event VARCHAR, start_date DATE, end_date DATE, brackets := VARCHAR, granularity := VARCHAR, group_by := VARCHAR, mode := VARCHAR, segments := VARCHAR) 1 example

Retention analysis: users retained N days (or periods) after a start event, per cohort

Positional arguments
start_event VARCHAR
Event that puts a user in a cohort (positional): an event name or event JSON; _new means new users.
return_event VARCHAR
Event that counts as coming back (positional): an event name or event JSON; _all means any event.
start_date DATE
First day of the range, in the project time zone.
end_date DATE
Last day of the range, inclusive.
Named arguments
brackets := VARCHAR
Brackets for mode = 'bracket' (named): JSON '[[0,5],[5,10]]', end exclusive. · default null
granularity := VARCHAR
Period (named): day (default), week, month. · default "day"
group_by := VARCHAR
One property to group by (named). · default null
mode := VARCHAR
Retention mode (named): nday (default), rolling, bracket, nday_or_before. · default "nday"
segments := VARCHAR
Segment definitions in Amplitude's `s` JSON format (named); NULL means all users. · default null
Returns columns
series_index INTEGER
Series (segment / group) index, 0-based.
cohort VARCHAR
Start-period label as Amplitude returns it (NULL for the combined row).
day INTEGER
Periods after the start period (0 = the start period) or bracket index.
cohort_size BIGINT
Users in the cohort (out of).
retained BIGINT
Users who returned in this period.
retention_rate DOUBLE
retained / cohort_size.
incomplete BOOLEAN
True when the period has not fully elapsed yet.
Example

Combined N-day retention of new users

SELECT day, round(retention_rate, 3) AS retention
FROM amplitude.main.retention('_new', '_all', DATE '2026-11-01', DATE '2026-11-07')
WHERE cohort IS NULL
ORDER BY day;
Link
revenue_ltv (start_date DATE, end_date DATE, granularity := VARCHAR, group_by := VARCHAR, metric := VARCHAR, segments := VARCHAR) 1 example

Revenue lifetime value (ARPU, ARPPU, total revenue or paying users) per acquisition cohort and day

Positional arguments
start_date DATE
First day of the range, in the project time zone.
end_date DATE
Last day of the range, inclusive.
Named arguments
granularity := VARCHAR
Cohort period (named): day (default), week, month. · default "day"
group_by := VARCHAR
One property to group by (named). · default null
metric := VARCHAR
arpu (default), arppu, total_revenue or paying_users (named). · default "arpu"
segments := VARCHAR
Segment definitions in Amplitude's `s` JSON format (named); NULL means all users. · default null
Returns columns
series_index INTEGER
Series index, 0-based.
series_label VARCHAR
Group value (NULL when ungrouped).
cohort_date VARCHAR
Acquisition period (YYYY-MM-DD).
day INTEGER
Days since acquisition (Amplitude's rNd bucket).
value DOUBLE
Metric value N days after acquisition.
cohort_users BIGINT
Users in the cohort.
paying_users BIGINT
Paying users in the cohort.
total_amount DOUBLE
Total revenue of the cohort.
Example

30-day ARPU per acquisition day

SELECT cohort_date, value AS arpu_30d
FROM amplitude.main.revenue_ltv(DATE '2026-10-01', DATE '2026-10-07')
WHERE day = 30
ORDER BY cohort_date;
Link
segmentation (event_json VARCHAR, start_date DATE, end_date DATE, formula := VARCHAR, granularity := VARCHAR, group_by := VARCHAR[], group_limit := INTEGER, metric := VARCHAR, second_event := VARCHAR, segments := VARCHAR, user_type := VARCHAR) 2 examples

Event segmentation chart (uniques, totals, DAU %, averages, property sums, formulas) as long rows

Positional arguments
event_json VARCHAR
Event type name or Amplitude event JSON (positional).
start_date DATE
First day of the range, in the project time zone.
end_date DATE
Last day of the range, inclusive.
Named arguments
formula := VARCHAR
Formula (named) when metric = 'formula', e.g. 'UNIQUES(A)/UNIQUES(B)'. · default null
granularity := VARCHAR
Interval (named): 'day' (default), 'week', 'month'; segmentation and funnel also take 'hour' (≤ 7 days) and 'realtime' (5-minute, ≤ 2 days). · default "day"
group_by := VARCHAR[]
Up to two user/event property names to group by (named), e.g. ['country']. · default null
group_limit := INTEGER
Group-by values returned (named; Amplitude default 1000, max 20,000). · default null
metric := VARCHAR
Metric (named): uniques (default), totals, pct_dau, average, histogram, sums, value_avg, formula. · default "uniques"
second_event := VARCHAR
Second event (named) for formulas: name or event JSON; it is event B. · default null
segments := VARCHAR
Segment definitions in Amplitude's `s` JSON format (named); NULL means all users. · default null
user_type := VARCHAR
Count 'any' users (default) or only 'active' users (named). · default null
Returns columns
series_index INTEGER
Series (segment / group) index, 0-based.
series_label VARCHAR
Group-by value or segment label (NULL when ungrouped).
period VARCHAR
The x value: a date (YYYY-MM-DD, project time zone), an hour, or a time of day.
value DOUBLE
Metric value for the series in the period.
series_total DOUBLE
The series collapsed over the whole range (Amplitude seriesCollapsed).
Examples (2)

Daily unique purchasers for a week

SELECT period, value AS daily_purchasers
FROM amplitude.main.segmentation('Purchase', DATE '2026-11-01', DATE '2026-11-07')
ORDER BY period;

Purchases per country (grouped in Amplitude)

SELECT series_label AS country, sum(value) AS purchases
FROM amplitude.main.segmentation('Purchase', DATE '2026-11-01', DATE '2026-11-07', metric := 'totals', group_by := ['country'])
GROUP BY ALL
ORDER BY purchases DESC;
Link
session_length_distribution (start_date DATE, end_date DATE, bin_max := INTEGER, bin_min := INTEGER, bin_size := INTEGER, bin_unit := VARCHAR) 1 example

Histogram of session lengths over a date range

Positional arguments
start_date DATE
First day of the range, in the project time zone.
end_date DATE
Last day of the range, inclusive.
Named arguments
bin_max := INTEGER
Highest bin edge (named). · default null
bin_min := INTEGER
Lowest bin edge (named). · default null
bin_size := INTEGER
Bin width (named). · default null
bin_unit := VARCHAR
Bin time unit (named): seconds, minutes, hours, days. · default null
Returns columns
bin_index INTEGER
Bin position, 0-based.
bin VARCHAR
Bin label, e.g. '60s-120s'.
sessions BIGINT
Sessions whose length falls in the bin.
Example

Session length histogram

SELECT bin, sessions
FROM amplitude.main.session_length_distribution(DATE '2026-11-01', DATE '2026-11-07')
ORDER BY bin_index;
Link
sessions_per_user (start_date DATE, end_date DATE) 1 example

Average sessions per user per day

Arguments
start_date DATE
First day of the range, in the project time zone.
end_date DATE
Last day of the range, inclusive.
Returns columns
period VARCHAR
Day (YYYY-MM-DD).
sessions_per_user DOUBLE
Average sessions per active user.
Example

Mean sessions per user over a week

SELECT avg(sessions_per_user) AS mean
FROM amplitude.main.sessions_per_user(DATE '2026-11-01', DATE '2026-11-07');
Link
user_activity (amplitude_id BIGINT, direction := VARCHAR, max_events := INTEGER) 1 example

One user's event stream (most recent first by default), with every export event column

Positional arguments
amplitude_id BIGINT
Amplitude id of the user (positional; see user_search).
Named arguments
direction := VARCHAR
latest (default, newest first) or earliest (named). · default "latest"
max_events := INTEGER
Most events to return (named; default 1000). · default 1000
Returns columns
uuid VARCHAR
Event uuid.
event_type VARCHAR
Event type.
event_time TIMESTAMP WITH TIME ZONE
When the event happened (UTC, clock-corrected).
server_upload_time TIMESTAMP WITH TIME ZONE
Upload time; the Export API's hour range filters on it.
server_received_time TIMESTAMP WITH TIME ZONE
Server receive time.
client_event_time TIMESTAMP WITH TIME ZONE
Event time by the client clock.
client_upload_time TIMESTAMP WITH TIME ZONE
Upload time by the client clock.
processed_time TIMESTAMP WITH TIME ZONE
Processing time.
user_creation_time TIMESTAMP WITH TIME ZONE
When the user was first seen.
user_id VARCHAR
User id (NULL if anonymous).
device_id VARCHAR
Device id.
amplitude_id BIGINT
Amplitude's user id.
event_id BIGINT
Per-device event counter.
session_id BIGINT
Session start, epoch ms (NULL: none).
insert_id VARCHAR
Dedup id ($insert_id).
app BIGINT
Project id.
platform VARCHAR
Platform (iOS, Web …).
os_name VARCHAR
OS name.
os_version VARCHAR
OS version.
device_brand VARCHAR
Device brand.
device_manufacturer VARCHAR
Device manufacturer.
device_model VARCHAR
Device model.
device_family VARCHAR
Device family.
device_type VARCHAR
Device type.
device_carrier VARCHAR
Carrier.
country VARCHAR
Country (IP geo).
region VARCHAR
Region.
city VARCHAR
City.
dma VARCHAR
DMA.
language VARCHAR
Language.
ip_address VARCHAR
Client IP.
location_lat DOUBLE
Latitude.
location_lng DOUBLE
Longitude.
version_name VARCHAR
App version.
start_version VARCHAR
First app version.
library VARCHAR
Sending SDK.
paying BOOLEAN
User has paid.
revenue DOUBLE
Revenue: $revenue, else $price × $quantity.
event_properties JSON
Event properties.
user_properties JSON
User properties then.
group_properties JSON
Group properties.
groups JSON
Groups (type → names).
data JSON
Internal data.
amplitude_event_type VARCHAR
System event type.
amplitude_attribution_ids VARCHAR
Attribution ids.
adid VARCHAR
Google ad id.
idfa VARCHAR
Apple IDFA.
sample_rate DOUBLE
Sample rate.
Example

A user's 20 most recent events

SELECT event_time, event_type
FROM amplitude.main.user_activity(12345, max_events := 20)
ORDER BY event_time DESC;
Link
user_composition (start_date DATE, end_date DATE, property VARCHAR) 1 example

Active users broken down by one property (version, country, platform, a custom gp: property …)

Arguments
start_date DATE
First day of the range, in the project time zone.
end_date DATE
Last day of the range, inclusive.
property VARCHAR
Property to break down by (positional), e.g. 'platform' or 'gp:plan'.
Returns columns
value VARCHAR
Property value ('(none)' when unset).
users BIGINT
Users with that value.
Example

Users per platform

SELECT value AS platform, users
FROM amplitude.main.user_composition(DATE '2026-11-01', DATE '2026-11-07', 'platform')
ORDER BY users DESC;
Link
user_profile (query VARCHAR) 1 example

Profiles (usage totals, first/last seen, devices, location, user properties) of users matching an id

Arguments
query VARCHAR
User id, device id, Amplitude id or user id prefix (positional).
Returns columns
amplitude_id BIGINT
Amplitude id.
user_id VARCHAR
User id.
merged_amplitude_ids BIGINT[]
Amplitude ids merged into this user.
num_events BIGINT
Lifetime events.
num_sessions BIGINT
Lifetime sessions.
usage_time_ms BIGINT
Lifetime usage time (ms).
first_used TIMESTAMP WITH TIME ZONE
First day seen (midnight UTC of Amplitude's date).
last_used TIMESTAMP WITH TIME ZONE
Last day seen (midnight UTC of Amplitude's date).
purchases BIGINT
Revenue events.
revenue DOUBLE
Lifetime revenue.
platform VARCHAR
Platform.
os VARCHAR
Operating system.
version VARCHAR
App version.
device VARCHAR
Device.
device_type VARCHAR
Device type.
carrier VARCHAR
Carrier.
country VARCHAR
Country.
region VARCHAR
Region.
city VARCHAR
City.
dma VARCHAR
DMA.
language VARCHAR
Language.
start_version VARCHAR
First app version.
device_ids VARCHAR[]
Device ids.
last_lat DOUBLE
Last latitude.
last_lng DOUBLE
Last longitude.
properties JSON
User properties (JSON).
Example

A user's profile

SELECT user_id, num_events, last_used, country
FROM amplitude.main.user_profile('user_42');
Link
unified 4 tables · 1 function

Amplitude data in the shared cross-tool product-analytics shape.

Schema examples (5)
Examples (5)

A user in the shared shape

SELECT tool, user_id, last_seen FROM amplitude.unified.users('user_42');

Unique users per event for one day

SELECT event_name, count(DISTINCT distinct_id) AS users
FROM amplitude.unified.events
WHERE event_time >= TIMESTAMPTZ '2026-11-14 00:00:00+00' AND event_time < TIMESTAMPTZ '2026-11-15 00:00:00+00'
GROUP BY event_name
ORDER BY users DESC;

Cohorts by size

SELECT tool, name, size FROM amplitude.unified.cohorts ORDER BY size DESC;

Highest-volume events

SELECT event_name, volume
FROM amplitude.unified.event_definitions
ORDER BY volume DESC NULLS LAST
LIMIT 10;
1 more example

Properties per scope

SELECT scope, count(*) AS properties
FROM amplitude.unified.property_definitions
GROUP BY scope
ORDER BY scope;
Tables
cohorts 1 example9 cols

Cohorts in the shared product-analytics shape (tool, id, name, size, timestamps, definition)

Columns
toolnot null VARCHAR
The analytics tool the row came from: 'amplitude'.
idnot null VARCHAR
The tool's identifier of the cohort.
name VARCHAR
Cohort name.
description VARCHAR
Free-text description of the cohort.
size BIGINT
Count of members at the last computation.
created_at TIMESTAMP WITH TIME ZONE
Created.
updated_at TIMESTAMP WITH TIME ZONE
Last modified.
is_archived BOOLEAN
Archived.
definition JSON
Tool-specific definition (JSON).
ConstraintsPRIMARY KEY (id)
Example

Cohorts by size

SELECT tool, name, size FROM amplitude.unified.cohorts ORDER BY size DESC;
Link
event_definitions 1 example9 cols

Event definitions in the shared product-analytics shape (name, description, category, volume)

Columns
toolnot null VARCHAR
The analytics tool the row came from: 'amplitude'.
event_namenot null VARCHAR
Event name exactly as the SDKs send it.
display_name VARCHAR
Human-friendly name shown in the tool's UI.
description VARCHAR
Free-text description from the tracking plan.
category VARCHAR
Tracking-plan category the event is filed under.
is_hidden BOOLEAN
Hidden in the tool's UI.
is_active BOOLEAN
Receiving data.
volume BIGINT
Recent volume (Amplitude: events this week).
tags VARCHAR[]
Free-form labels from the tracking plan.
ConstraintsPRIMARY KEY (event_name)
Example

Highest-volume events

SELECT event_name, volume
FROM amplitude.unified.event_definitions
ORDER BY volume DESC NULLS LAST
LIMIT 10;
Link
events 1 example19 cols

Raw events in the shared product-analytics shape (tool, event_name, event_time, ids, properties)

Columns
toolnot null VARCHAR
The analytics tool the row came from: 'amplitude'.
uuidnot null VARCHAR
The tool's unique event id (Amplitude uuid).
event_namenot null VARCHAR
Event name (Amplitude event_type).
event_timenot null TIMESTAMP WITH TIME ZONE
When the event happened (UTC).
received_time TIMESTAMP WITH TIME ZONE
When the tool received the event (Amplitude server_upload_time).
user_id VARCHAR
User id (NULL if anonymous).
device_id VARCHAR
Device / anonymous id.
distinct_id VARCHAR
The id the tool resolves people by (Amplitude amplitude_id, as text).
session_id VARCHAR
Session id as text (Amplitude: session start epoch ms).
insert_id VARCHAR
Client deduplication id.
properties JSON
Event properties.
user_properties JSON
User properties at event time (JSON object).
platform VARCHAR
Platform, e.g. 'iOS', 'Web'.
os VARCHAR
OS name.
country VARCHAR
Country name from IP geolocation.
city VARCHAR
City name from IP geolocation.
app_version VARCHAR
Version of the app that sent the event.
library VARCHAR
SDK that sent the event.
revenue DOUBLE
Revenue attached to the event, in the project's currency.
ConstraintsPRIMARY KEY (uuid)
Example

Unique users per event for one day

SELECT event_name, count(DISTINCT distinct_id) AS users
FROM amplitude.unified.events
WHERE event_time >= TIMESTAMPTZ '2026-11-14 00:00:00+00' AND event_time < TIMESTAMPTZ '2026-11-15 00:00:00+00'
GROUP BY event_name
ORDER BY users DESC;
Link
property_definitions 1 example10 cols

Event, user and group property definitions in the shared product-analytics shape

Columns
toolnot null VARCHAR
The analytics tool the row came from: 'amplitude'.
property_namenot null VARCHAR
Property key exactly as sent in event or user properties.
scopenot null VARCHAR
'event', 'user' or 'group'.
event_name VARCHAR
Event the property belongs to (event scope; NULL when shared).
data_type VARCHAR
Declared value type: string, number, boolean, enum …
description VARCHAR
Free-text description from the tracking plan.
is_array BOOLEAN
Array-valued.
is_required BOOLEAN
Required.
is_hidden BOOLEAN
Hidden.
enum_values VARCHAR[]
Allowed values.
Example

Properties per scope

SELECT scope, count(*) AS properties
FROM amplitude.unified.property_definitions
GROUP BY scope
ORDER BY scope;
Link
Table functions
users (query VARCHAR) 1 example

Users matching an id, in the shared product-analytics shape

Arguments
query VARCHAR
User id, device id, Amplitude id or user id prefix (positional).
Returns columns
tool VARCHAR
The analytics tool the row came from: 'amplitude'.
user_id VARCHAR
User id.
distinct_id VARCHAR
The tool's person id (Amplitude id as text).
device_ids VARCHAR[]
Device / anonymous ids.
first_seen TIMESTAMP WITH TIME ZONE
First seen (day precision for Amplitude).
last_seen TIMESTAMP WITH TIME ZONE
Last seen (day precision for Amplitude).
properties JSON
User properties (JSON).
platform VARCHAR
Platform.
os VARCHAR
Operating system.
country VARCHAR
Country.
city VARCHAR
City.
app_version VARCHAR
App version.
Example

A user in the shared shape

SELECT tool, user_id, last_seen FROM amplitude.unified.users('user_42');
Link

Credentials

The secret type amplitude declares, as reported by the worker itself.

amplitude

How to get these credentials

An Amplitude project's API key and secret key (HTTP Basic auth), plus its data region

secret.sql
CREATE SECRET amplitude (
    TYPE amplitude,
    api_key    '<AMPLITUDE_API_KEY>',  -- secret
    secret_key '<SECRET_KEY>',  -- secret
    region     '<region>',
    base_url   '<base_url>'
);
Key Type Required Description
api_key secret VARCHAR — Project API key (Project settings > General).
secret_key secret VARCHAR — Project secret key (Project settings > General).
region VARCHAR — Data region: 'us' (default, https://amplitude.com) or 'eu' (https://analytics.eu.amplitude.com).
base_url VARCHAR — Override the API origin (a proxy or test server); wins over REGION. http:// only for 127.0.0.1/localhost.

The worker doesn't mark which keys are required.

Create the secret in the same session, after attaching amplitude — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

events_columns — The events() result columns (binds only; create an amplitude secret and drop LIMIT 0 for rows)

SELECT event_time, event_type, user_id, revenue
FROM amplitude.main.events()
LIMIT 0;

Uses events

segmentation_columns — The segmentation() result columns (binds only)

SELECT series_label, period, value
FROM amplitude.main.segmentation('Purchase', DATE '2026-11-01', DATE '2026-11-07')
LIMIT 0;

Uses segmentation

Sign-up to purchase conversion

SELECT step, event_type, users, round(conversion_rate, 3) AS conversion
FROM amplitude.main.funnel(['Sign Up', 'Purchase'], DATE '2026-11-01', DATE '2026-11-07')
ORDER BY step

Uses funnel

Combined N-day retention of new users

SELECT day, round(retention_rate, 3) AS retention
FROM amplitude.main.retention('_new', '_all', DATE '2026-11-01', DATE '2026-11-07')
WHERE cohort IS NULL
ORDER BY day

Uses retention

Daily active users for a week

SELECT period, users AS dau
FROM amplitude.main.active_users(DATE '2026-11-01', DATE '2026-11-07')
ORDER BY period

Uses active_users

Average session minutes per day

SELECT period, round(avg_seconds / 60, 1) AS minutes
FROM amplitude.main.average_session_length(DATE '2026-11-01', DATE '2026-11-07')
ORDER BY period

Uses average_session_length

28 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Which three event types have the most events this week in Amplitude?
  • How many Purchase events happened in Amplitude on 2026-11-14 (UTC), from the raw event export?
  • What was the total revenue per country from raw Amplitude events on 2026-11-14 (UTC)?
  • How many unique users did 'Purchase' in Amplitude each day from 2026-11-01 to 2026-11-03?
  • What fraction of users who signed up (Sign Up) went on to Purchase between 2026-11-01 and 2026-11-07?
  • Which Amplitude cohort has the most users?

Amplitude is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.