Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Example code for consuming data from Google APIs via Erlang
branch: master
Failed to load latest commit information.
src Initial checkin
README Add links to README


Very rough example of querying the Google Discovery APIs ( and retrieving data from Google+ using Erlang. This is certainly not a complete Discovery client implementation, but contains most of the required ingredients for creating one! 

==== Links from the talk

Developer Console
API Explorer
API Explorer Sourcecode

==== Code Examples

Requires the mochijson2 library. 

erl -pa /path/to/mochijson2/ebin

API access. Get these values from the Devconsole:
If following along you'll need to create a Simple API Key, and a OAuth Web ClientID. Enable the Google+ API in the Services tab.

RedirectURL = "http://localhost:8080/oauth2callback".
ClientID = "". %% For OAuth
ClientSecret = "". %% For OAuth
APIKey = "". %% For Simple API usage

%% Start service
plus_srv:start_link(APIKey, ClientID, ClientSecret, RedirectURL).
%% Retrieve a list of available APIs from the Discovery Document
AllApis = plus_srv:list_apis().
lists:foreach(fun({N,U}) -> io:format("API: ~s~n~s~n--------~n", [N,U]) end, AllApis).
%% Use the Google+ API
%% List methods in the basic Google+ API
%% Search for mentions of Erlang on Google+
{ok, Activities} = plus_srv:call_method("", [{"query", "erlang"}], []).
Items = proplists:get_value(<<"items">>, Activities).
lists:foreach(fun({struct, I}) -> io:format("Title: ~s~n--------~n", [proplists:get_value(<<"title">>, I)]) end, Items).
%% Call profile retrieval - will return an auth error
plus_srv:call_method("plus.people.get", [{"userId", "me"}], []).
%% Show the scopes required for people.get
%% Generate a token URL to paste in the browser 
%% - grab the code and state params from there for the next call
%% Exchange the code for an auth token
plus_srv:exchange_token("", "").
%% Retrieve profile data from Google+
{ok, Person} = plus_srv:call_method("plus.people.get", [{"userId", "me"}], []).
io:format("~s: ~s~n", [proplists:get_value(<<"displayName">>, Person), proplists:get_value(<<"url">>, Person)]).
Something went wrong with that request. Please try again.