The new Gmail API
JOHN RAE-GRANT: Hi,I’m John Rae-Grant,product manager forGmail Extensibility. I’m here to talk aboutthe new Gmail API. Let’s start with aquick history lesson. Back in the midst of thedistant past, there was email. Many email systemswere closed, meaningthat you had to use aspecific applicationor a specific websiteto manage your mail. This made it hard for peoplewho had multiple accountsor multiple clientsto manage their mail. So IMAP was born. IMAP is a standard protocoldesigned for an email clientto connect to an email server. IMAP’s great, becauseit means that wecan do cool things like getall of our mail into one inboxor send email using any of ouraccounts from the same client. So IMAP was designed toenable a full-fledged emailclient to connectto an email service. Gmail initially introducedIMAP support in 2007,specifically withthe goal of makingit easy to use mobile deviceemail apps to access your Gmailaccount. And it was good. Then things got interesting. Once Gmail opened up toIMAP, the developer communityrealized there was nowa way to enable usersto add features thatused their Gmail data. These developers,you folks, went waybeyond buildingsimple email clients. You did brilliant things, likeadding a record of messagesexchanged with eachprospect to a CRM system. You made useful utilities, whichmanage your email subscriptionsor allow you to sendmail at a later date. You even wrote customChrome extensionswhich talk to IMAP andextend the Gmail UI. All of these are good things. So what’s the problem with IMAP?Well, IMAP’s great,but Gmail and youhave gone way beyondwhat it was designed for. IMAP was designeda long time ago. Originally, in 1986, withthe last major core protocolversion in 1998. To give some context, that’s theyear the Sony PlayStation wasbattling it outwith the Nintendo64 and a new search enginecalled Google first launched. APIs have come along way since then. IMAP was designed to handle thekind of mailboxes people usedto have. It was never intended toscale to hundreds of thousandsof messages in an inbox. In 2004, Gmailrevolutionized the inboxby giving you onegigabyte of storage,giving you the ability to stopwasting time sorting foldersand instead use powerfulqueries to search labels. Despite the decade sinceIMAP was introduced,it still doesn’t havestandards to supportthe revolutionary wayGmail interacted with usersa decade ago, let alone ourmany improvements since then. It’s not that IMAP isn’t useful. It’s that it’s getting usedin ways for which it wasn’tdesigned, sort oflike this golf club. You can use it forbowling, and since you’reclever and determined you mightmanage to knock down some pins,but it’s not reallythe right tool. So we’re introducingthe new Gmail APIto enable you all tocreatively meet the modern usecases of today’s users. We’ve kept in mindall the performanceand ease of use that you’dexpect to come with that. The new Gmail APIprovides very simplywhat you would expect, withRESTful access to threads,messages, and labels,including drafts. In contrast to IMAP,which requires accessto all of the user’smessages for all operations,the new API gives fine grainedcontrol to the user’s mailbox. If you just need to send mailas a convenience from your app,you don’t need to ask the userfor permission to read mail. To keep in sync, the API allowsyou to query the inbox changehistory, thereby avoiding theneed to pull or do archaeologyto figure out what changed. Most importantly,this API is designedto make it easy and efficientto do specific queries,such as get me all themessages exchanged with Joe. Or get all the messages receivedwith the my_company label. Or get me all themessages in this thread. Essentially, the APIoffers the full searchcapabilities of the webUI using the same syntaxas the search box. Since the new Gmail APIis a standard Google API,you get simple HTTPSaccess using RESTful callsand get your responses inJSON, XML, or Google Protobufformats. You can also make these callsfrom standard web languageslike Java and Python. And there’s no needfor a TCP socket. This means that the API isaccessible from many cloudenvironments thatcouldn’t support IMAP. Not only does thenew API replaceIMAP for manyapplications, it alsoreplaces SMTP for mail sending. And one huge advantage is speed. As I mentionedearlier, IMAP was neverdesigned to do what you’vebeen getting it to do. Because the new Gmail APIwas designed for the Gmailbackend architecture,it understandslabels instead offolders and is optimizedfor exactly these operations. Here are somepreliminary speed testswhich demonstrate that evenbefore the tuning, whichyou beta users willbe helping us to do,the Gmail API handlesgetting a threador doing a searchfor matching messagesa factor of three to 10times faster than IMAP. Since the new Gmail API is astandard Google Developer API,you’ll be able to getstarted right away usingthe same developer keyand developer consolethat you already usefor other Google APIs. All access is under standardOAuth 2. 0 authentication,so you’ve likely alreadydone that as well. If you haven’t, the exampleapps and SDK documentationhave done most ofthe work for you. The Gmail API is entering betathe week of June 24, 2014. We’re really eager to getyour suggestions and feedback. To get started, go to theGoogle Developers siteand follow the instructionsto sign up for the beta. And we’d love to hear yourfeedback and suggestions. On behalf of the Gmail team,thanks for your attention. And we can’t waitto see what you’llmake with the new Gmail API.