Nuddles is a Node.js wrapper for the foursquare API. It will enable you to effortlessly query their multiple endpoints. We make no assumptions about how you are going to use it, we just return the data to you. You are free do manipulate the results as you wish.
Before you can start using Nuddles, please make sure you have your access tokens ready. If you
don't know how to aquire them, you can simply head over to the foursquare developers
site, click "create new app" and follow the instructions. Foursquare will provide you with
clientId and a
clientSecret token that you will need to query the API.
$ npm install nuddles --save
Depending on your setup, you may need sudo privileges
To use Nuddles in your project, you first need to import it and instantiate a new
const nuddles =const client =clientId: "your client id"clientSecret: "your client secret"
Client object must be instantiated with both your
you can also specify an optional api version if you wish to (it currently defaults to
const client =clientId: "your client id"clientSecret: "your client secret"apiVersion: "YYYYMMDD"
The setup above is perfectly fine for making requests to Foursquare's publicly accessible endpoints. However if you need to access protected endpoints that require acting users, you must first authenticate them using the OAuth2 flow.
Step 1: Instantiate a new
const client =clientId: "your client id"clientSecret: "your client secret"apiVersion: "YYYYMMDD" // optionalredirectUri: "your redirect uri"
Notice that we pass a
redirectUri attribute to the config. It must match the
redirect uri you set when creating the app on the foursquare developer's site.
Step 2: Create an authorization link / button for your users
const authorizationUrl = clientauth_url// Render this url as a link / button in your front end app
Step 3: Request an access token
Once your users click on the link and give your app authorization to use their account on
their behalf, they will be redirected to your
An authorization code will be passed along as a query parameter. You will need to capture that code and store it in a variable.
// Example using expresslet authorizationCodeapp
Once you have that code you can request an access token to Foursquare
client// Make note of this token// Handle the error
Step 4: Set your access token
clientaccessToken = "yourSavedAccessToken"
Ideally you'd want to store your credentials in a separate config file ignored by version control or in environment variables
Set your acccess token directly
Alternatively, if you already have an access token, you can just skip step 1 to 4 and directly instantiate a client with your accessToken.
const client = nuddles
Nuddles also exposes seven other classes:
All of the above classes accept an optional
id upon instantiation (ex: the Id of a venue when creating a new Venue)
const client = clientId: "your client id" clientSecret:"your client secret"// Venueconst venue = client "someVenueId"// Listconst list = client "someListId"
Please note that all methods return promises, which means you will have to call
.then() to manipulate the response
All methods that accept a
params argument should be passed an object with a list of
query parameters for your request, these parameters should match the ones listed in the
client // Your other query params here
In order to run the tests:
Nuddles is a work in progress and an open source project. If you spot something that can be improved, a missing endpoint or find a better way to achieve the same functionality, please feel free to add your contribution by way of a pull request.
Nuddles is licensed under the Do What The Fuck You Want license.