Documentation ¶
Overview ¶
Package yelp provides a lightweight wrapper around the Yelp REST API. It supports authentication with OAuth 1.0, the Search API, and the Business API.
Index ¶
- type AuthOptions
- type BoundOptions
- type Business
- type Center
- type Client
- type Coordinate
- type CoordinateOptions
- type Deal
- type DealOption
- type GeneralOptions
- type GiftCertificate
- type GiftCertificateOptions
- type LocaleOptions
- type Location
- type LocationOptions
- type OptionProvider
- type Region
- type Review
- type SearchOptions
- type SearchResult
- type Span
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthOptions ¶
type AuthOptions struct { ConsumerKey string // Consumer Key from the yelp API access site. ConsumerSecret string // Consumer Secret from the yelp API access site. AccessToken string // Token from the yelp API access site. AccessTokenSecret string // Token Secret from the yelp API access site. }
AuthOptions provide keys required for using the Yelp API. Find more information here: http://www.yelp.com/developers/documentation.
type BoundOptions ¶
type BoundOptions struct { SwLatitude float32 // Southwest latitude of bounding box SwLongitude float32 // Southwest longitude of bounding box NeLatitude float32 // Northeast latitude of bounding box NeLongitude float32 // Northeast longitude of bounding box }
BoundOptions provides a way to describe a location that uses a set of coordinates. Location is specified by a bounding box, defined by a southwest latitude/longitude and a northeast latitude/longitude geographic coordinate. The bounding box format is defined as: bounds=sw_latitude,sw_longitude|ne_latitude,ne_longitude
type Business ¶
type Business struct { ID string // Yelp ID for this business Name string // Name of this business ImageURL string `json:"Image_URL"` // URL of photo for this business URL string // URL for business page on Yelp MobileURL string `json:"Mobile_URL"` // URL for mobile business page on Yelp Phone string // Phone number for this business with international dialing code (e.g. +442079460000) DisplayPhone string `json:"Display_phone"` // Phone number for this business formatted for display ReviewCount int `json:"Review_count"` // Number of reviews for this business Categories [][]string // Provides a list of category name, alias pairs that this business is associated with. The alias is provided so you can search with the category_filter. Distance float32 // Distance that business is from search location in meters, if a latitude/longitude is specified. Rating float32 // Rating for this business (value ranges from 1, 1.5, ... 4.5, 5) RatingImgURL string `json:"Rating_img_URL"` // URL to star rating image for this business (size = 84x17) RatingImgURLSmall string `json:"Rating_img_URL_small"` // URL to small version of rating image for this business (size = 50x10) RatingImgURLLarge string `json:"Rating_img_URL_large"` // URL to large version of rating image for this business (size = 166x30) SnippetText string `json:"Snippet_text"` // Snippet text associated with this business SnippetImageURL string `json:"Snippet_image_URL"` // URL of snippet image associated with this business Location Location // Location data for this business IsClaimed bool `json:"Is_claimed"` // Whether business has been claimed by a business owner IsClosed bool `json:"Is_closed"` // Whether business has been (permanently) closed MenuProvider string `json:"Menu_provider"` // Provider of the menu for this business MenuDateUpdated float32 `json:"Menu_date_updated"` // Last time this menu was updated on Yelp (Unix timestamp) Deals []Deal // Deal info for this business (optional: this field is present only if there’s a Deal) GiftCertificates []GiftCertificate `json:"Gift_certificates"` // Gift certificate info for this business (optional: this field is present only if there are gift certificates available) Reviews []Review // Contains one review associated with business }
Business information is returned in full from the business API, or shallow from the search API.
type Center ¶
type Center struct { Latitude float32 // Latitude position of map bounds center Longitude float32 // Longitude position of map bounds center }
Center provides the coordinate where the business is most likely to be located.
type Client ¶
type Client struct { Options *AuthOptions Client *http.Client }
Client manages all searches. All searches are performed from an instance of a client. It is the top level object used to perform a search or business query. Client objects should be created through the createClient API.
func New ¶
func New(options *AuthOptions, httpClient *http.Client) *Client
New will create a new yelp search client. All search operations should go through this API.
func (*Client) DoSearch ¶
func (client *Client) DoSearch(options SearchOptions) (result SearchResult, err error)
DoSearch performs a complex search with full search options.
func (*Client) DoSimpleSearch ¶
func (client *Client) DoSimpleSearch(term, location string) (result SearchResult, err error)
DoSimpleSearch performs a simple search with a term and location.
type Coordinate ¶
type Coordinate struct { Latitude float32 // Latitude of current location Longitude float32 // Longitude of current location }
Coordinate data is used with location information.
type CoordinateOptions ¶
type CoordinateOptions struct { Latitude null.Float // Latitude of geo-point to search near (required) Longitude null.Float // Longitude of geo-point to search near (required) Accuracy null.Float // Accuracy of latitude, longitude (optional) Altitude null.Float // Altitude (optional) AltitudeAccuracy null.Float // Accuracy of altitude (optional) }
CoordinateOptions are used with complex searches for locations. The geographic coordinate format is defined as: ll=latitude,longitude,accuracy,altitude,altitude_accuracy
type Deal ¶
type Deal struct { ID string // Deal identifier Title string // Deal title URL string // Deal URL ImageURL string `json:"image_URL"` // Deal image URL CurrencyCode string `json:"currency_code"` // ISO_4217 Currency Code TimeStart float32 `json:"time_start"` // Deal start time (Unix timestamp) TimeEnd float32 `json:"time_end"` // Deal end time (optional: this field is present only if the Deal ends) IsPopular bool `json:"is_popular"` // Whether the Deal is popular (optional: this field is present only if true) WhatYouGet string `json:"what_you_get"` // Additional details for the Deal, separated by newlines ImportantRestrictions string `json:"Important_restrictions"` // Important restrictions for the Deal, separated by newlines AdditionalRestrictions string `json:"Additional_restrictions"` // Deal additional restrictions Options []DealOption //Deal options }
Deal defines a set of special offerings from the business.
type DealOption ¶
type DealOption struct { Title string // Deal option title PurchaseURL string `json:"Purchase_URL"` // Deal option URL for purchase Price float32 // Deal option price (in cents) FormattedPrice string `json:"Formatted_price"` // Deal option price (formatted, e.g. "$6") OriginalPrice float32 `json:"Original_price"` // Deal option original price (in cents) FormattedOriginalPrice string `json:"Formatted_original_price"` // Deal option original price (formatted, e.g. "$12") IsQuantityLimited bool `json:"Is_quantity_limited"` // Whether the deal option is limited or unlimited RemainingCount float32 `json:"Remaining_count"` // The remaining deal options available for purchase (optional: this field is only present if the deal is limited) }
DealOption provides options are optionally included on a deal.
type GeneralOptions ¶
type GeneralOptions struct { Term string // Search term (e.g. "food", "restaurants"). If term isn’t included we search everything. Limit null.Int // Number of business results to return Offset null.Int // Offset the list of returned business results by this amount Sort null.Int // Sort mode: 0=Best matched (default), 1=Distance, 2=Highest Rated. If the mode is 1 or 2 a search may retrieve an additional 20 businesses past the initial limit of the first 20 results. This is done by specifying an offset and limit of 20. Sort by distance is only supported for a location or geographic search. The rating sort is not strictly sorted by the rating value, but by an adjusted rating value that takes into account the number of ratings, similar to a bayesian average. This is so a business with 1 rating of 5 stars doesn’t immediately jump to the top. CategoryFilter string // Category to filter search results with. See the list of supported categories. The category filter can be a list of comma delimited categories. For example, 'bars,french' will filter by Bars and French. The category identifier should be used (for example 'discgolf', not 'Disc Golf'). RadiusFilter null.Float // Search radius in meters. If the value is too large, a AREA_TOO_LARGE error may be returned. The max value is 40000 meters (25 miles). DealsFilter null.Bool // Whether to exclusively search for businesses with deals }
GeneralOptions includes a set of standard query options for using the search API. They are used along with a location based option to complete a search.
type GiftCertificate ¶
type GiftCertificate struct { ID string // Gift certificate identifier URL string // Gift certificate landing page URL ImageURL string `json:"Image_URL"` // Gift certificate image URL CurrencyCode string `json:"Currency_code"` // ISO_4217 Currency Code UnusedBalances string `json:"Unused_balances"` // Whether unused balances are returned as cash or store credit Options []GiftCertificateOptions // Gift certificate options }
GiftCertificate defines optional data available on Businesses.
type GiftCertificateOptions ¶
type GiftCertificateOptions struct { Price float32 // Gift certificate option price (in cents) FormattedPrice string `json:"Formatted_price"` // Gift certificate option price (formatted, e.g. "$50") }
GiftCertificateOptions can define a set of pricing options for a gift certificate.
type LocaleOptions ¶
type LocaleOptions struct {
// contains filtered or unexported fields
}
LocaleOptions provide additional search options that enable returning results based on a given country or locale.
type Location ¶
type Location struct { Coordinate Coordinate // Address for this business formatted for display. Includes all address fields, cross streets and city, state_code, etc. Address []string // Address for this business. Only includes address fields. DisplayAddress []string `json:"Display_address"` // Display address for the business. City string // City for this business StateCode string `json:"State_code"` // ISO 3166-2 state code for this business PostalCode string `json:"Postal_code"` // Postal code for this business CountryCode string `json:"Country_code"` // ISO 3166-1 country code for this business CrossStreets string `json:"Cross_streets"` // Cross streets for this business Neighborhoods []string // List that provides neighborhood(s) information for business GeoAccuracy float32 `json:"Geo_accuracy"` // Geo accuracy for the location. }
Location information defines the location of a given business.
type LocationOptions ¶
type LocationOptions struct { Location string // Specifies the combination of "address, neighborhood, city, state or zip, optional country" to be used when searching for businesses. (required) CoordinateOptions *CoordinateOptions // An optional latitude, longitude parameter can also be specified as a hint to the geocoder to disambiguate the location text. The format for this is defined as: ?cll=latitude,longitude }
LocationOptions enable specifing a Location by Neighborhood, Address, or City. The location format is defined: ?location=location
type OptionProvider ¶
type OptionProvider interface {
// contains filtered or unexported methods
}
OptionProvider provides a base level interface which all search option interfaces implement. It provides information that allows for easily mapping to querystring parameters for the search query.
type Region ¶
type Region struct { Span Span // Span of suggested map bounds Center Center // Center position of map bounds }
Region provides the location of a business obtained from search.
type Review ¶
type Review struct { ID string // Review identifier Rating float32 // Rating from 1-5 RatingImageURL string `json:"Rating_image_URL"` // URL to star rating image for this business (size = 84x17) RatingImageSmallURL string `json:"Rating_image_small_URL"` // URL to small version of rating image for this business (size = 50x10) RatingImageLargeURL string `json:"Rating_image_large_URL"` // URL to large version of rating image for this business (size = 166x30) Excerpt string // Review excerpt TimeCreated float32 `json:"Time_created"` // Time created (Unix timestamp) User User // User who wrote the review }
Review data contains a list of user reviews for a given Business (when queried using the Business API).
type SearchOptions ¶
type SearchOptions struct { GeneralOptions *GeneralOptions // standard general search options (filters, terms, etc) LocaleOptions *LocaleOptions // Results will be localized in the region format and language if supported. LocationOptions *LocationOptions // Use a location term and potentially coordinates to define the location CoordinateOptions *CoordinateOptions // Use coordinate options to define the location. BoundOptions *BoundOptions // Use bound options (an area) to define the location. }
SearchOptions are the top level search parameters used for performing searches. You can define multiple sets of options, and use them together. One (and only one) of LocationOptions, CoordinateOptions, or BoundOptions can be used at the same time.
type SearchResult ¶
type SearchResult struct { Region Region // Suggested bounds in a map to display results in Total int // Total number of business results Businesses []Business // The list of business entries (see Business) }
A SearchResult is returned from the Search API. It includes the region, the total number of results, and a list of matching businesses. The business objects returned by this query are shallow - they will not include deep results such as reviews.