Session length distribution

GET https://amplitude.com/api/2/sessions/length?start=&end=&timeHistogramConfigBinTimeUnit=&timeHistogramConfigBinMin=&timeHistogramConfigBinMax=&timeHistogramConfigBinSize=

Get the number of sessions for each pre-defined length (bucket) period during a specified date range.

timeHistogramConfigBin Format

timeHistogramConfigBinTimeUnit is any of ['hours', 'minutes', 'seconds'].

In order to take advantage of custom binning, timeHistogramConfigBinMintimeHistogramConfigBinMax, and timeHistogramConfigBinTimeUnit must be specified. When timeHistogramConfigBinSize is not specified, Amplitude will try to determine the optimum bin sizing. For example, if we have timeHistogramConfigBinMin=0timeHistogramConfigBinMax=10, and timeHistogramConfigBinTimeUnit=minutes, there is no guarantee regarding the final amount of bins or bin bounds. If timeHistogramConfigBinSize=1 is specified, 10 bins would be guaranteed, with each bin size equaling a minute.

When combined timeHistogramConfigBin parameters are invalid/missing, Amplitude will default to use default bins that are chosen because they approximate certain behaviors such as bounce rate. These bins are (in milliseconds): [0, 3000), [3000, 10,000), [10,000, 30,000), [30,000, 60,000), [60,000, 180,000), [180,000, 600,000), [600,000, 1,800,000), [1,800,000, 3,600,000), [3,600,000, 86,400,000).

Session lengths are bounded at a maximum of 1 day (86,400,000 ms).

Returns

AttributeDescription
seriesAn array with one element which is itself an array that contains the counts (number of sessions) for each of the buckets.
xValuesAn array of the (string) session length intervals (buckets) of the format [bucketStartInSeconds]s-[bucketEndInSeconds]s.

Request Params

KeyDatatypeRequiredDescription
startnullRequired. First date included in data series, formatted YYYYMMDD (e.g. "20141001").
endnullRequired. Last date included in data series, formatted YYYYMMDD (e.g. "20141004").
timeHistogramConfigBinTimeUnitnullOptional. Time unit for bucket sizes (see below for valid inputs).
timeHistogramConfigBinMinnullOptional. Minimum value for bucketing, as number (e.g. "0").
timeHistogramConfigBinMaxnullOptional. Maximum value for bucketing, as number (e.g. "600").
timeHistogramConfigBinSizenullOptional. Size of each bucket, as number (e.g. "60").

RESPONSES

status: OK

{"withSets":true,"data":{"xValues":["0s-3s","3s-10s","10s-30s","30s-60s","60s-180s","180s-600s","600s-1800s","1800s-3600s","3600s-86400s"],"series":[[11,4,2,4,4,6,2,3,0]],"seriesLabels":[0]},"timeComputed":1643750153702,"wasCached":false,"cacheFreshness":"FRESH","novaRuntime":402,"novaRequestDuration":435,"novaCost":15,"throttleTime":1,"minSampleRate":1,"transformationIds":[],"backend":"novaV2","realtimeDataMissing":false,"timedOutRealtimeData":false,"partialMergedAndNewUserInformation":false,"prunedResult":false,"hitChunkGroupByLimit":false,"subcluster":6,"millisSinceComputed":6,"queryIds":["Pg4CUaNyOK"]}