Reputation: 777
Goal: Fetch all messages from google (emails, and hangouts) and date in which there where sent.
As is: I'm using Gmail-API, messages.get() endpoint. When Im fetching this endpoint with query: in:!chats
aka email messages, all works great. But if I invoke this with query: in:chats
(hangouts messages), the endpoint will return less information than normal message, and unfortunately it won't have send at date.
Is there any way to get send at date from hangout message?
Upvotes: 1
Views: 1097
Reputation: 112867
I would advice you to list entire chat conversations with threads.list() instead.
query = in:chat
GET https://www.googleapis.com/gmail/v1/users/me/threads?q=in%3Achat&access_token={YOUR_API_KEY}
Response:
{
"threads": [
{
"id": "14786647099d3243",
"snippet": "until I 😃...",
"historyId": "147978"
}, ...
]
}
Then, just issue a thread.get()-request on each chat conversation, explicitly asking for the internalDate
-parameter, and you will have when every message was sent in the chat.
fields = messages(id,internalDate)
GET https://www.googleapis.com/gmail/v1/users/me/threads/14786647099d3243?fields=messages(id%2CinternalDate)&key={YOUR_API_KEY}
Response:
{
"messages": [
{
"id": "14786647099d3243", // The Id of the chat message.
"internalDate": "1406709035161" // Time in ms when the message was created.
},
{
"id": "14786650de543fa8",
"internalDate": "1406709075429"
}, ...
]
}
Upvotes: 0