knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE, comment = "")
An R library for the Yelp Fusion API
devtools::install_github("OmaymaS/yelpr")
From yelp authentication guide :
"In order to set up your access to Yelp Fusion API, you need to create an app with Yelp. This app represents the application you'll build using our API and includes the credentials you'll need to gain access. Here are the steps for creating an app:
To use the package, it is required to have an API key as clarified in the previous section. In the following examples, we will read the key once from a saved file. You could create your own file or assign the key directly in the code.
# load yelpr package library(yelpr)
## assign app key key <- readLines("yelp_app_key.txt")
The available functions are:
business_search()
business_lookup_id()
business_search_phone()
business_search_review()
business_search_autocomplete()
business_search_transaction()
business_match_name()
For example business_search()
returns up to 1000 businesses based on the provided search criteria. The location OR (longitude+latitude) are required, plus Additional optional parameters.
Here we will retrieve the first 5 results in new york with the term 'chinese'
# search businesses with keyword 'chinese' in 'New York' business_ny <- business_search(api_key = key, location = 'New York', term = "chinese", limit = 5)
The function returns a list, so we can extract the details of the businesses business_ny$businesses
:
business_ny$businesses
The available functions are:
For example, event_search_featured
returns the featured event, chosen by Yelp's community managers, for a given location. The location OR (longitude+latitude) are required.
Here we'll get the details of featured event in the given location using the longitude and latitude.
# search featured event in the given location coordinates event <- event_search_featured(api_key = key, longitude = "-74.01385", latitude = "40.70387")
And the event name event$name
would be:
r event$name
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.