node-strava is not yet in the NPM repository. You can install it by running the command below:
npm install git+https://github.com/mcfitz2/node-strava.git
To get started, first initialize the client with your OAuth credentials:
var strava = new require("./strava")({
client_id: "<Client ID>",
client_secret: "<Client Secret>",
redirect_uri: "<Redirect URI>",
access_token: "<Access Token>"
});
Then you can access the API:
strava.athlete.get(function(err, res) {
console.log(res);
});
{
"id": 227615,
"resource_state": 3,
"firstname": "John",
"lastname": "Applestrava",
"profile_medium": "http://pics.com/227615/medium.jpg",
"profile": "http://pics.com/227615/large.jpg",
"city": "San Francisco",
"state": "California",
"country": "United States",
"sex": "M",
...
}
For all methods, params
is an object with keys corresponding to the parameters given in the Strava API. Some methods have other special parameters.
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
types
- List of data types to request. Should be an array.
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
types
- List of data types to request. Should be an array.
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
paginate
- Automatically fetch all results. Currently cannot restrict number of pages
Parameters
types
- List of data types to request. Should be an array.
Parameters
wait
- Poll API for upload status and return only after an error or a successful uploadpoll_interval
- Amount of time (in milliseconds) to wait between pollspoll_callback
- Function that is called after each poll with the argumentserr
, andres
data
- GPX, FIT, or TCX file as a buffer, string, or streamfilename
- Specify filename of GPX, FIT, or TCX file. Ifdata
is not set, this filename will be used to open the file. Otherwise, it has no real meaning.
Examples
As a stream:
strava.uploads.upload({wait:true, data:fs.createReadStream("test.gpx")}, function(err, body) {
console.log(err, body);
});
As a string:
fs.readFile("test.gpx", function(err, gpx) {
strava.uploads.upload({wait:true, data:gpx}, function(err, body) {
console.log(err, body);
});
});
Using just a filename:
strava.uploads.upload({wait:true, filename:"test.gpx"}, function(err, body) {
console.log(err, body);
});
Uploading a TCX file:
strava.uploads.upload({wait:true, filename:"test.tcx", "data_type":"tcx"}, function(err, body) {
console.log(err, body);
});
node-strava is the work of a single developer. If you want to contribute, feel free to send a pull request!