Coder Social home page Coder Social logo

yelp / yelp-api Goto Github PK

View Code? Open in Web Editor NEW
580.0 81.0 1.1K 1.59 MB

Examples of code using our v2 API

Home Page: http://yelp.com/developers

License: MIT License

C# 13.92% Java 10.10% Shell 0.31% Objective-C 13.73% PHP 47.44% Batchfile 0.32% Ruby 0.24% Haskell 3.21% Rust 2.69% R 4.14% Swift 1.87% Perl 2.03%
api

yelp-api's Introduction

Yelp API

As of June 30, 2018, the API v2 has been discontinued and v2 endpoints no longer work. It has been replaced by Yelp's Fusion API. This github repository is archived. Read more.

The Yelp API gives you access to search for over 50,000,000 businesses in 32 countries. We provide a search, phone search, and business API to help integrate Yelp into your app.

For complete documentation and instructions on how to authenticate visit the developer site.

For problems with the API, the samples, or just questions, please open an issue on this project.

Clientlibs

Official

iOS

The official iOS client library is yelp-ios.

Android

The official Android client library is yelp-android and will help integrate Yelp with Android phones.

Python

For the official Python client library, we have yelp-python.

Ruby

For the official Ruby client library, we have yelp-ruby. The sample Rails app will show you how to get setup if you need a little more guidance.

Unofficial

Please note that we do not provide support for any of the unofficial libraries, these are provided to you as-is. If you have any problems with them, please open an issue on the project itself.

C#

yelpsharp

Go

go-yelp

Node.js

node-yelp

PHP

yelp-php

Swift

ios_yelp_swift

yelp-api's People

Contributors

dan98765 avatar dennyglee avatar eklitzke avatar gabriel avatar gchin avatar jglukasik avatar kgodey avatar mathisonian avatar mittonk avatar paulirish avatar rggammon avatar samdelagarza avatar silentsound avatar ssheldon avatar stevenmaguire avatar tadaspocius avatar thibaudrobelain avatar tomelm avatar virgytam avatar watterso avatar will-ship-it avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yelp-api's Issues

Python v2 example is broken

Requesting a URL with zero query parameters results in "Invalid Signature" errors. Happens in both business.py and search.py

C# example is double encoding the values

In Visual Studio 2013, the following line of code appears to be incorrect:
query[queryParam.Key] = SimpleOAuth.Utilities.UrlHelper.Encode(queryParam.Value);

I go the sample to work by replacing the above line of code with the following line of code:
query[queryParam.Key] = queryParam.Value;

C# API returns HTTP 400 error

I just downloaded, extracted the folder, built the API and ran the exe file as described, with similar arguments, and it does not work. Is there another setup step needed or is the library not working for some reason?

I'm new to C#.

python example fails with HTTP error 400

When running the python example on OSX, I get the error:
Encountered HTTP error 400. Abort program.

Digging in further, it appears that the issue is under def request when it is making the initial connection.

PHP phone search

PHP phone does not search via the phone number

the below should resolve that for uk numbers

$API_HOST = 'api.yelp.com';
$DEFAULT_TERM = '';
$DEFAULT_LOCATION = 'GB';
$SEARCH_PHONEPATH = '/v2/phone_search';

function search_phone($term, $location) {
    $url_params = array();

    $url_params['phone'] = $term ?: $GLOBALS['DEFAULT_TERM'];
    $url_params['cc'] = $location?: $GLOBALS['DEFAULT_LOCATION'];
    $search_path = $GLOBALS['SEARCH_PHONEPATH'] . "?" . http_build_query($url_params);
    return request($GLOBALS['API_HOST'], $search_path);
}

PHP Example throws INVALID_OAUTH_CREDENTIALS

When running sample.php inside terminal, I get the following code:
stdClass Object
(
[error] => stdClass Object
(
[text] => The OAuth credentials are invalid
[id] => INVALID_OAUTH_CREDENTIALS
)

)

