David H David H - 2 years ago 106
Javascript Question

Accessing tips for a venue using the FourSquare API with javascript

I'm trying to get a list of tips for each venue when performing a search using the explore endpoint of the

API to see popular venues nearby.

I'm getting a JSON response with venues in it and can access most of its properties. However, I don't know how to access the tips object that is returned and is part of the venue object.
This is the page on
describing the response:


This is what I'm using to access the venue object:

var venues = data['response']['groups'][0]['items'];

How do I access the tips object that is inside this?

Answer Source

Try this ;)

var items = data['response']['groups'][0]['items'];

var itemVenue = {}; /* It is an object item venue */
var itemTips = []; /* It is an array of item tips */

for(var item in items){
    itemVenue = items[item]['venue'];
    itemTips = items[item]['tips'];

    console.log('Venue Name: ', itemVenue.name);
    console.log('Item tips count: ', itemTips.length);        

    /* Here we can loop all tips of  this item */
    var itemTip = {}; /* tip is an object */
    for(var tip in itemTips){
        itemTip = itemTips[tip];
        console.log('Tip text: ', itemTip.text);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download