KEMBAR78
Gmail API Guide: Access & Usage | PDF | Representational State Transfer | Hypertext Transfer Protocol
0% found this document useful (0 votes)
221 views5 pages

Gmail API Guide: Access & Usage

The document provides information about the Gmail API, which is a RESTful API that allows applications to access a Gmail account and perform operations like reading, composing, sending, and labeling emails. It describes the primary resources (messages, labels, drafts, history, threads) accessible through the API and how operations like getting, creating, updating and deleting can be performed on them. Authentication is done through OAuth 2.0 and applications need to specify scopes for the level of access required. Typical use cases for the Gmail API are also listed.

Uploaded by

Rohit Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
221 views5 pages

Gmail API Guide: Access & Usage

The document provides information about the Gmail API, which is a RESTful API that allows applications to access a Gmail account and perform operations like reading, composing, sending, and labeling emails. It describes the primary resources (messages, labels, drafts, history, threads) accessible through the API and how operations like getting, creating, updating and deleting can be performed on them. Authentication is done through OAuth 2.0 and applications need to specify scopes for the level of access required. Typical use cases for the Gmail API are also listed.

Uploaded by

Rohit Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Gmail API

API:-Application programming interface in basic terms API just allow application to


communicate with one another.
An API is messenger that deliver your requested to the provider that you are requesting it
from and then delivers the response back to you.
An API is not a database .it is an access point to an app that can access a database.
Gmail API: - the Gmail API is RESTful API that can be used to access Gmail mailbox and send
mail.
The API support many of the basic operations available through the Gmail user interface like
reading, composing, and sending mail.
The Gmail REST API uses a JSON payload and provides five primary resource type.
-Message
-Label
-Drafts
-History
-Threads
Message are immutable (unable to change):-they can only be created and deleted .No
message properties can be changes other than the labels applied to given message.
Labels:-
Labels serve as the primary means of categorizing and organizing message and threads.
A labels has many to many relationship with message and threads: a single message may
have multiple labels applied to it and a single labels may be applied to multiple message or
threads.
Example of labels- inbox, sent, trash, spam
Drafts: - it represent unsent message
The message themselves cannot be modified once created but message contained within
the draft may be replaced .sending a draft automatically delete the drafts and create a
message with the sent system label.
History:-history is a collection recently modified in chronological order while the history is
intended as lightweight method of synchronizing a client it typically only contains record of
changes with in past 30 days.
Manual synchronization (more than one place stored or backup file) is required for client
that are out –of-date for more 30 days.
Threads: - are collection of message that represent conversations. Like message threads may
also have labels applied to them. However unlike message threds can’t create only deleted
Message can however be inserted into threads.
API Authorization and scopes
The Gmail API uses OAuth 2.0 to handle authentications and authorizations which means
you will have to generate client credentials in the google developer console.
Your application will also specify one or more scope to gain access to various resources
provided by the API.

scope descriptions

https://mail.google.com Full access to the account, including


permanent deletion of thread and
message. The scope should only be
requested if your applications need to
immediately and permanently delete
threads and message.
https://mail.googleapis.com/auth/gmail.modify All read/write operations except
immediate, permanent deletions of
threads and message.
https://mail.googleapis.com/auth/gmail.readonly Read all resources and their meta
data. no write operations.
https://mail.googleapis.com/auth/gmail.compose Create, read, update, and delete
drafts. Send message and drafts.

Typical use cases


The Gmail API can be used in a variety of different applications including typically.
-Read-only mail extension, indexing, and backup.
-label management (add and remove labels)
-automated or programmatic message sending.
- Move from one part of something to another. (Email account to other providers)
-set standardized email signature for users in domain

RESTful API
RESTful API is an application programme interface that uses HTTP request to GET, PUT,
POST, and DELETE data.
A RESTful API -- also referred to as a RESTful web service -- is based on representational
state transfer (REST) technology, an architectural style and approach to communications
often used in web service development.

GET() - this methods are used for get the details from the server.

POST() – this methods are used for create a new entity it can used for send data to the server.

PUT() – this methods are used for create a new entity or existing one.

DELETE() - this methods are used for delete the data from a server.

Gmail API:-

- First you have to choose which technologies you will use.

- Suppose you will use php then u have to requirement of software

Xampp (php 5.4 or greater with the command –line interface)

Composer (dependency management tool for php) and install the composer setup

- And you have google account with Gmail id.

Developer Gmail API in php:-

1:- requirement of software

- Php version (5.4 onwards)

- Composer (php dependency manager)

2:- google account

3:- installation

- Downloads the composer

- Once composer is installed execute the following command in your project root to
install this library.

composer require google/apiclient:"^2.0"

- And after that include the autoloader


require_once '/path/to/your-project/vendor/autoload.php';

https://stackoverflow.com/questions/38508735/how-to-send-a-reply-to-an-mail-using-
gmail-api

You might also like