14

So far I have seen some Perl modules; Finance:MtGox and Webservice:MtGox for interacting with Mt.Gox, a Ruby gem for Mt.Gox and a Python based command line client for again, Mt.Gox.

I'm wondering if there are any other language APIs for other exchanges?

I'd especially like to find a Java API for more than one exchange.

5
  • 2
    Why don't you make one for java? ;)
    – user62
    Sep 9, 2011 at 17:33
  • 1
    @barrymac, why don't you make an answer to this question listing the ones you already know with a short description of each. People might add to you answer and we'll soon get a great list without relying on a link to somewhere else.
    – D.H.
    Sep 9, 2011 at 18:08
  • @Harpyon Well I might end up doing that, not sure the quality will be amazing though. The authentication mechanism is complicated and confuses me a bit. Also there's an issue with the SSL certificate that makes things annoying as well, you have to add an exclusion to a local trust store and add this to the JDK.
    – barrymac
    Sep 9, 2011 at 19:30
  • @D.H. I'll add what I know to the question with some links
    – barrymac
    Sep 9, 2011 at 19:31
  • @Harpyon, page not found... 404
    – Pacerier
    Apr 19, 2013 at 7:17

3 Answers 3

7

There is now the XChange library

This is a pure Java library that has been released under the MIT license. It currently supports Mt Gox, but there are simple hooks to allow other exchanges such as Intersango and CryptoXChange to be supported.

It is currently used by the MultiBit client.

3

I have rolled my own mtgox api implementation in java. it is based on google-Gson and raw URL requests. i plan on releasing it eventually but the code is not yet on release quality level. if you have any specific questions, just ask in comments

2

I don't know of a currently existing Java API for Mt Gox - most folks will probably roll their own until Mt Gox issues their own demonstration client in Java.

However, in the interests of helping you make some progress in this area here is a short tutorial that may be of some use.

How to build a Java API for Mt Gox

You could just throw one together using the web API specification provided by Mt Gox.

Although the examples are written in PHP, the nature of the API is a bunch of simple HTTP requests which typically use JSON to transfer the payload.

For example the getDepth request

https://mtgox.com/api/0/data/getDepth.php?Currency=PLN

will return a block of JSON that looks something like this:

{"asks":[[13.32937,46.25473014],

....

"bids": [[11.09752,1],[11.18583,259.5],

[12.64579,3]]}

which can be mapped to a Java object as follows

package org.example.mtgox;

import java.util.List;

public class Depth {
    private List<Asks> asks;
    private List<Bids> bids;

    public List<Asks> getAsks(){
        return this.asks;
    }
    public void setAsks(List<Asks> asks){
        this.asks = asks;
    }
    public List<Bids> getBids(){
        return this.bids;
    }
    public void setBids(List<Bids> bids){
        this.bids = bids;
    }
}

Add a sprinkle of JAXB annotations (@XmlRootElement and so on), plug it into the RESTEasy framework and it'll handle all the translation for you. Note that JAXB annotations allow rendering to XML, JSON and YAML - they're just markers. Barely a line of code to be written.

Incidentally, if you have a JSON input and you want a bare Java POJO generated from it, you can use the very handy JSONGen web service.

Shameless plug

If you want this developed more, then let me know and I'll see what I can do to help.

2
  • 1
    Thank you for your very informative post but actually I use groovy which has very convenient json facilities: 'getMtGoxSslClient().get(path: "api/0/data/ticker.php") { resp, json -> println "BUY: " + json.ticker.buy println "SELL: " + json.ticker.sell }'
    – barrymac
    Sep 10, 2011 at 23:56
  • @barrymac Groovy is ideal for this kind of work. I only offered JAXB since you mentioned Java. Good luck with your project.
    – Gary
    Sep 11, 2011 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.