Foursquare 场地 API 和结果数量,以更有效的方式?
我想问除了这些选项之外,还有没有更有效的方法可以得到50个以上的结果?
我正在使用当前的 foursquare api 进行场地搜索 https://developer.foursquare.com/docs/venues/search 。
我想要的是类似偏移选项的东西,以便获得更多结果,但似乎没有这样的选项。
有替代解决方案吗? 先感谢您。
I'd like to ask if there is a more efficient way to get more than 50 results besides these options?
- How do I get more locations?
- Foursquare Venue API & Number of Results
- and this, which is for the old API Foursquare API nearByVenue service issue
I'm using the current foursquare api for the venue search https://developer.foursquare.com/docs/venues/search .
What I'd like is something like an offset option, in order to get more results, but it seems that there isn't such an option.
Is there an alternative solution?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您应该使用以偏移量和限制作为参数的场地探索,
场地探索为您提供了totalResults,您可以使用此响应来计算分页中所需的页数,
例如假设totalResults为90(注意偏移量和限制参数值)
在第一个请求中:
https://api.foursquare.com/v2/venues/explore?client_id=client_id&client_secret=client_secret&v=20150825&near=city_name&categoryId=category_id&intent=browse&offset=0& 第二个请求中的limit=30
:
https://api.foursquare.com/v2/venues/explore?client_id=client_id&client_secret=client_secret&v=20150825&near=city_name&categoryId=category_id&intent=browse&offset=30& 第三个请求中的limit=30
:
https://api.foursquare.com/v2/venues/explore?client_id=client_id&client_secret=client_secret&v=20150825&near=city_name&categoryId=category_id&intent=browse&offset=60& limit=30
对于 90 个结果,您可以获得所有记录以上三个要求
you should use venues explore with offset and limit as paramters,
venues explore gives you totalResults and you can use this response to calculate number of pages you need in paginate
for example assume totalResults is 90(pay attention at offset and limit parametr value )
in first request:
https://api.foursquare.com/v2/venues/explore?client_id=client_id&client_secret=client_secret&v=20150825&near=city_name&categoryId=category_id&intent=browse&offset=0&limit=30
in second request:
https://api.foursquare.com/v2/venues/explore?client_id=client_id&client_secret=client_secret&v=20150825&near=city_name&categoryId=category_id&intent=browse&offset=30&limit=30
in third request:
https://api.foursquare.com/v2/venues/explore?client_id=client_id&client_secret=client_secret&v=20150825&near=city_name&categoryId=category_id&intent=browse&offset=60&limit=30
for 90 results you can get all records with above three request
实际上这里没有提到另一个选项(虽然不是分页)
使用(实验性的?)categoryId 过滤器。
您可以使用不同的类别 ID 多次搜索单个点 (ll),从而获得许多结果(由于场地可能有多个类别,因此会出现一些重复结果)。
因此,您可以在同一地点搜索“美食”场所和“夜生活”场所,在 50 个结果中获得 100 个结果。正如所说,这是 100 个结果,但不是唯一的结果,可能会重复。我认为这比尝试使用浏览半径更有效。
不是分页,但会比普通搜索提供更多结果 - 即使在城市地区通常也足够了。
但是,是的,通过某种方式在单个点上提取超过 50 个数据是不可能的,但可能会很好:)
There is actually another option not mentioned here (not pagination though)
Using the (experimental?) categoryId filter.
You can search for a single point (ll) a few times with different category ids, giving you many results (some duplicates as venues can have more than one category).
So you can search for 'Food' venues and 'Nightlife' venues at the same place, getting 100 results in stand of 50.. as said it is 100 results, but not unique results, could be duplicates. I think that is more efficient then trying to play around with the browse radius thing.
Not pagination, but will give a lot more results than a normal search - usually enough even in urban areas.
But yea, having some sort of way to extract more than 50 on a single point is not possible, but could be nice :)
恐怕不是。目前没有分页,为了找到更多场地,您需要像突出显示的答案一样移动搜索区域。我同意,不过分页会很方便!
Afraid not. Currently there is no pagination, in order to find more venues you need to move your search area around as in the answers you highlighted. I agree, pagination would be handy though!
对于资源管理器端点,这对我有用:例如,如果返回的最大结果数是 100,则只需在下一次调用中使用 offset=100,这会为您提供从 100(偏移量)开始的下 100 个结果。迭代(例如使用 while 循环)并不断将偏移量增加 100,直到达到总数或结果(在 api 中返回totalResults)。
我的第一篇堆栈溢出帖子,试图尽可能清楚地回答
For the explorer endpoint this worked for me: If the maximum number of results that is returned for instance is 100, just use offset=100 in the next call which gives you the next 100 results starting from 100 (the offset). Iterate (e.g. using while loop) and keep increasing offset by 100 until you reach the total number or results (which is returned in in the api for totalResults).
My first stack overflow post, tried to answer as clearly as possible
上面的代码非常适合我,其中
ven_num
变量是呼叫某个社区的场所所需的限制the code above has worked perfectly with me, where
ven_num
variable is the desired limit for calling venues in a certain neighborhood