Skip to content

Commit cc6c91e

Browse files
authored
Merge pull request #304 from tinybirdco/iterate_api_endpoint_102
add new endpoint
2 parents 0cd4aad + 825737b commit cc6c91e

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
DESCRIPTION >
2+
Top Browsers ordered by most visits.
3+
Accepts `date_from` and `date_to` date filter. Defaults to last 7 days.
4+
Also `skip` and `limit` parameters for pagination.
5+
6+
7+
TOKEN "dashboard" READ
8+
9+
NODE endpoint
10+
DESCRIPTION >
11+
Group by browser and calcualte hits and visits
12+
13+
SQL >
14+
15+
%
16+
select
17+
browser,
18+
device,
19+
uniqMerge(visits) as visits,
20+
countMerge(hits) as hits
21+
from
22+
analytics_sources_mv
23+
where
24+
{% if defined(date_from) %}
25+
date >= {{Date(date_from, description="Starting day for filtering a date range", required=False)}}
26+
{% else %}
27+
date >= timestampAdd(today(), interval -7 day)
28+
{% end %}
29+
{% if defined(date_to) %}
30+
and date <= {{Date(date_to, description="Finishing day for filtering a date range", required=False)}}
31+
{% else %}
32+
and date <= today()
33+
{% end %}
34+
group by
35+
browser, device
36+
order by
37+
visits desc
38+
limit {{Int32(skip, 0)}},{{Int32(limit, 50)}}
39+
40+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tb pipe data top_browsers_1 --date_from 2024-01-11 --date_to 2024-01-12 --format CSV
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"browser","device","visits","hits"
2+
"chrome","desktop",1,2
3+
"firefox","desktop",1,1
4+
"chrome","mobile-android",1,1
5+

0 commit comments

Comments
 (0)