Anything to be done to fix this? I'm struggling to implement this API in a current project.

js example help

I'm trying to integrate the js example with Drupal 6, which has a limits my jQuery to version 1.2.6. jQuery 1.2.6 seems to ignore the jsonpCallback property of the $.ajax object, leaving the value of the parameter randomized. This causes Yelp's API server to send back a 400: Bad Request response, I assume because the signatures don't match.

Is there a way to work around this problem?

php v2 example broken

In trying the example, i get the following error:

[sijis@host php (master)]$ php -f example.php 
PHP Warning:  require_once(lib/Oauth.php): failed to open stream: No such file or directory in /home/sijis/yelp-api/v2/php/example.php on line 9
PHP Stack trace:
PHP   1. {main}() /home/sijis/yelp-api/v2/php/example.php:0
PHP Fatal error:  require_once(): Failed opening required 'lib/Oauth.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/sijis/yelp-api/v2/php/example.php on line 9
PHP Stack trace:
PHP   1. {main}() /home/sijis/yelp-api/v2/php/example.php:0

After a little poking around, I realized that the path to Oauth.php is correct but the file is actually OAuth.php (case sensitive) and thus why I got the error.

Here's the patch:

diff --git a/v2/php/example.php b/v2/php/example.php
index 4a8d6af..8ecec47 100644
--- a/v2/php/example.php
+++ b/v2/php/example.php
@@ -6,7 +6,7 @@
 
 
 // Enter the path that the oauth library is in relation to the php file
-require_once ('lib/Oauth.php');
+require_once ('lib/OAuth.php');
 
 // For example, request business with id 'the-waterboy-sacramento'
 $unsigned_url = "http://api.yelp.com/v2/business/the-waterboy-sacramento";

C# implementation generates invalid signature, as it does not consider base string

The C# implementation, when my key information is subbed in and ran, gives the following error:

REQUEST:

GET http://api.yelp.com/v2/search/?term=thai&location=Seattle%252C%2520WA&limit=3 HTTP/1.1
Authorization: OAuth oauth_consumer_key="GzeIA9K2LG30d2zVM7FVow",oauth_nonce="b9c6e0f655e34e4782084457b0d82b07",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1404704198",oauth_token="oxiSh7zzELUi_dWMhLxeytbPcc5zF06w",oauth_version="1.0",oauth_signature="WpUFDczUNLM6u032WASz%2BpF9vlE%3D"
Host: api.yelp.com

Connection: Keep-Alive

RESPONSE:

HTTP/1.1 400 Bad Request
Date: Mon, 07 Jul 2014 03:36:35 GMT
Server: Apache
X-Node: web72-r7-sfo1, api_com
Cache-Control: private
Set-Cookie: bse=3462b728c385176c78cab0e1c8a67842; Domain=.yelp.com; Path=/; HttpOnly
Content-Length: 488
Vary: User-Agent
Content-Type: application/json; charset=UTF-8
X-Mode: rw
X-Proxied: lb1

{"error": {"text": "Signature was invalid", "id": "INVALID_SIGNATURE", "description": "Invalid signature. Expected signature base string: GET\u0026http%3A%2F%2Fapi.yelp.com%2Fv2%2Fsearch%2F\u0026limit%3D3%26location%3DSeattle%252C%2520WA%26oauth_consumer_key%3DGzeIA9K2LG30d2zVM7FVow%26oauth_nonce%3Db9c6e0f655e34e4782084457b0d82b07%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1404704198%26oauth_token%3DoxiSh7zzELUi_dWMhLxeytbPcc5zF06w%26oauth_version%3D1.0%26term%3Dthai"}}

This appears to be because the C# app does not encode a base string - indeed, the response from the Yelp API seems to indicate this. This SO thread provides more information:

http://stackoverflow.com/questions/9330004/invalid-signature-for-signing-requests-to-the-flickr-api-simulation-in-console

