Searching for Messages

You can search or filter files using the messages.list and threads.list methods. These methods accept the q parameter which supports the same advanced search syntax as the Gmail web-interface. This advanced syntax allows you to use search queries to filter messages by properties such as the sender, date, or label to name a few possibilities. For example, the following query retrieves all messages sent by the user in January of 2014:

GET https://www.googleapis.com/gmail/v1/users/me/messages?q=in:sent after:2014/01/01 before:2014/02/01

In addition to search queries, you can also filter messages and threads by label with the labelIds parameter. This allows you to search for messages and threads with the specified system or user labels applied. For more information, see the messages.list or threads.list method reference.

Send feedback about...

Need help? Visit our support page.