Skip to content

Commit ad42bfc

Browse files
committed
Add hourly export docs
1 parent d9c48a0 commit ad42bfc

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

_docs/50_api/20_export-data-points.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ redirect_from:
77
- /api/export-pageviews
88
- /api/export-page-views
99
- /api/export-events
10-
last_modified_at: 2022-11-12
10+
last_modified_at: 2025-07-04
1111
fields: added_iso,country_code,datapoint,device_type,path,query,query_and_path,session_id,utm_source,utm_campaign,utm_content,utm_medium
1212
---
1313

@@ -17,6 +17,27 @@ With this API you can export raw data points (without sampling). Data points are
1717
1818
When using the API, it's recommended [to generate the export URL](/api/helpers#generate-export-url) via [the export your data interface](/export-data). It has a simple UI where fields can be selected without any coding or technical knowledge.
1919

20+
## Hourly data export
21+
22+
You can now export data for specific hours of a day. This allows for more granular data analysis when you need to understand traffic patterns within a single day.
23+
24+
To export hourly data, append the hour to your date in the format `YYYY-MM-DDTHH` where `HH` is the hour in 24-hour format (00-23).
25+
26+
**Important constraints for hourly exports:**
27+
28+
- Both `start` and `end` parameters must include the hour
29+
- The start and end dates must be the same (you can only export hourly data for a single day at a time)
30+
- Hours must be between 00 and 23
31+
32+
**Example:**
33+
34+
```bash
35+
# Export data for 2PM on July 4th, 2025
36+
curl "https://simpleanalytics.com/api/export/datapoints?version={{ site.api_version }}&format=csv&hostname=example.com&start=2025-07-04T14&end=2025-07-04T14&fields=added_iso,path" \
37+
-H 'User-Id: sa_user_id_...' \
38+
-H 'Api-Key: sa_api_key_...'
39+
```
40+
2041
<details>
2142
<summary>Available fields in export</summary>
2243
<div markdown="1">
@@ -95,10 +116,17 @@ You can specify all fields you like to export. Add them as a comma seperated lis
95116
To test if your API key works correctly you can replace the example values of this cURL example with your own.
96117

97118
```bash
119+
# Export daily data
98120
curl "https://simpleanalytics.com/api/export/datapoints?version={{ site.api_version }}&format=csv&hostname=simpleanalytics.com&start={{ "now" | date: '%s' | minus: 2592000 | date: '%Y-%m-%d' }}&end={{ "now" | date: '%Y-%m-%d' }}&robots=false&timezone=Europe%2FAmsterdam&fields=added_iso,path&type=pageviews" \
99121
-H 'User-Id: sa_user_id_00000000-0000-0000-0000-000000000000' \
100122
-H 'Api-Key: sa_api_key_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
101123
-H 'Content-Type: text/csv'
124+
125+
# Export hourly data (for 3PM today in Amsterdam)
126+
curl "https://simpleanalytics.com/api/export/datapoints?version={{ site.api_version }}&format=csv&hostname=simpleanalytics.com&start={{ "now" | date: '%Y-%m-%d' }}T15&end={{ "now" | date: '%Y-%m-%d' }}T15&robots=false&timezone=Europe%2FAmsterdam&fields=added_iso,path&type=pageviews" \
127+
-H 'User-Id: sa_user_id_00000000-0000-0000-0000-000000000000' \
128+
-H 'Api-Key: sa_api_key_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
129+
-H 'Content-Type: text/csv'
102130
```
103131

104132
</div>

0 commit comments

Comments
 (0)