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-fusion

v3.0.0

Published

Yelp Fusion API client for Node.js

Downloads

3,207

Readme

yelp-fusion

npm version Build Status codecov

Yelp Fusion API client for Node.js with Promises

Please refer to official Yelp documentation for request / response model details: https://www.yelp.com/developers/documentation/v3

V3 Breaking Changes

The following beta endpoints have been deprecated by the API since April 1, 2019. This library has been updated to reflect this change.

  • GET https://api.yelp.com/v3/businesses/matches/best
  • GET https://api.yelp.com/v3/businesses/matches/lookup

See https://www.yelp.com/developers/documentation/v3/business_match for more info

V2 Breaking Changes

  • yelp.accessToken() method is removed because OAuthV2 is being deprecated by the API. Use the new API Key in place of the token derived from client id and client secret. See https://www.yelp.com/developers/documentation/v3/authentication#where-is-my-client-secret-going

Install NPM Package

npm install yelp-fusion --save

Table of Contents

Business Endpoints:

Event Endpoints:

Category Endpoints:

Business Endpoints

Business Search

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.search({
  term: 'Four Barrel Coffee',
  location: 'san francisco, ca',
}).then(response => {
  console.log(response.jsonBody.businesses[0].name);
}).catch(e => {
  console.log(e);
});

Phone Search

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.phoneSearch({
  phone: '+14157492060'
}).then(response => {
  console.log(response.jsonBody.businesses[0].name);
}).catch(e => {
  console.log(e);
});

Transaction Search

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.transactionSearch('delivery', {
  location: 'san diego'
}).then(response => {
  console.log(response.jsonBody.businesses[0].name);
}).catch(e => {
  console.log(e);
});

Business Details

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.business('gary-danko-san-francisco').then(response => {
  console.log(response.jsonBody.name);
}).catch(e => {
  console.log(e);
});

Business Match

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.businessMatch({
  name: 'Pannikin Coffee & Tea',
  address1: '510 N Coast Hwy 101',
  address2: 'Encinitas, CA 92024',
  city: 'Encinitas',
  state: 'CA',
  country: 'US'
}).then(response => {
  console.log(response.jsonBody.businesses[0].id);
}).catch(e => {
  console.log(e);
});

Reviews

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.reviews('gary-danko-san-francisco').then(response => {
  console.log(response.jsonBody.reviews[0].text);
}).catch(e => {
  console.log(e);
});

Autocomplete

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.autocomplete({
  text: 'pizza'
}).then(response => {
  console.log(response.jsonBody.terms[0].text);
}).catch(e => {
  console.log(e);
});

Event Endpoints

Event Lookup

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.eventLookup("oakland-saucy-oakland-restaurant-pop-up").then(response => {
  console.log(response.jsonBody.description);
}).catch(e => {
  console.log(e);
});

Event Search

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.eventSearch({
  categories: 2,
  is_free: true,
  location: 'claremont, ca'
}).then(response => {
  console.log(response.jsonBody.events[0].name);
}).catch(e => {
  console.log(e);
});

Featured Event

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.featuredEvent({
  location: 'claremont, ca'
}).then(response => {
  console.log(response.jsonBody.description);
}).catch(e => {
  console.log(e);
});

Category Endpoints

All Categories

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.allCategories().then(response => {
  console.log(response.jsonBody.categories[0].alias);
}).catch(e => {
  console.log(e);
});

Category Details

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');

client.categoryDetails('3dprinting').then(response => {
  console.log(response.jsonBody.category.title);
}).catch(e => {
  console.log(e);
});

Advanced Request Options -- SocketTimeout

Socket Timeout will abort the request if the server doesn't complete the response within that time in milliseconds.

'use strict';

const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY', {
  socketTimeout: 5000
});

// or optionally
// client.options.socketTimeout = 5000;

Additionally, the options object support all fields defined here: https://nodejs.org/api/http.html#http_http_request_options_callback