node-strava/node-strava-v3

giving kudos

aryehbeitz opened this issue · 14 comments

how can I give kudos? It's documented in Strava's api, but here there is only retrieve kudos
thanks

OzQu commented

As far as I know, it is not implemented to this library yet. And as we all see, pull requests are piling up.

I think @timosta @UnbounDev should try to share responsibilities of this library to someone else, so improvements would be merged. Or someone could fork this and actively maintain the fork.

Hello @OzQu, according to the information from the https://developers.strava.com/ soon we will have library developed by Strava as I understand.
Please see Client Libraries section. Hope that it will be really soon

Code sample from docs with usage of the new library:

var StravaApiV3 = require('strava_api_v3');
var defaultClient = StravaApiV3.ApiClient.instance;

// Configure OAuth2 access token for authorization: strava_oauth
var strava_oauth = defaultClient.authentications['strava_oauth'];
strava_oauth.accessToken = "YOUR ACCESS TOKEN"

var api = new StravaApiV3.AthletesApi()

var id = 56; // {Integer} The identifier of the athlete.

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.getAthleteById(id, callback);
OzQu commented

That's great! Any idea when that is going to be published? Just that it's sad that at the moment there is no up to date library, not from community or Strava itself.

@OzQu They gonna release new update of the API January 15, 2018. Hope that the libraries also will be ready. You should receive this email from Strava Team. Subject: Activity-update webhook events coming Jan 15

Looks like Strava isn't supplying a new JavaScript library, but instead is suggesting that user's use Swagger to use code-generation to generate their own JavaScript client. This could work, but code-generated interfaces can be ugly and awkward to work with. Look at the sample that Swagger provides about a fake "Pet Store" project generated with the project:

https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/javascript-promise/src/model

I Installed Swagger on Ubuntu Linux today and only found an option to generate nodejs-server code. No option was found to generate Node.js client code for the Strava swagger file. So it's not clear to me that Strava is actually supporting a Node.js client through Swagger. Please correct me if I'm wrong here.

@markstos you can create a node.js client using https://github.com/swagger-api/swagger-js
You likely will need to provide your own fetch implementation using something like https://github.com/lquixada/cross-fetch

@markstos I'll put something together and get back to you. Looks like swagger-js already uses cross-fetch, so that step isn't necessary.

Please find an initial version at https://github.com/Interactivefitness/strava-v3-client

@svanzoest is there any advantage using your provided swagger code instead of this module? Any additional functions to use?

In theory, the Swagger code supports a maximal amount of features and is maximally up to date and officially supported.

Practically: Good luck. I just checked out the Github repo above and it doesn't document what method names are provided. It links to the Strava Swagger Playground. I followed the link. I didn't see how the Node.js method names are derived there either. So I read the source code in the new git repo. No method names are contained there either, as the entire API is apparently generated on the fly.

Somewhere I'm sure there is away to find all the docs for the method names and the structures returned.

If someone developers a Swagger-based client for Strava with decent docs, I'll take another look. In the meantime, this module works well enough for my needs, has some documentation and lacks the layer of magic and complexity that the Swagger code-gen solution contains.

@lavolp3 What @markstos is saying is correct. It wraps the swagger document to create the API.
The majority of the heavy lifting is actually done by swagger-client and uses the tags interface.

Strava recommends using a Swagger Code Generator and that is basically what I have done an initial version of for JavaScript. Their example is for Java.

All the methods are defined by the Swagger/OpenAPI document provided by Strava, so if Strava makes a change this is very easily integrated in the client library.

The way I started documenting the API is by writing tests. This is also a good way to keep track of the API changes when it loads in a new Swagger Document. It also should not be too difficult to automatically make documentation for the API based on the Swagger document, so you know the exact methods and structure, however, this is not something I have spent any time on. I wanted to publish this as soon as it was functional. It is therefore best to review the tests and Strava Swagger Playground for full understanding of the API.

The swagger document does not take into account a bunch of nuances such as image upload and oauth, so I still think it is best to use this library. There is nothing wrong with this library :) I actually contributed to this library to support binary uploads better, as that was no longer functioning after a refactor.

Since the current swagger document provided by Strava does not provide full oauth flow, it is something that needs to be specifically coded as this library does. So, in regards to the swagger generated version, that either needs to be added or the appropriate oauth configuration needs to be added to the Swagger/OpenAPI document for that functionality to be available.

My main reasoning for building the swagger version is that in the long run it will be easier to maintain, but since it may not provide all the functionality you are looking for it might be better to use this library instead. It really depends on what functionality you need.

Closing since no one has provided a patch for this since 2017. As the conversation above indicates, using Swagger-generated client code is another option-- that approach should support all the Strava API features except perhaps the OAuth flow.