Code Monkey home page Code Monkey logo

go-yelp's Introduction

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

go-yelp's People

Contributors

hariharan-uno avatar justinbeckwith avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

go-yelp's Issues

Exposing vendored packages

I'm getting this issue when using this package: http://stackoverflow.com/questions/38091816/packages-type-cannot-be-used-as-the-vendored-packages-type

It seems that because go-yelp uses the null package in defining structs, the vendored package is exposed and causing this issue. After thinking about it and talking with others, two potential solutions seem to be either 1) not vendoring the package at all, or 2) keeping the vendored package, but create public functions that can be accessed to create the structs defined in go-yelp.

Do you have any thoughts?

yelp v3 fusion

Hi,

are there any plans in supporting yelp api v3 (called fusion)?

Best, Sven

Get rid of underscores in variable names

Right now the struct variable names match exactly to the JSON schema. Feedback was to get rid of underscores in variable names, and use the json mapping feature to map.

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.