knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE, comment = "")

An R library for the Yelp Fusion API

Installation

devtools::install_github("OmaymaS/yelpr")

API Authentication

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:

Usage

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")

Business Endpoint

The available functions are:

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

Events Endpoint

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



OmaymaS/yelpr documentation built on May 15, 2019, 3:24 p.m.