Is there a working implementation floating around or should I hack around with this one?

Publish on composer

In order to manager dependencies in PHP project it would be great if we can publish it on composer

PHP:INVALID_SIGNATURE

i got a response code as "Expired timestamp: given 1324343351 and now 1324343681 has a greater difference than threshold 300 )", so i changed class OAuthServer:protected $timestamp_threshold = 600(Before is 300),but it do not work.My meaning was it still demonstrated "given 1324343351 and now 1324343681 has a greater difference than threshold 300 "
Those who let me puzzled is the OAuthException code is :
throw new OAuthException(
"Expired timestamp, yours $timestamp, ours $now"
);
but what demonstrated is "given 1324343351 and now 1324343681 has a greater difference than threshold 300"

Convert all examples to use HTTPS

SSL is good. Keeps private stuff private.

The Yelp API is available using https, but not all examples use it all the time. They should!

A few obvious flags:

$ ack -a 'http://api'
v2/csharp/YelpAPI/Program.cs
59:        private const string API_HOST = "http://api.yelp.com";

v2/perl/search.pl
18:sub user_url { 'http://api.yelp.com/v2/search?term=food&location=San+Francisco' }

v1/googlemaps_example/businessSearch.html
60:        var URL = "http://api.yelp.com/" +

We should audit the examples, find any that use plain http, and upgrade them to https.

Add License

There does not appear to be a license file indicating under what terms the source code can be reused.

Need JavaScript example

We used to have a JS example, but it was removed for security reasons in #17 .

We should have a JS example that doesn't expose OAuth credentials as publicly. Doesn't need to be super-high-security, but shouldn't be downright dangerous to emulate.

I wonder if Node.js or something similar might be close enough to fill this niche?

Add README to iOS Project

A README explaining how to use the iOS oAuth library would be helpful. Right now you basically need to guess as to where to put the oAuth key (OAuthTest.m btw)

How do I get ratings from the business response object?

This is my code.

params = {
    'lang': 'en'
}
response2 = c.get_business('alice-bakery-and-confectionary-north-wales-2', **params)
print response2.business.rating_img_url, response2.business.location.address, response2.business.name, response2.business.display_phone, response2.business.review_count

I am getting the following error.
AttributeError: 'Business' object has no attribute 'rating_img_url'

I am referring to the following documentation.
https://www.yelp.com/developers/documentation/v2/business

Question about what we can do with Yelp API

Hi there,

I have little/no programming experience so please excuse my non-technical language, or if I posted this in the wrong place.

I am looking for a way to search Yelp for businesses that are closed. I don't see a way to do this at Yelp.com, but is this something that can be done through the Yelp API - if I hire someone to write a custom program?

Thanks,

Mike

HTTP request failed.

HTTP request failed, got The remote server returned an error: (400) Bad Request.
, abort program.

Python sample fails when business ID contains special characters

Hello!

Using the Search API python sample to search for restaurants sometimes fails with the error:

Traceback (most recent call last):
File "search-yelp.py", line 170, in
main()
File "search-yelp.py", line 164, in main
query_api(input_values.term, input_values.location)
File "search-yelp.py", line 149, in query_api
response = get_business(business)
File "search-yelp.py", line 119, in get_business
return request(API_HOST, business_path)
File "search-yelp.py", line 63, in request
url = 'http://{0}{1}?{2}'.format(host, path, encoded_params.encode('utf8'))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 16: ordinal not in range(128)

This happens because business IDs can contain special characters like "é", which cannot be put into URLs before being decoded. For example, in this instance the specific cause of failure is trying to access the API endpoint "/v2/business/café-pro-bono-palo-alto-3".

This is easily fixed by changing line 59 to:

url = 'http://{0}{1}?{2}'.format(host, urllib.urlencode(path), encoded_params)

Could you provide more information in the API?

