Viewing 6 posts - 1 through 6 (of 6 total)
  • Strava and Swift (programming)
  • LittleNose
    Free Member

    I’ve learned the basics of swift over the last year, with the intention of playing around with Strava data for OSX or the iPhone.

    Unfortunately now I’ve gotten myself to the point where I’m ready to play with the Strava data, but I’ve hit a brick wall.
    I’ve signed up and got myself the developer API stuff, I’m quite honestly clueless on how to use this and wondered if anyone here has done anything along these lines and would give me a little boost to get going.

    whatnobeer
    Free Member

    There’s probably a few tutorials around showing you how to connect and make the requests to get the data you want, either from Strava’s Developer Guide (maybe the dont have one) or from a 3rd party/open source/enthusiast blog type website.

    Usually the script is something along the lines of make a request to the API to authenticate and get a token.
    Save the token locally and use this in a header for future requests.
    Send GET requests to the appropriate API endpoints and get the data you need.
    Parse the response that you just got back ( I guess it’s JSON?) and do some stuff with it.

    🙂

    Edit: I assume you’ve read this: Strava Docs
    If you need help with how to send requests I’d suggest looking for a tutorial on how to do that 1st, then using the Strava one 2nd.

    LittleNose
    Free Member

    Cheers WNB

    Yes, it uses JSON, which I think I’m quite happy with, but it’s the initial requests and authentication I’m struggling with.

    As you say, the net is full of helpful resources, but as Swift is updating annually and not backwards compatible, it’s hard to always know which version the resource is trying to help with.
    I’ve also found that within Swift there are so many obscure and specific library calls compared to something like Python.

    Yes, I’ve read the API guide, but as a hobbyist, I’m struggling with lots of the jargon.

    Thanks for the input… it’s very helpful to motivate me again… I’ll have another concerted effort over the next week and let you know how I get on.

    whatnobeer
    Free Member

    Good luck!

    I find its usually helpful to break it down into steps. Try and just get the authentication working 1st. There’s an OAuth guide on the dev docs, it’s not for Swift, but should give you an idea of what to look for/be doing.
    Once you’ve got the auth token you can then look at constructing your requests.

    The other option might be to look at using a Swift Strava library (If there is one). If it’s well documented then it might give you some clues and take a lot of the leg work out!

    atlaz
    Free Member

    I’d imagine there are some OAuth libs for Swift (actually, a quick google confirms this) so download one and use that in your source code to get the authentication. It’s the hardest part of the Strava API to get into and originally wasn’t required unless you needed user specific data but that time is now gone.

    LittleNose
    Free Member

    Thanks guys

    I was originally trying not to use the libraries, so that I could learn to understand what’s going on under the hood so to speak, but I think on reflection after banging my head against the wall, I’m going to use OAuthSwift or StravaKit to see if I can get any further.

    Thanks again folks… and I’ll let you know how I get on.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Strava and Swift (programming)’ is closed to new replies.