The Gmail API is a RESTful API that can be used to access Gmail mailboxes and send mail. The API supports many of the basic operations available through the Gmail user interface like reading, composing, and sending mail.
The Gmail RESTful API uses a JSON payload and provides five primary resource types:
- Messages
- Labels
- Drafts
- History
- Threads
Messages are immutable: they can only be created and deleted. No message properties can be changed other than the labels applied to a given message.
History is a collection of recently modified messages in chronological order. While the history is intended as a lightweight method of synchronizing a client, it typically only contains records of changes within the past 30 days. Manual synchronization is required for clients that are out-of-date for more than 30 days.
Threads are collections of messages that represent a conversation. Like messages, threads may also have labels applied to them. However, unlike messages, threads cannot be created, only deleted. Messages can be inserted into a thread.
Like other Google APIs, the Gmail API uses OAuth 2.0 to handle authentication and authorization which means you will have to generate client credentials in the Google Developers Console. Your app will also specify one or more scopes to gain access to various resources provided by the API.
List of most to least restrictive scopes:
- 'https://www.googleapis.com/auth/gmail.readonly' - Read only access to all resources + metadata
- 'https://www.googleapis.com/auth/gmail.send' - Send messages only (no inbox read nor modify)
- 'https://www.googleapis.com/auth/gmail.labels' - Create, read, update, and delete labels only
- 'https://www.googleapis.com/auth/gmail.insert' - Insert and import messages only
- 'https://www.googleapis.com/auth/gmail.compose' - Create, read, update, delete, and send email drafts and messages
- 'https://www.googleapis.com/auth/gmail.modify' - All read/write operations except for immediate and permanent deletion of threads & messages
- 'https://mail.google.com/' - All read/write operations
- Gmail Api Overview
- Intro to GMAIL API video
- Getting Started with the Gmail API
- Stackoverflow
- Building Web Applications using Google APIs and JavaScript Client for Google APIs
- Gmail Api v1 Services
- Cross-Origin Resource Sharing
- How to parse PDF files
- Google Push Notifications
- Gmail Service Reference Guide
- Verifying Domains for Push Notifications
- Google API Javascript Libraries
- What is Google Cloud Pub/Sub?
- Parsing body of an email