npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yelp-api

v1.0.3

Published

A JavaScript interface for the Yelp Fusion API.

Downloads

15

Readme

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);
});

Featured Event API

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

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.