Hi Yelp,

I am using Yelp API in an Android App, it works great. The only problem is, it only provides few images and reviews of a business. I want to get all the images and reviews, can you provide these information? Just want to know, thank you!

Objective-C OAuth library does not use ARC

@MatthewHendy writes in #32 :

In my build settings the 'Objective-C Automatic Reference Counting' flag is set to yes, yet I have 94 errors relating to 'release' , 'autorelease' , ARC restrictions, and ARC casting rules. I copied this code into my project and double checked my ARC flag and it doesn't run. If I turn off ARC then it runs fine.

First step: Repro and find a few of these 94 errors.

@MatthewHendy: Do you have 2-3 example errors we could look at?

ARC

Is there a quick way to implement this in a project that uses ARC? I pasted it into my app, and got 41 issues related to ARC because the code is full of retain / release / auto retain.

Interruption of service?

I've been getting slow or non-reponses from the Yelp API today. I also received one instance of "INTERNAL_ERROR" response to my query. I'm connecting using the Scribe library provide in the example code. Prior to today I haven't had any issues. Is something going on with the service? Thanks

Here's some of the error log:
` Process: com.[...], PID: 26642
java.lang.RuntimeException: An error occurred while executing doInBackground()
[...]
Caused by: org.scribe.exceptions.OAuthConnectionException: There was a problem while creating a connection to the remote service.
at org.scribe.model.Request.send(Request.java:70)
at org.scribe.model.Request.send(Request.java:76)
at com.[...].YelpAPI.sendRequestAndGetResponse(YelpAPI.java:120)
at com.[...].YelpAPI.searchForBusinessesByLocation(YelpAPI.java:83)
at
[...]
Caused by: java.net.ConnectException: failed to connect to api.yelp.com/104.16.57.23 (port 443): connect failed: ENETUNREACH (Network is unreachable)
at libcore.io.IoBridge.connect(IoBridge.java:124)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
[...]

Caused by: android.system.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)
at libcore.io.Posix.connect(Native Method)
at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:111)
at libcore.io.IoBridge.connectErrno(IoBridge.java:137)
[...] `

Yelp Deals

Hi, I'm not sure how the yelp deals option works. It says that it takes a boolean value. I'm using python - I entered in a value of "1" and "true" different times, expecting the api to give me a business with a yelp deal. It didn't. It keeps returning the same business. I'm not sure whats going on... Also - the result never just tells me if the business has a deal or not - the only way I figured it out was because the it said that the business wasn't claimed. Hence, deals are not possible. Someone help me!!!

Expired timestamp

on IOS 4.2.1, the response for the yelp data is

{
"error": {
"text": "Signature was invalid",
"id": "INVALID_SIGNATURE",
"description": "Expired timestamp: given 1326837029 and now 1326841425 has a greater difference than threshold 300"
}
}

on an IOS 5 device, running the same code, everything is fine.

Rating as search parameter

Is it possible to create a search with rating as one of the parameters?

Example:
parameters.push(['rating', rating]);

Add README to iOS Project

A README explaining how to use the iOS oAuth library would be helpful. Right now you basically need to guess as to where to put the oAuth key (OAuthTest.m btw).

The project is also non-ARC and not easily integrated into any iOS project. Would be nice to see an ARC update, or a recommended CocoaPod instead.

Updating search term language

I think it would be helpful to update the documentation to clarify that the term in the search parameters can be fed the name of the restaurant you're looking for. This saved me a lot of time once I realized it takes more than generic terms like "dinner" etc.

Just a suggestion, thanks for the great work!

js v2 example for jquery 1.5.1

Hi,

Changing the jquery version from 1.4.4 to 1.5.1 breaks the example at yelp-api/v2/js/example.html.

The culprit seems to be the '_' parameter that gets automatically added to the request, which can be disabled by adding a "cache: true," to the $.ajax() call.

Thanks,

Bo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.