Get retention cohorts
curl --request GET \
--url https://api.datalyr.com/v1/retention \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.datalyr.com/v1/retention"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.datalyr.com/v1/retention', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.datalyr.com/v1/retention",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.datalyr.com/v1/retention"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.datalyr.com/v1/retention")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.datalyr.com/v1/retention")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"cohorts": [
{
"cohort_date": "<string>",
"cohort_size": 123,
"periods": [
{
"period_index": 123,
"active_persons": 123,
"retention_rate": 123,
"revenue": 123
}
]
}
],
"granularity": "day",
"date_range": {
"start": "<string>",
"end": "<string>"
},
"complete": true,
"meta": {
"grain": "<string>",
"metric": "<string>",
"max_periods": 123,
"cohort_count": 123,
"period_unit": "<string>",
"cohort_basis": "<string>",
"limitation": "<string>"
}
}{
"error": "<string>"
}{
"error": "<string>"
}Cohorts and funnels
Get retention cohorts
Person-grain retention cohorts. Each person is anchored to the cohort of their ALL-TIME first recorded activity, so start_date and end_date select which cohorts come back, not what counts as acquisition. Every cohort carries one row per elapsed period with the persons active in it, the retention rate, and the revenue those persons recorded.
Activity retention only: a person counts as retained for ANY activity in the period. Event-specific retention, such as returned and purchased, is not available in this version and is not approximated.
GET
/
retention
Get retention cohorts
curl --request GET \
--url https://api.datalyr.com/v1/retention \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.datalyr.com/v1/retention"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.datalyr.com/v1/retention', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.datalyr.com/v1/retention",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.datalyr.com/v1/retention"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.datalyr.com/v1/retention")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.datalyr.com/v1/retention")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"cohorts": [
{
"cohort_date": "<string>",
"cohort_size": 123,
"periods": [
{
"period_index": 123,
"active_persons": 123,
"retention_rate": 123,
"revenue": 123
}
]
}
],
"granularity": "day",
"date_range": {
"start": "<string>",
"end": "<string>"
},
"complete": true,
"meta": {
"grain": "<string>",
"metric": "<string>",
"max_periods": 123,
"cohort_count": 123,
"period_unit": "<string>",
"cohort_basis": "<string>",
"limitation": "<string>"
}
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Query Parameters
Response
Successful response. Activity retention: a person counts as retained for any activity in the period, not for a specific event.
Was this page helpful?