API

37 watchers
Dec 2014
9:33pm, 10 Dec 2014
4,611 posts
  •  
  • 0
Badger
Hi Fetch, any updates on the API? I'm using it for uploads again at the moment (using a Suunto watch and using Python to upload runs to here and Training Peaks); wondering if there is any chance of editing things like equipment and maybe even custom fields? Also, being able to pull the exact time of a workout would be really good for deciding what to upload and what's already there; hour is usually good enough, but parkrun mornings often turn into a run and a bike within the same hour.

Flanker, did you get anywhere with FIT files?
Dec 2014
12:01am, 11 Dec 2014
15,452 posts
  •  
  • 0
flanker
not looked at it yet. Got sidetracked with learning Swift!
Mar 2015
8:34pm, 5 Mar 2015
15,666 posts
  •  
  • 0
flanker
still sidetracked, but dreaming ups interesting ideas with the mapping/geolocation stuff on iDevices...

Now if fetchpoint was exposed via the API (or maybe by a scrape? hmmm...) then I can envisage a great app for bug busting / coin gathering / etc.
Jun 2015
5:20pm, 2 Jun 2015
15,904 posts
  •  
  • 0
flanker
right, finally starting to play with this, but struggling at the first step as I've no idea how to authenticate against the API as I'm not a PHP guy.

From what I can make out from the example I need to POST through a base64 encoded combination of user +":"+secret ?

At the moment I'm getting the response:
NSHTTPURLResponse: 0x7fdb08c180f0 { URL: api.fetcheveryone.com } { status code: 200, headers {

"Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";

Connection = "Keep-Alive";

"Content-Length" = 0;

"Content-Type" = "text/html; charset=utf-8";

Date = "Tue, 02 Jun 2015 16:15:46 GMT";

Expires = "Thu, 19 Nov 1981 08:52:00 GMT";

"Keep-Alive" = "timeout=5, max=100";

Pragma = "no-cache";

Server = "Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny10 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g mod_perl/2.0.4 Perl/v5.10.0";

"Set-Cookie" = "PHPSESSID=0e9013b6e140ca3f6b71d6d4c7cbc74a; path=/";

"X-Powered-By" = "PHP/5.2.6-1+lenny10";
} }

which I assume means I've not authorised anything. I'm getting no data or error back.
Jun 2015
5:59pm, 2 Jun 2015
5,093 posts
  •  
  • 0
Badger
I'm not a PHP guy either, but I got it going with Python.

Your content-length should be 51, so that's not right.
content-type should be application/json
Did you have 'Accept': "application/json" in the headers as well as the authorization bit?
Jun 2015
6:20pm, 2 Jun 2015
5,094 posts
  •  
  • 0
Badger
Scratch that, what you get is what I see if I send garbage as the base64 encoded users=":"+secret. I was confused by the 200 status code.

Have you used hex instead of text for the user and secret values?
Jun 2015
8:08pm, 2 Jun 2015
15,905 posts
  •  
  • 0
flanker
Thanks.

Yes, had the accept header, or at least I think I did! Assuming how I'm passing the header pairs is correct. Expect that my encoding is the issue, as I'm not too sure right now what I'm trying to do there or (yet) how the pre-built Swift API works - I've just been following a pattern so far, but will dig into it later tonight.
Jun 2015
10:33am, 3 Jun 2015
15,909 posts
  •  
  • 0
flanker
Grrrr. Typo. Missed out the trailing space on "Basic "

Getting somewhere now. Although I'm having to work out the request/response protocols by trial and error from looking at the HTTP responses and data. I'm sure it's widely documented on t'web, but by the time I've worked out the PHP I can have worked it out by looking at the raw data!
Jun 2015
11:21am, 4 Jun 2015
15,917 posts
  •  
  • 0
flanker
All working on iOS (other than upload, which I can't be bothered to code unless I can find some useful purpose for it. strava to Fetch synch?)

One question - I'm sometimes getting a FAIL response with an invalid access token. I' assuming this is the access token expiring? If so, does anyone know what its TTL is?
Jun 2015
12:06pm, 4 Jun 2015
5,105 posts
  •  
  • 0
Badger
60 seconds I believe; I was refreshing after 55 and have had no problems with very lengthy sessions.

I've made tools for multiple uploads of Suunto sml files and tcx files to FE, and a few people have used the tcx uploader to get old data into new FE accounts.

I started playing with strava to FE sync and can't remember why I abandoned that; probably having to deal with yet another file format for the route from strava (which they helpfully describe as a polyline in the documentation).

About This Thread

Maintained by fetcheveryone
We're very much in the "gently trying things out" stage, but please join in if you're interested in working with a Fetch API:

Get your developer keys here:
http://www.fetcheveryone.com/api-request-keys.php

And a basic PHP client example here:
http://www.fetcheveryone.com/demo/api_client.0.2.zip

With thanks to Badger, here's a Python version:
http://www.fetcheveryone.com/demo/FetchAPIPython_0.2.zip

Available methods:
http://www.fetcheveryone.com/api-doc.php

Join the developer group here:
http://www.fetcheveryone.com/groups-view.php?id=1167

If you'd care to port the client into another language, please let me know, and I can upload it to share with others.

Related Threads

  • api
  • coding
  • import









Back To Top

Tag A User

To tag a user, start typing their name here:
X

Free training & racing tools for runners, cyclists, swimmers & walkers.

Fetcheveryone lets you analyse your training, find races, plot routes, chat in our forum, get advice, play games - and more! Nothing is behind a paywall, and it'll stay that way thanks to our awesome community!
Get Started
Click here to join 113,793 Fetchies!
Already a Fetchie? Sign in here