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
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
npm install yelp-fusion --save
Business Endpoints:
Event Endpoints:
Category Endpoints:
'use strict';
const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');
client.businessSearch({
term: 'Four Barrel Coffee',
location: 'san francisco, ca',
}).then(response => {
console.log(response.jsonBody.businesses[0].name);
}).catch(e => {
console.log(e);
});
'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);
});
'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);
});
'use strict';
const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');
const businessID = 'gary-danko-san-francisco';
client.business(businessID).then(response => {
console.log(response.jsonBody.name);
}).catch(e => {
console.log(e);
});
'use strict';
const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');
// matchType can be 'lookup' or 'best'
client.businessMatch('lookup', {
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);
});
'use strict';
const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');
const businessID = 'gary-danko-san-francisco';
client.reviews(businessID).then(response => {
console.log(response.jsonBody.reviews[0].text);
}).catch(e => {
console.log(e);
});
'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);
});
'use strict';
const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');
const eventID = "oakland-saucy-oakland-restaurant-pop-up";
client.eventLookup(eventID).then(response => {
console.log(response.jsonBody.description);
}).catch(e => {
console.log(e);
});
'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);
});
'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);
});
'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);
});
'use strict';
const yelp = require('yelp-fusion');
const client = yelp.client('YOUR_API_KEY');
const categoryAlias = '3dprinting';
client.categoryDetails(categoryAlias).then(response => {
console.log(response.jsonBody.category.title);
}).catch(e => {
console.log(e);
});
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