Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yelp-api

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yelp-api

A JavaScript interface for the Yelp Fusion API.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

yelp-api

npm version Build Status Dependency Status devDependency Status

This package provides a programmatic JavaScript interface for the Yelp Fusion API. The Yelp Fusion API Documentation can be viewed here.

In order to use this package, you must first get a Yelp Fusion API Key.

Installing

Simply use npm to install the package.

npm install yelp-api --save

Usage

The Yelp Fusion API has many API endpoints. Below shows how to query each of them. Reference links for each endpoint are also provided.

To query any of these endpoints, you must get your API Key from the Yelp Fusion Manage App page, located here.

Search API

This endpoint returns up to 1000 businesses based on the provided search criteria. More details here.

let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let params = [{ location: '20008' }];

// Call the endpoint
yelp.query('businesses/search', params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});

Phone Search API

This endpoint returns a list of businesses based on the provided phone number. More details here.

let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let params = [{ phone: '+14159083801' }];

// Call the endpoint
yelp.query('businesses/search/phone', params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});

Transaction Search API

This endpoint returns a list of businesses which support certain transactions. More details here.

let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let transactionType = 'delivery';
let params = [{ location: '20002' }];

// Call the endpoint
yelp.query(`transactions/${transactionType}/search`, params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});

Business API

This endpoint returns the detail information of a business. More details here.

let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let businessId = 'four-barrel-coffee-san-francisco';
let params = [{ locale: 'en_US' }];

// Call the endpoint
yelp.query(`businesses/${businessId}`, params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});

Business Match API

Thess endpoints let you match business data from other sources against our businesses based on some minimal information provided. To enable this endpoint, you must first join the Yelp Developer Beta Program. More details here.

Best Match
let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let params = [
  { name: 'Four Barrel Coffee' }, 
  { city: 'San Francisco' }, 
  { state: 'CA' },
  { country: 'US' }
];

// Call the endpoint
yelp.query('businesses/matches/best', params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});
Lookup
let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let params = [
  { name: 'Four Barrel Coffee' }, 
  { city: 'San Francisco' }, 
  { state: 'CA' },
  { country: 'US' }
];

// Call the endpoint
yelp.query('businesses/matches/lookup', params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});

Reviews API

This endpoint returns up to three reviews of a business ordered by Yelp's default sort order. More details here.

let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let params = [{ locale: 'en_US' }];
let businessId = 'four-barrel-coffee-san-francisco';

// Call the endpoint
yelp.query(`businesses/${businessId}/reviews`, params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});

Autocomplete API

This endpoint returns autocomplete suggestions for search keywords, businesses and categories, based on the input text. More details here.

let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let params = [{ text: 'Panuccis Pizza' }];

// Call the endpoint
yelp.query('autocomplete', params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});

Event Lookup API

This endpoint returns the detailed information of a Yelp event. To enable this endpoint, you must first join the Yelp Developer Beta Program. More details here.

let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let params = [{ locale: 'en_US' }];
let eventId = 'oakland-saucy-oakland-restaurant-pop-up';

// Call the endpoint
yelp.query(`events/${eventId}`, params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});

Event Search API

This endpoint returns events based on the provided search criteria. To enable this endpoint, you must first join the Yelp Developer Beta Program. More details here.

let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let params = [{ locale: 'en_US' }];

// Call the endpoint
yelp.query('events', params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});

This endpoint returns the featured event for a given location. To enable this endpoint, you must first join the Yelp Developer Beta Program. More details here.

let yelpAPI = require('yelp-api');

// Create a new yelpAPI object with your API key
let apiKey = 'YOUR_API_KEY';
let yelp = new yelpAPI(apiKey);

// Set any parameters, if applicable (see API documentation for allowed params)
let params = [{ location: '20002' }];

// Call the endpoint
yelp.query('events/featured', params)
.then(data => {
  // Success
  console.log(data);
})
.catch(err => {
  // Failure
  console.log(err);
});

Contributing

I would very much appreciate your contributions to this project Make any pull requests on the GitHub repo.

Authors

  • Nick Shallee - AureliaCasts

See also the list of contributors who participated in this project.

License (MIT)

Copyright 2018 Nick Shallee

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 07 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc