Not an API but some PHP Classes to get at your Fuelly Data
I know many people (including myself) wish Fuelly had an API so that we could fetch data and display it inline on our site. The only suggestions I have seen is to export to csv and import to your site or write a script that would login as your user and export/import on it's own.
However this is just messy. I have created a set of PHP classes that use the DOM to get at the data that Fuelly displays in-line on the site. Currently it requires your username and password and fetches your list of vehicles based on that. Once it has a list of vehicles it will loop over them and fetch the data associated with them, along with the last X fuelups, this number is configurable by changing a class constant currently. I know it's not the best way but this code is a work in progress and I will be extending upon it so that everyone who wishes to use it can benefit from it.
It's pretty straight forward, basically you create a fuelly_user instance with your username and password. Then you get an instance of the fuelly_scraper class passing it the user and call the run method. It will return a populated user object like the following:
Hopefully one-day Fuelly will get an API going so that we can do things like this. I am not personally looking for a way to push data to Fuelly, I basically want to display some data on my site. I was originally going to put on my site how many miles I have driven today based on the fuel-ups for the current date but it will take a bit more work to get all that information.
If anyone is wondering why there are none of the mini-stats collected it is because each mini-stat does not have an identifier in the code such as an id/class that I could use with XPath to fetch the data from the dom.
I could still grab the data without them however how am I to know what order the mini-stats are in since every user can put them in any order they wish. Also the script currently only uses cURL to login to get your vehicle list. Everything else is pulled from public pages. I plan to change this in the future so that you can get at the data that is only available to you on the Fuelly site, more to come over the next few weeks.
as for computing them on my end sure it could be done but i found that my numbers come out different than yours. I found that in the simple case where I tried to calculate total fuelup cost as gallons * price. could not get the exact number you have in the stats on the actual fuelup page.
I opted to use the datatables JSON output you have available rather than scraping for all the fuelups, maybe I will change that soon.
It would be nice if you could do something like this on your end.
True, but you never know what people have set as their mini-stats. So you'd only have access to whatever stats the user has enabled.
Can't you get the stat from the DOM? Each mini stat includes the value, label, and the timeframe. The strong tag has the value, the em tag has the timeframe, and the p tag has the stat name. You should be able to get it without IDs.