📬 Google Gmail API

Number of APIs: 78

Gmail API Overview with Qodex Collection

The Gmail API allows developers to access and manage a user's mail within Gmail. With this API, developers can build a range of applications that operate within the Gmail platform, such as applications that automate email responses, analyze mailbox data, and manage users' emails

Technical Concepts

MIME Messages

  • What is a MIME Message?: MIME (Multipurpose Internet Mail Extensions) is a standard that extends the format of email to support text in character sets other than ASCII, as well as attachments of audio, video, images, and application programs.
  • From: sender@example.comTo: recipient@example.comSubject: Sample MIME EmailContent-Type: text/plainThis is a plain text body of the email.

Encodings

  • Base64 Encoding: Base64 is a method for encoding binary data into ASCII characters. It is commonly used in email to encode attachments.
  • URL Safe Encoding: When using Base64 in URLs, it is modified to be URL safe by replacing + with - and / with _.

Obtaining Access Tokens

To make requests to the Gmail API, you need an OAuth 2.0 token:

  1. Google Developer Console: Go to the Google Developer Console, create a new project, and enable the Gmail API.
  2. OAuth Consent Screen: Set Up OAuth Consent Screen with the proper scopes
  3. Credentials: Create credentials (OAuth client ID)

Scopes

The Gmail API uses scopes to specify the level of access that the application requires. Below is a table of common scopes:

ScopeDescription
https://www.googleapis.com/auth/gmail.readonlyAllows read-only access to the user's emails.
https://www.googleapis.com/auth/gmail.modifyAllows read and write access to user's emails but not deletion.
https://www.googleapis.com/auth/gmail.composeAllows creating, reading, and sending emails.
https://www.googleapis.com/auth/gmail.sendAllows sending emails only.
https://www.googleapis.com/auth/gmail.labelsAllows managing labels and settings of Gmail.

Common Parameters

ParameterDescriptionExample Value
access_tokenOAuth 2.0 token for the user account. It is used to authenticate API requests involving user data.{{accessToken}}
altAlternative format type for the response data. Common values are json and media.json
callbackName of the JavaScript callback function that handles the response. Used in JSONP requests.handleResponse
fieldsThe fields parameter allows you to specify which attributes of a resource should be included in the API response, helping to streamline the data load. To include attributes from nested objects, use parentheses:.messages(id,snippet,payload(headers))
keyAPI key. Used to identify the application making the request.{{key}}
oauth_tokenOAuth 2.0 token for the user account, can be used as an alternative to using the Authorization header.{{oauth_token}}
prettyPrintReturns response with indentations and line breaks to make it more readable.true or false
quotaUserAn opaque string that helps manage quota for APIs when not using an API key.custom_user_id_string
upload_protocolSpecifies the upload protocol used in file upload requests.resumable
uploadTypeType of upload request, such as media, multipart, or resumable.multipart
$.xgafvVersion of the Google API front-end to use. Useful for Google internal experimentation with APIs.2
  1. Notifications - Stop Notifications for User POST {{baseUrl}}/gmail/v1/users/:userId/stop

  2. Profile - Get Profile GET {{baseUrl}}/gmail/v1/users/{{userId}}/profile

  3. Notifications - Watch Users POST {{baseUrl}}/gmail/v1/users/:userId/watch

  4. settings-imap - GET IMAP GET {{baseUrl}}/gmail/v1/users/:userId/settings/imap

  5. settings-language - Get Language Settings GET {{baseUrl}}/gmail/v1/users/:userId/settings/language

  6. settings-pop - Update POP Settings PUT {{baseUrl}}/gmail/v1/users/:userId/settings/pop

  7. settings-vacation - Get Vacation Settings GET {{baseUrl}}/gmail/v1/users/:userId/settings/vacation

  8. settings-vacation - Update Vacation Settings PUT {{baseUrl}}/gmail/v1/users/:userId/settings/vacation

  9. settings-Send As-Send As Email-SMIME INFO-Set Default - Set default S/MIME config POST {{baseUrl}}/gmail/v1/users/:userId/settings/sendAs/:sendAsEmail/smimeInfo/:id/setDefault

  10. settings-imap - Update IMAP PUT {{baseUrl}}/gmail/v1/users/:userId/settings/imap