如何根据某些类别获取场地?
How to get venues based on certain categories?
应该是
https://api.foursquare.com/v2/venues/search?ll=40.7484,-73.9857&categoryId=4d4b7105d754a06374d81259&radius=100&limit=5&client_id=X&client_secret=X&v=20200101
4d4b7105d754a06374d81259 是食物的 categoryId
。
因此,我希望获得该类别的场所列表。
但我得到了各种各样的场地。
样本-
{
"meta": {
"code": 200
"requestId": "5f0d9ac6a0a468438f4f1b11"
}
"notifications": [
{
"type": "notificationTray"
"item": {
"unreadCount": 0
}
}
]
"response": {
"venues": [
{
"id": "43695300f964a5208c291fe3"
"name": "Empire State Building"
"contact": {
"phone": "+12127363100"
"formattedPhone": "+1 212-736-3100"
"twitter": "empirestatebldg"
"instagram": "empirestatebldg"
"facebook": "153817204635459"
"facebookUsername": "empirestatebuilding"
"facebookName": "Empire State Building"
}
"location": {
"address": "350 5th Ave"
"crossStreet": "btwn 33rd & 34th St"
"lat": 40.7485995507123
"lng": -73.98580648682452
"distance": 23
"postalCode": "10118"
"cc": "US"
"neighborhood": "Midtown Manhattan, New York, NY"
"city": "New York"
"state": "NY"
"country": "United States"
"formattedAddress": [
"0": "350 5th Ave (btwn 33rd & 34th St)"
"1": "New York, NY 10118"
"2": "United States"
]
}
"categories": [
"0": {
"id": "4bf58dd8d48988d130941735"
"name": "Building" # SEE HERE, ITS A BUILDING
"pluralName": "Buildings"
"shortName": "Building"
"icon": {
"prefix": "https://ss3.4sqi.net/img/categories_v2/building/default_"
"suffix": ".png"
}
"primary": true
}
]
"verified": true
"stats": {
"tipCount": 1165
"usersCount": 140228
"checkinsCount": 202739
}
"url": "https://www.esbnyc.com"
"venueRatingBlacklisted": true
"beenHere": {
"lastCheckinExpiredAt": 0
}
"venuePage": {
"id": "64514349"
}
"storeId": ""
"hereNow": {
"count": 0
"summary": "Nobody here"
"groups": [
]
}
"referralId": "v-1594727371"
"venueChains": [
]
"hasPerk": false
}
{
"id": "4bcca12bb6c49c7422169491"
"name": "86th Floor Observation Deck"
"contact": {
"phone": "+12127363100"
"formattedPhone": "+1 212-736-3100"
}
"location": {
"address": "350 5th Ave"
"crossStreet": "btwn 33rd & 34th Sts"
"lat": 40.74844544481811
"lng": -73.98568124187432
"labeledLatLngs": [
"0": {
"label": "display"
"lat": 40.74844544481811
"lng": -73.98568124187432
}
]
"distance": 5
"postalCode": "10118"
"cc": "US"
"city": "New York"
"state": "NY"
"country": "United States"
"formattedAddress": [
"0": "350 5th Ave (btwn 33rd & 34th Sts)"
"1": "New York, NY 10118"
"2": "United States"
]
}
"categories": [
"0": {
"id": "4bf58dd8d48988d165941735"
"name": "Scenic Lookout" # LOOK HERE, IT'S SCENIC LOOKOUT
"pluralName": "Scenic Lookouts"
"shortName": "Scenic Lookout"
"icon": {
"prefix": "https://ss3.4sqi.net/img/categories_v2/parks_outdoors/sceniclookout_"
"suffix": ".png"
}
"primary": true
}
]
"verified": true
"stats": {
"tipCount": 241
"usersCount": 21820
"checkinsCount": 23730
}
"beenHere": {
"lastCheckinExpiredAt": 0
}
"venuePage": {
"id": "64514350"
}
"hereNow": {
"count": 0
"summary": "Nobody here"
"groups": [
]
}
"referralId": "v-1594727371"
"venueChains": [
]
"hasPerk": false
}
{
"id": "5af44f23bcbf7a002ce0a18a"
"name": "Workday"
"contact": {
}
"location": {
"address": "350 5th Ave"
"lat": 40.748333
"lng": -73.985577
"labeledLatLngs": [
"0": {
"label": "display"
"lat": 40.748333
"lng": -73.985577
}
]
"distance": 12
"postalCode": "10001"
"cc": "US"
"city": "New York"
"state": "NY"
"country": "United States"
"formattedAddress": [
"0": "350 5th Ave"
"1": "New York, NY 10001"
"2": "United States"
]
}
"categories": [
"0": {
"id": "4bf58dd8d48988d124941735"
"name": "Office" # IT'S AN OFFICE
"pluralName": "Offices"
"shortName": "Office"
"icon": {
"prefix": "https://ss3.4sqi.net/img/categories_v2/building/default_"
"suffix": ".png"
}
"primary": true
}
]
"verified": false
"stats": {
"tipCount": 0
"usersCount": 12
"checkinsCount": 69
}
"venueRatingBlacklisted": true
"beenHere": {
"lastCheckinExpiredAt": 0
}
"hereNow": {
"count": 0
"summary": "Nobody here"
"groups": [
]
}
"referralId": "v-1594727371"
"venueChains": [
]
"hasPerk": false
}
{
"id": "5820b92252addb0cc786c053"
"name": "Expedia - New York City Office"
"contact": {
}
"location": {
"address": "350 5th Ave"
"lat": 40.748452
"lng": -73.985595
"labeledLatLngs": [
"0": {
"label": "display"
"lat": 40.748452
"lng": -73.985595
}
]
"distance": 10
"postalCode": "10118"
"cc": "US"
"city": "New York"
"state": "NY"
"country": "United States"
"formattedAddress": [
"0": "350 5th Ave"
"1": "New York, NY 10118"
"2": "United States"
]
}
"categories": [
"0": {
"id": "4bf58dd8d48988d124941735"
"name": "Office"
"pluralName": "Offices"
"shortName": "Office"
"icon": {
"prefix": "https://ss3.4sqi.net/img/categories_v2/building/default_"
"suffix": ".png"
}
"primary": true
}
]
"verified": false
"stats": {
"tipCount": 0
"usersCount": 15
"checkinsCount": 52
}
"venueRatingBlacklisted": true
"beenHere": {
"lastCheckinExpiredAt": 0
}
"hereNow": {
"count": 0
"summary": "Nobody here"
"groups": [
]
}
"referralId": "v-1594727371"
"venueChains": [
]
"hasPerk": false
}
{
"id": "59a44ba0e97dfb37208faf41"
"name": "JCDecaux, NA"
"contact": {
}
"location": {
"address": "350 Fifth Avenue, 73rd floor"
"lat": 40.74847232935598
"lng": -73.98566846513467
"labeledLatLngs": [
"0": {
"label": "display"
"lat": 40.74847232935598
"lng": -73.98566846513467
}
]
"distance": 8
"postalCode": "10001"
"cc": "US"
"city": "New York"
"state": "NY"
"country": "United States"
"formattedAddress": [
"0": "350 Fifth Avenue, 73rd floor"
"1": "New York, NY 10001"
"2": "United States"
]
}
"categories": [
"0": {
"id": "4bf58dd8d48988d124941735"
"name": "Office"
"pluralName": "Offices"
"shortName": "Office"
"icon": {
"prefix": "https://ss3.4sqi.net/img/categories_v2/building/default_"
"suffix": ".png"
}
"primary": true
}
]
"verified": false
"stats": {
"tipCount": 0
"usersCount": 21
"checkinsCount": 452
}
"venueRatingBlacklisted": true
"beenHere": {
"lastCheckinExpiredAt": 0
}
"hereNow": {
"count": 0
"summary": "Nobody here"
"groups": [
]
}
"referralId": "v-1594727371"
"venueChains": [
]
"hasPerk": false
}
]
"confident": false
}
}
那么,我到底做错了什么?应该如何做才能仅获得那些类别为“食品”或其某个子类别的场所?
你的参数有误。将 categoryID
替换为 categoryId
.
https://api.foursquare.com/v2/venues/search?ll=40.7484,-73.9857&categoryID=4d4b7105d754a06374d81259&radius=100&limit=5&client_id=X&client_secret=X&v=20200101
->
https://api.foursquare.com/v2/venues/search?ll=40.7484,-73.9857&categoryId=4d4b7105d754a06374d81259&radius=100&limit=5&client_id=X&client_secret=X&v=20200101
2 件事:
- 我读到 categoryId 应该优先于其他任何内容。我不确定它是否相关,但它对我有用。
- 你原来的半径只有100米url,我建议半径大一些,因为它可能也会影响结果。
对我来说,这个 url 非常有效:
https://api.foursquare.com/v2/venues/search?categoryId=4d4b7105d754a06374d81259&ll=40.7,-74&client_id=X&client_secret=X&v=20200101&radius=700&limit=20
应该是
https://api.foursquare.com/v2/venues/search?ll=40.7484,-73.9857&categoryId=4d4b7105d754a06374d81259&radius=100&limit=5&client_id=X&client_secret=X&v=20200101
4d4b7105d754a06374d81259 是食物的 categoryId
。
因此,我希望获得该类别的场所列表。
但我得到了各种各样的场地。
样本-
{
"meta": {
"code": 200
"requestId": "5f0d9ac6a0a468438f4f1b11"
}
"notifications": [
{
"type": "notificationTray"
"item": {
"unreadCount": 0
}
}
]
"response": {
"venues": [
{
"id": "43695300f964a5208c291fe3"
"name": "Empire State Building"
"contact": {
"phone": "+12127363100"
"formattedPhone": "+1 212-736-3100"
"twitter": "empirestatebldg"
"instagram": "empirestatebldg"
"facebook": "153817204635459"
"facebookUsername": "empirestatebuilding"
"facebookName": "Empire State Building"
}
"location": {
"address": "350 5th Ave"
"crossStreet": "btwn 33rd & 34th St"
"lat": 40.7485995507123
"lng": -73.98580648682452
"distance": 23
"postalCode": "10118"
"cc": "US"
"neighborhood": "Midtown Manhattan, New York, NY"
"city": "New York"
"state": "NY"
"country": "United States"
"formattedAddress": [
"0": "350 5th Ave (btwn 33rd & 34th St)"
"1": "New York, NY 10118"
"2": "United States"
]
}
"categories": [
"0": {
"id": "4bf58dd8d48988d130941735"
"name": "Building" # SEE HERE, ITS A BUILDING
"pluralName": "Buildings"
"shortName": "Building"
"icon": {
"prefix": "https://ss3.4sqi.net/img/categories_v2/building/default_"
"suffix": ".png"
}
"primary": true
}
]
"verified": true
"stats": {
"tipCount": 1165
"usersCount": 140228
"checkinsCount": 202739
}
"url": "https://www.esbnyc.com"
"venueRatingBlacklisted": true
"beenHere": {
"lastCheckinExpiredAt": 0
}
"venuePage": {
"id": "64514349"
}
"storeId": ""
"hereNow": {
"count": 0
"summary": "Nobody here"
"groups": [
]
}
"referralId": "v-1594727371"
"venueChains": [
]
"hasPerk": false
}
{
"id": "4bcca12bb6c49c7422169491"
"name": "86th Floor Observation Deck"
"contact": {
"phone": "+12127363100"
"formattedPhone": "+1 212-736-3100"
}
"location": {
"address": "350 5th Ave"
"crossStreet": "btwn 33rd & 34th Sts"
"lat": 40.74844544481811
"lng": -73.98568124187432
"labeledLatLngs": [
"0": {
"label": "display"
"lat": 40.74844544481811
"lng": -73.98568124187432
}
]
"distance": 5
"postalCode": "10118"
"cc": "US"
"city": "New York"
"state": "NY"
"country": "United States"
"formattedAddress": [
"0": "350 5th Ave (btwn 33rd & 34th Sts)"
"1": "New York, NY 10118"
"2": "United States"
]
}
"categories": [
"0": {
"id": "4bf58dd8d48988d165941735"
"name": "Scenic Lookout" # LOOK HERE, IT'S SCENIC LOOKOUT
"pluralName": "Scenic Lookouts"
"shortName": "Scenic Lookout"
"icon": {
"prefix": "https://ss3.4sqi.net/img/categories_v2/parks_outdoors/sceniclookout_"
"suffix": ".png"
}
"primary": true
}
]
"verified": true
"stats": {
"tipCount": 241
"usersCount": 21820
"checkinsCount": 23730
}
"beenHere": {
"lastCheckinExpiredAt": 0
}
"venuePage": {
"id": "64514350"
}
"hereNow": {
"count": 0
"summary": "Nobody here"
"groups": [
]
}
"referralId": "v-1594727371"
"venueChains": [
]
"hasPerk": false
}
{
"id": "5af44f23bcbf7a002ce0a18a"
"name": "Workday"
"contact": {
}
"location": {
"address": "350 5th Ave"
"lat": 40.748333
"lng": -73.985577
"labeledLatLngs": [
"0": {
"label": "display"
"lat": 40.748333
"lng": -73.985577
}
]
"distance": 12
"postalCode": "10001"
"cc": "US"
"city": "New York"
"state": "NY"
"country": "United States"
"formattedAddress": [
"0": "350 5th Ave"
"1": "New York, NY 10001"
"2": "United States"
]
}
"categories": [
"0": {
"id": "4bf58dd8d48988d124941735"
"name": "Office" # IT'S AN OFFICE
"pluralName": "Offices"
"shortName": "Office"
"icon": {
"prefix": "https://ss3.4sqi.net/img/categories_v2/building/default_"
"suffix": ".png"
}
"primary": true
}
]
"verified": false
"stats": {
"tipCount": 0
"usersCount": 12
"checkinsCount": 69
}
"venueRatingBlacklisted": true
"beenHere": {
"lastCheckinExpiredAt": 0
}
"hereNow": {
"count": 0
"summary": "Nobody here"
"groups": [
]
}
"referralId": "v-1594727371"
"venueChains": [
]
"hasPerk": false
}
{
"id": "5820b92252addb0cc786c053"
"name": "Expedia - New York City Office"
"contact": {
}
"location": {
"address": "350 5th Ave"
"lat": 40.748452
"lng": -73.985595
"labeledLatLngs": [
"0": {
"label": "display"
"lat": 40.748452
"lng": -73.985595
}
]
"distance": 10
"postalCode": "10118"
"cc": "US"
"city": "New York"
"state": "NY"
"country": "United States"
"formattedAddress": [
"0": "350 5th Ave"
"1": "New York, NY 10118"
"2": "United States"
]
}
"categories": [
"0": {
"id": "4bf58dd8d48988d124941735"
"name": "Office"
"pluralName": "Offices"
"shortName": "Office"
"icon": {
"prefix": "https://ss3.4sqi.net/img/categories_v2/building/default_"
"suffix": ".png"
}
"primary": true
}
]
"verified": false
"stats": {
"tipCount": 0
"usersCount": 15
"checkinsCount": 52
}
"venueRatingBlacklisted": true
"beenHere": {
"lastCheckinExpiredAt": 0
}
"hereNow": {
"count": 0
"summary": "Nobody here"
"groups": [
]
}
"referralId": "v-1594727371"
"venueChains": [
]
"hasPerk": false
}
{
"id": "59a44ba0e97dfb37208faf41"
"name": "JCDecaux, NA"
"contact": {
}
"location": {
"address": "350 Fifth Avenue, 73rd floor"
"lat": 40.74847232935598
"lng": -73.98566846513467
"labeledLatLngs": [
"0": {
"label": "display"
"lat": 40.74847232935598
"lng": -73.98566846513467
}
]
"distance": 8
"postalCode": "10001"
"cc": "US"
"city": "New York"
"state": "NY"
"country": "United States"
"formattedAddress": [
"0": "350 Fifth Avenue, 73rd floor"
"1": "New York, NY 10001"
"2": "United States"
]
}
"categories": [
"0": {
"id": "4bf58dd8d48988d124941735"
"name": "Office"
"pluralName": "Offices"
"shortName": "Office"
"icon": {
"prefix": "https://ss3.4sqi.net/img/categories_v2/building/default_"
"suffix": ".png"
}
"primary": true
}
]
"verified": false
"stats": {
"tipCount": 0
"usersCount": 21
"checkinsCount": 452
}
"venueRatingBlacklisted": true
"beenHere": {
"lastCheckinExpiredAt": 0
}
"hereNow": {
"count": 0
"summary": "Nobody here"
"groups": [
]
}
"referralId": "v-1594727371"
"venueChains": [
]
"hasPerk": false
}
]
"confident": false
}
}
那么,我到底做错了什么?应该如何做才能仅获得那些类别为“食品”或其某个子类别的场所?
你的参数有误。将 categoryID
替换为 categoryId
.
https://api.foursquare.com/v2/venues/search?ll=40.7484,-73.9857&categoryID=4d4b7105d754a06374d81259&radius=100&limit=5&client_id=X&client_secret=X&v=20200101
->
https://api.foursquare.com/v2/venues/search?ll=40.7484,-73.9857&categoryId=4d4b7105d754a06374d81259&radius=100&limit=5&client_id=X&client_secret=X&v=20200101
2 件事:
- 我读到 categoryId 应该优先于其他任何内容。我不确定它是否相关,但它对我有用。
- 你原来的半径只有100米url,我建议半径大一些,因为它可能也会影响结果。
对我来说,这个 url 非常有效:
https://api.foursquare.com/v2/venues/search?categoryId=4d4b7105d754a06374d81259&ll=40.7,-74&client_id=X&client_secret=X&v=20200101&radius=700&limit=20