🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

github.com/appsynthasia/google-places-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/appsynthasia/google-places-api

v0.0.0-20160215072721-97020cc3e0ee
Source
Go
Version published
Created
Source

Google Places API Client for Go

Build Status GoDoc

A Go client for the Google Places API. A work in progress, contributions welcome.

To install this package, run:

go get gopkg.in/maxhawkins/google-places-api.v1/places

Example

package main

import (
    "fmt"
    "net/http"
    "time"

    "gopkg.in/maxhawkins/google-places-api.v1/places"
)

func main() {
    service := places.NewService(http.DefaultClient, "<your api key>")

    call := service.Nearby(37.7833, -122.4167) // San Francisco
    call.Types = append(call.Types, places.Cafe)
    call.Radius = 500

    resp, err := call.Do()
    if places.IsZeroResults(err) {
        fmt.Println("no results")
        return
    }
    if err != nil {
        panic(err)
    }

    results := resp.Results
    token := resp.NextPageToken

    for token != "" {
        time.Sleep(2 * time.Second) // Rate limit

        call.PageToken = token
        resp, err := call.Do()
        if err != nil {
            panic(err)
        }

        token = resp.NextPageToken
        results = append(results, resp.Results...)
    }

    for _, result := range results {
        fmt.Println(result.Name)
    }
}

Gotchas

  • This package is a work in progress. Not all API calls are implemented.
  • There is a short delay between when a NextPageToken is issued, and when it will become valid. Requesting the next page before it is available will return an INVALID_REQUEST response. Retrying the request with the same NextPageToken will return the next page of results.

What's done

  • Nearby Search
  • Place Details
  • Radar Search
  • Text Search

What's not done

  • Place Add
  • Place Autocomplete
  • Place Delete
  • Place Photos
  • Query Autocomplete
  • More Examples

FAQs

Package last updated on 15 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts