scott4arrows
scott4arrows

Reputation: 80

venue search api returns duplicate venue with incorrect lat/lon

I performed a venue search which returned a duplicate venue. The duplicate venue was identical except for venue id and lat/lon info. Perform the same search at foursquare.com and duplicate is not shown. How can I exclude the duplicate?

Here is API call (minus secret): https://api.foursquare.com/v2/venues/search?ll=38.468807,-77.372589&query=starbucks

Results:

{
    meta: {
        code: 200
    }
    notifications: [
    {
        type: "notificationTray"
        item: {
            unreadCount: 0
        }
    }]
    response: {
        venues: [
        {
            id: "4e4dc886bd41b76bef93082e"
            name: "Starbucks Coffee"
            contact: {
                phone: "5407209145"
                formattedPhone: "(540) 720-9145"
            }
            location: {
                address: "1495 Stafford Market Pl"
                lat: 38.47310969662029
                lng: -77.38591645407749
                distance: 1256
                postalCode: "22556"
                city: "Stafford"
                state: "VA"
                country: "United States"
            }
            categories: [
            {
                id: "4bf58dd8d48988d1e0931735"
                name: "Coffee Shop"
                pluralName: "Coffee Shops"
                shortName: "Coffee Shop"
                icon: {
                    prefix: "https://foursquare.com/img/categories/food/coffeeshop_"
                    sizes: [ 32 44 64 88 256 ]
                    name: ".png"
                }
                primary: true
            }]
            verified: false
            stats: {
                checkinsCount: 13
                usersCount: 11
                tipCount: 0
            }
            specials: {
                count: 0
                items: [ ]
            }
            hereNow: {
                count: 0
            }
        },
        {
            id: "4b8dd66ef964a520071033e3"
            name: "Starbucks"
            contact: {
                phone: "5407209145"
                formattedPhone: "(540) 720-9145"
            }
            location: {
                address: "1495 Stafford Market Place"
                crossStreet: "Garrisonville Road"
                lat: 38.470214117289444
                lng: -77.41142749786377
                distance: 3388
                postalCode: "22554"
                city: "Stafford"
                state: "VA"
                country: "United States"
            }
            categories: [
            {
                id: "4bf58dd8d48988d1e0931735"
                name: "Coffee Shop"
                pluralName: "Coffee Shops"
                shortName: "Coffee Shop"
                icon: {
                    prefix: "https://foursquare.com/img/categories/food/coffeeshop_"
                    sizes: [ 32 44 64 88 256 ]
                    name: ".png"
                }
                primary: true
            }]
            verified: true
            stats: {
                checkinsCount: 1885
                usersCount: 522
                tipCount: 14
            }
            url: "http://www.starbucks.com/"
            specials: {
                count: 0
                items: [ ]
            }
            hereNow: {
                count: 0
            }
            menu: {
                url: "https://foursquare.com/v/starbucks/4b8dd66ef964a520071033e3/menu"
                mobileUrl: "https://foursquare.com/v/4b8dd66ef964a520071033e3/device_menu"
            }
        },
        {
            id: "4d87c7bba98841bd5eaf3055"
            name: "Starbucks"
            contact: {
                phone: "5407209145"
                formattedPhone: "(540) 720-9145"
                twitter: "starbucks"
            }
            location: {
                address: "1495 Stafford Market Place"
                lat: 38.50188672
                lng: -77.37500964
                distance: 3688
                postalCode: "22556"
                city: "Stafford"
                state: "Virginia"
                country: "United States"
            }
            categories: [ ]
            verified: true
            stats: {
                checkinsCount: 17
                usersCount: 11
                tipCount: 0
            }
            specials: {
                count: 0
                items: [ ]
            }
            hereNow: {
                count: 0
            }
        }
    }
}

The second venue, id=4b8dd66ef964a520071033e3, is the actual. The other 2 are duplicates.

Upvotes: 1

Views: 1005

Answers (1)

louielouie
louielouie

Reputation: 14941

I would rule out the first result because it has the key/value "verified: false". Verified: true means that the owner has claimed it.

I would then note that the second result is superior over the third one because: 1. It has a category 2. The checkinsCount is higher. In this case, much higher. 3. It has a website link (url) 4. It has menu links 5. The location has a cross-street

Basically, if you created an algorithm to rank the completeness of a "compact venue" result, you could approximate Foursquare.com's uniqueness. I would add up all the amount of the different attributes present and give extra weight to the verified attribute, the number of checkins and tips (which tell you if people are using that venue). I'd probably use the name, street address and possibly phone number as the key. Zip code seems like it'd be a good one to use too, but in this case you'll notice that it is incorrect for the result which should be the canonical one.

A good reference doc that I used to help answer this is: https://developer.foursquare.com/docs/responses/venue

Upvotes: 2

Related Questions