Python Client Library for Google APIs is out of Beta
|
Antonio |
|
Joe |
By Joe Gregorio and Antonio Fuentes, Google Developer Team
We have awesome news for Python developers. The
Python Client Library for Google
APIs is no longer in Beta! The Python Client Library has been augmented with many
great features since its Beta launch. It now supports OAuth 2.0 service accounts, upload of
media resources, batching of requests, asynchronous requests, resumable media upload, feed
paging and many other features.
We encourage you to check out the new
documentation for the
client library, which not only has brand new content, but also has a slick new look
and is now hosted on developers.google.com.
If you are building a Python application that uses Google APIs, we strongly recommend you use
this client library. First, the library makes it simple to call any RESTful Google API and
grab the data returned by the call. Also, the client library handles the OAuth 2.0
authentication protocol and all errors for you without the need to write any additional
code.
Making a call to a RESTful API using the Google APIs Client Library for Python is simple. You
start by constructing an http object to sign all requests with OAuth 2.0 credentials:
http =
httplib2.Http()
http = credentials.authorize(http)
You then create a service object that knows how to talk to a Google API. In this example, we
use the Google+ API:
service =
build("plus", "v1", http=http)
You then access a collection of resources in the API by simply calling its name. The
collection object that is returned has all the methods that a collection understands. Here we
execute a GET request on the
people
collection passing the
userID
parameter:
person =
service.people().get(userId='me').execute()
print "Your
name is: %s" % person['displayName']
To get started, check out the
documentation for
the client library, which contains instructions for how to download and install it. As always,
your
feedback
is welcome!
Joe Gregorio is a Software Engineer. In the past five years at Google he’s worked on
APIs, Google App Engine, Google Wave, and now has come full circle and is back working on
APIs.
Antonio Fuentes is a Product Manager focusing on developer-facing technologies. He
has experience launching products in the cloud computing, infrastructure, and virtualization
spaces.
Posted by Scott Knaster,
Editor