WIP: API
-
You inspired me :)
Here we have our first simple Merchant API for FTC/USD currency conversion:
[b]Examples:[/b]
http://host.feathercoin.com/netstats/FTC_Merchant_Currency_Converter_API.php?amount=1
http://host.feathercoin.com/netstats/FTC_Merchant_Currency_Converter_API.php?amount=100
http://host.feathercoin.com/netstats/FTC_Merchant_Currency_Converter_API.php?amount=10000I have also included further information in the actual page you are linked too…
[b]Edit:[/b] I decided to pull data from Mt.Gox for BTC/USD conversion and BTC-E for FTC/BTC conversion < This can be changed if warranted.
I’m off to bed now ::) -
.
-
Nice work. Pulling from MtGox seems the right thing to do to get the value of Bitcoin. Gox also has lots of currencies so we can pull more from the same place.
Going forward I think that we should use JSON.
-
[quote name=“Bushstar” post=“17970” timestamp=“1372315226”]
Nice work. Pulling from MtGox seems the right thing to do to get the value of Bitcoin. Gox also has lots of currencies so we can pull more from the same place.Going forward I think that we should use JSON.
[/quote]Definately JSON…But…
…Why not offer both? :DI have added a further option:
[b]
Defining output > 0 returns a valid JSON string:[/b]
[url=http://host.feathercoin.com/API/FTC_Converter_API.php?amount=1000&output=1]http://host.feathercoin.com/API/FTC_Converter_API.php?amount=1000&output=1[/url]
[b]If output < 0 (or omitted from the URL completely), will return plain a text ticker:[/b]
[url=http://host.feathercoin.com/API/FTC_Converter_API.php?amount=1000&output=0]http://host.feathercoin.com/API/FTC_Converter_API.php?amount=1000&output=0[/url]I have also rounded the result to 2 decimal places and added a couple of [i]catch $e[/i] on the data pulls to cover any eventualities.
Now how do we announce this? Can the server stand the API?.. Or anything else we need? …
-
Genius at having both plain text and JSON.
Let’s put it to the test on a couple of things. I will look to implement a FTC converter in the market.
UKMark, I have put a copy of the calc on the host.ftc.com server. You know what would be awesome, the price of FTC to be live :)
-
[quote name=“Bushstar” post=“18114” timestamp=“1372357388”]
Genius at having both plain text and JSON.Let’s put it to the test on a couple of things. I will look to implement a FTC converter in the market.
UKMark, I have put a copy of the calc on the host.ftc.com server. You know what would be awesome, the price of FTC to be live :)
http://host.feathercoin.com/calc/
[/quote]I will do promise, but not just yet, I can’t multitask…So my Wife keeps telling me :)
As for the market you could display the USD prices under every FTC price quite easily by using something like document.write or inner.HTML on a DOM ready etc in .js - I could write you this if needed… 8)
-
There is a currency converter that I stripped out of the system. It pulls the values for currencies from a flat file. I may leave this in place but get a script to run to update the file once in a while. This should at least make it easy to add all the fiat currencies. I will start with FTC/USD.
-
[quote name=“Bushstar” post=“18120” timestamp=“1372359405”]
There is a currency converter that I stripped out of the system. It pulls the values for currencies from a flat file. I may leave this in place but get a script to run to update the file once in a while. This should at least make it easy to add all the fiat currencies. I will start with FTC/USD.
[/quote]Ok great leave everything as is I will take a look, I have only just noticed it in host. now :)
-
-
OK here is where we are at:
The currency API is now loacted at:
[url=http://host.feathercoin.com/api/api.php?amount=1&output=1]host.feathercoin.com/api/api.php?amount=1&output=1[/url] will return a JSON string response, likewise - [url=http://host.feathercoin.com/api/api.php?amount=1&output=0]host.feathercoin.com/api/api.php?amount=1&output=0[/url] will return a plain text/ticker response.Listening to bushes suggestions I have also implemented the API with our mining calculator, but to save on server load I have written another script that pulls the data from the API and writes it to a .log file, this .log file is then imported into the calculator on screen load < Bush needs to set a cron for the script execution process, but for now I will do on a daily basis < if I remember :)
This new calc is available here:
[url=http://host.feathercoin.com/calc]host.feathercoin.com/calc[/url]Also I have added the basic GUI [i]plain text[/i] live API currency converter to:
[url=http://host.feathercoin.com/api/ftc_usd.html]http://host.feathercoin.com/API/ftc_usd.html[/url]< I am not sure whether bush wants to release this to the community just yet as we may need to set up a separate server for the API as they can be quite resource intensive once adopted by the masses, so maybe best to hang fire on spreading the word fully until bush gives us the nod. 8)
EDIT: Updated the GUI converter link from index.html to ftc_usd.html
EDIT2: Damn API is now offline :o, we have moved servers and it appears now that a few things are barfed :'( < Will update further when this is resolved.
-
Ok everything works again ::), new server configuration and file permissions were to blame. :(
I have increased accuracy to 8 decimal places overall on the JSON output for the currency converter API - plain text output is still standard [i]fiat[/i] 2dp.
this increased accuracy can now be seen on the mining calculator (link above).I have also built a JSON API version of our stats page ( + a few xtra features like blocks to re-target and days, hours, minutes & seconds, are now all separately available strings, this is designed for developer/development purposes, I can add more on an as-needed/requested basis…
[url=http://host.feathercoin.com/api/ftcjsonapi.php]http://host.feathercoin.com/api/ftcjsonapi.php[/url]
[b]Returns:[/b]
[code]{
“khs”: 3061169.064,
“retblk”: 43344,
“blkstoret”: 334,
“nowdiff”: 68.80258528,
“nextdiff”: 97.306513467429,
“timetoret”: 32347.9,
“days”: 0,
“hours”: 8,
“min”: 59,
“sec”: 7,
“totcm”: 8602000
}[/code]