Elixir library for accessing Google APIs.
Only the following APIs are supported:
- Analytics (partial)
- Knowledge Graph Search API
- Maps Time Zone API
- Places Autocomplete
- Nearby Places Search
PRs are welcome for more APIs.
- Add google_api_client to your list of dependencies in
mix.exs
:
def deps do
[{:google_api_client, "~> 1.1"}]
end
You will need a Google Developers Console project.
- Go to the Google Developers Console.
- Click Create Project, enter a name, and click Create.
- Once inside your project, enable access to the Google APIs you want this project to have access to (Library -> Search -> Enable).
For key based requests:
- Create Credentials (API Key)
- Add the following to your Elixir app's configuration:
config :google_api_client,
api_key: "Your API key"
For Ouath based requests:
- Implement oauth to obtain a user's token (see: https://developers.google.com/identity/protocols/OAuth2WebServer)
- Pass the access token to methods which require oauth
results = Google.Apis.KnowledgeGraph.search("elixir")
results["itemListElement"] # List of results
# See https://developers.google.com/knowledge-graph/reference/rest/v1/ for a
# full description of what's contained in results
Google.Apis.Maps.TimeZone.get(location: {-33.86,151.20})
# => %{"dstOffset" => 3600, "rawOffset" => 36000, "status" => "OK", "timeZoneId" => "Australia/Sydney", "timeZoneName" => "Australian Eastern Daylight Time"}
Google.Apis.Places.autocomplete("poz", language: "pl")
Google.Apis.Places.Nearby.get({-33.86,151.20}, radius: 50)
alias Google.Apis.Analytics.Accounts
Accounts.list("a_valid_oauth_token")
alias Google.Apis.Analytics.WebProperties
WebProperties.get("a_valid_oauth_token", account_id, web_property_id)
WebProperties.insert("a_valid_oauth_token", account_id, resource)
WebProperties.list("a_valid_oauth_token", account_id)
WebProperties.patch("a_valid_oauth_token", account_id, web_property_id, resource)
WebProperties.update("a_valid_oauth_token", account_id, web_property_id, resource)
alias Google.Apis.Analytics.Views
Views.delete("a_valid_oauth_token", account_id, web_property_id, profile_id)
Views.get("a_valid_oauth_token", account_id, web_property_id, profile_id)
Views.insert("a_valid_oauth_token", account_id, web_property_id, resource)
Views.list("a_valid_oauth_token", account_id, web_property_id)
Views.patch("a_valid_oauth_token", account_id, web_property_id, profile_id, resource)
Views.update("a_valid_oauth_token", account_id, web_property_id, profile_id, resource)
Google.Apis.??? # Submit a PR
- Daniel Upton @elkelk
- AJ Gregory @aj-gregory