Code Monkey home page Code Monkey logo

google-api-elixir-client's Introduction

Google API Client for Elixir

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.

Installation

  1. 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.

  1. Go to the Google Developers Console.
  2. Click Create Project, enter a name, and click Create.
  3. 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:

  1. Create Credentials (API Key)
  2. Add the following to your Elixir app's configuration:
  config :google_api_client,
    api_key: "Your API key"

For Ouath based requests:

  1. Implement oauth to obtain a user's token (see: https://developers.google.com/identity/protocols/OAuth2WebServer)
  2. Pass the access token to methods which require oauth

Usage

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

Special Thanks / Contributors

  • Daniel Upton @elkelk
  • AJ Gregory @aj-gregory

google-api-elixir-client's People

Contributors

aj-gregory avatar elkelk avatar mkkroliks avatar seanabrahams avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

google-api-elixir-client's Issues

Authorization

So Google Drive only supports OAuth2 to authorize requests - see https://developers.google.com/drive/v3/web/about-auth .

We have a couple of options:

1/ Add a dependency to a library to handle auth, as this will mean that google-api-elixir-client only interacts with Google API and doesn't handle auth (good)
2/ Write auth ourselves.

I recommend option 1, as this will reduce the initial development time, and help grow both projects.

Tests

Testing third party APIs can be tricky.

We might want to look into something like exvcr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.