Home > Uncategorized > #Yelp API implemented in C# @yelpdev

#Yelp API implemented in C# @yelpdev


Yelp offer an API that allows you extract their data in JSON format; really cool, and a very useful resource. If you’re using C#, then you can use this code to access it (I’ve removed the access key and client id)

static void Main(string[] args)
var strUrl = “https://api.yelp.com/oauth2/token”;

var strPostData = “grant_type=client_credentials”;
strPostData += “&client_id=A-xxxxx”;
strPostData += “&client_secret=xxxxx”;
WebClient wc = new WebClient();
var strResponse = wc.UploadString(strUrl, strPostData);
var login = JavascriptDeserialize<OAuthLogin>(strResponse);

//var strSearch =
// “https://api.yelp.com/v3/businesses/search?term=bar&latitude=51&longitude=0.1&#8221;;

var strSearch = “https://api.yelp.com/v3/businesses/the-crow-and-gate-crowborough&#8221;;
wc.Headers.Add(“Authorization”, “Bearer ” + login.access_token);
var strSearchResponse = wc.DownloadString(strSearch);

public static T JavascriptDeserialize<T>(string json)
var jsSerializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue };
return jsSerializer.Deserialize<T>(json);

public class OAuthLogin
public string token_type { get; set; }
public int expires_in { get; set; }
public string access_token { get; set; }

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: