For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Login
HomeDocsAPI ReferenceMCP ServerChat SDKsRelease Notes
HomeDocsAPI ReferenceMCP ServerChat SDKsRelease Notes
  • Introduction
    • Overview
    • Authentication
    • Versioning
    • Limits
    • Pagination
    • Errors
    • Migrate to V2
    • Changelog
  • Knowledge
    • Overview
    • Sources
    • Articles
    • Tags
  • End Users
    • Overview
    • Getting started
    • Developer guide
  • Integrations
    • Overview
    • Getting started
  • Conversations
    • Overview
    • Getting started
  • Webhooks
    • Overview
  • Data Compliance
    • Overview
  • Data Export
    • Overview
    • Getting started
    • Conversations
    • Messages
Login
LogoLogo
On this page
  • Fetch All Messages from the Previous Day
Data Export

Getting started

Previous

Conversation object

Next
Built with

The following example demonstrates how to use the Data Export API to retrieve messages from a specific time range. In this case, the code fetches all messages from the previous day, handling pagination until all data is retrieved.

The sample code is provided in both JavaScript and Python to help you get started quickly.

Replace placeholders like <YOUR-BOT-HANDLE> and <YOUR-API-KEY> with your own credentials to begin fetching data.

Fetch All Messages from the Previous Day

1import fetch from "node-fetch"
2
3async function fetchMessages() {
4 const API_KEY = "<YOUR-API-KEY>"
5
6 const startOfYesterday = new Date(), endOfYesterday = new Date()
7
8 startOfYesterday.setDate(new Date().getDate() - 1)
9 startOfYesterday.setHours(0)
10 startOfYesterday.setMinutes(0)
11 startOfYesterday.setSeconds(0)
12
13 endOfYesterday.setDate(new Date().getDate() - 1)
14 endOfYesterday.setHours(23)
15 endOfYesterday.setMinutes(59)
16 endOfYesterday.setSeconds(59)
17
18
19 let endpoint = `api/v2/export/messages?created_since=${startOfYesterday.toISOString()}&created_to=${endOfYesterday.toISOString()}`
20
21 while (endpoint) {
22 const res = await fetch(`https://<YOUR-BOT-HANDLE>.ada.support/${endpoint}`,
23 {
24 headers: {
25 Authorization: `Bearer ${API_KEY}`
26 }
27 }
28 )
29
30 const json = await res.json()
31 saveToDatabase(json.data)
32 endpoint = json.meta?.next_page_uri
33 }
34}