stackexchange-api

StackExchange REST API - get users from specific country


Is there a way to filter users returned by /users/ endpoint to get users with some "location" value only?
If so, in order to correctly filter locations like "New York, United States" by "United States", can "users" be filtered by "location" that contains some string as a substring?

Is there a documentation describing what fields of the "user" object could be used for filtering and how (if any)?


Solution

  • No, you can't query the /Users endpoint with a location.

    The only available query parameters are documented here and are limited to:

    inname operates on the userdisplayname. There is no inlocation parameter so you're out of luck. The only option left is fetch all users and then filter locally but fetching all users is hardly viable.

    An alternative might be using the Stack Exchange Data Explorer or Stack Exchange Datadump.

    A similar question has been asked before on Stack Apps: Can I fetch Stack Overflow users by location in Stack Exchange API