Skip to content

go-yelp is a #golang wrapper for the Yelp REST API. It lets you do all kinds of interesting things like searching for businesses, getting user comments and ratings, and handling common errors. The library is written Go.

License

TomDeVito/go-yelp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-yelp

go-yelp is a #golang wrapper for the Yelp REST API. It lets you do all kinds of interesting things like searching for businesses, getting user comments and ratings, and handling common errors. The library is written Go.

GoDoc

Build Status

Coverage Status

For more information, visit the Yelp REST API.

Getting Started

To install go-yelp, just use the go get command:

go get github.com/JustinBeckwith/go-yelp/yelp

When you're ready to start using the API, import the reference:

import "github.com/JustinBeckwith/go-yelp/yelp"

Authentication

All searches are performed through a client. To create a new client, you need provide a set of access keys necessary to use the V2 Yelp API. You can sign up for a Yelp developer account, and access your keys here:

Yelp | Manage Keys

Keep these keys safe! There are a variety of ways to store them. I chose to store them in a config.json file which is not checked into the repository. To run the tests, you can create your own config.json file:

{
	"ConsumerKey": "MY_CONSUMER_KEY",
	"ConsumerSecret":	"MY_CONSUMER_SECRET",
	"AccessToken":	"MY_ACCESS_TOKEN",
	"AccessTokenSecret":	"MY_ACCESS_TOKEN_SECRET"
}

The Search API

The simple search API enables searching for businesses with a term and a location (ex: coffee, Seattle). After you have your keys, create a client, and make a simple query:

import "github.com/JustinBeckwith/go-yelp/yelp"

client := yelp.New(options, nil)
result, err := client.DoSimpleSearch("coffee", "seattle")

For more complex searches, the DoSearch method allows for searching based on a combination of general search criteria, and advanced location options:

// Build an advanced set of search criteria that include 
// general options, and location specific options.
options := SearchOptions{
	GeneralOptions: &GeneralOptions{
		Term: "food",
	},
	LocationOptions: &LocationOptions{
		"bellevue",
		&CoordinateOptions{
			Latitude:  null.FloatFrom(37.788022),
			Longitude: null.FloatFrom(-122.399797),
		},
	},
}

// Perform the search using the search options
result, err := client.DoSearch(options)

The Business API

To directly search for a business by name, use the client.GetBusiness(...) method on the client:

client := yelp.New(options, nil)
result, err := client.GetBusiness("yelp-san-francisco")

License

This library is distributed under the MIT License found in the LICENSE file.

Questions?

Feel free to submit an issue on the repository, or find me at @JustinBeckwith

About

go-yelp is a #golang wrapper for the Yelp REST API. It lets you do all kinds of interesting things like searching for businesses, getting user comments and ratings, and handling common errors. The library is written Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%