neynarxyz / nodejs-sdk

Typescript SDK for Neynar APIs
https://neynar.com
MIT License
53 stars 11 forks source link

feat: search users by location #230

Closed valerierose closed 2 weeks ago

valerierose commented 2 weeks ago

Overview

Adds fetchUsersByLocation method to get users by location.

Example

const result = await client.fetchUsersByLocation(34.05, -118.24, {limit: 3});
console.log(JSON.stringify(result));
$  node index.js | jq '.users[] | {fid: .fid, username: .username, profile: .profile}'

{
  "fid": 2,
  "username": "v",
  "profile": {
    "bio": {
      "text": "Technowatermelon. Elder Millenial. Building Farcaster. \n\nnf.td/varun"
    },
    "location": {
      "latitude": 34.05,
      "longitude": -118.24,
      "address": {
        "city": "Los Angeles",
        "state": "California",
        "state_code": "ca",
        "country": "United States of America",
        "country_code": "us"
      }
    }
  }
}
{
  "fid": 3,
  "username": "dwr.eth",
  "profile": {
    "bio": {
      "text": "Working on Farcaster and Warpcast."
    },
    "location": {
      "latitude": 34.05,
      "longitude": -118.24,
      "address": {
        "city": "Los Angeles",
        "state": "California",
        "state_code": "ca",
        "country": "United States of America",
        "country_code": "us"
      }
    }
  }
}
{
  "fid": 19,
  "username": "julia",
  "profile": {
    "bio": {
      "text": "President of Antares Industries. Mom to 2 little boys. Nuclear energy advocate. Formerly SpaceX and Opendoor. Angel investor. "
    },
    "location": {
      "latitude": 34.05,
      "longitude": -118.24,
      "address": {
        "city": "Los Angeles",
        "state": "California",
        "state_code": "ca",
        "country": "United States of America",
        "country_code": "us"
      }
    }
  }
}
zacharytyhacz commented 2 weeks ago

What is the radius it searches when you pass lat + lng ? or is it exact coords?

I think a more reasonable query would be like "fetching users where location is within 0.1 of this latitude+longitude"

for example:

valerierose commented 2 weeks ago

Hi @zacharytyhacz. For now, the radius is 50km, roughly a metro area. In the future, as we iterate on the API, we'll consider making the radius a parameter.