Skip to content
amiridis edited this page Jan 12, 2011 · 5 revisions

API Usage

Request info: (ascii, utf-8) key-value pairs
Response info: JSON
Response code: 200 if it worked, {4,5}xx if there was an error

/api/overview.js

GET example.com**/api/overview.js**

{
    "req_url": "https://mtgox.com/code/(function_name).php",
    "req_method": "POST",
    "post_body_encoding": "application/x-www-form-urlencoded",// or "application/json"
    "req_authentication_type": (integer)
    // 1:
    //     To authenticate with (account identifier, authkey {type:"password", password:"...password..."}):
    //         include params: name=(account identifier), pass=(authkey.password)
    // 2:
    //     To authenticate with (account identifier, authkey {type:"hmac-sha256", token:"...", key:"..."}):
    //         include params:
    //              f=(function name)
    //              account=(token)
    //              nonce_ms=(ms since 1970)
    //              nonce_random="(random token)"
    //         include HTTP headers:
    //              X-Signature: ...base64...
    //              X-Authkey-Token: (authkey.token)
    
    "supported_functions": [
        // e.g. for Mt Gox at the moment:
        "send-btc", "my-balance", "place-order", "my-open-orders", "cancel-order"
    ]
}

API Functions

Basic

send-btc

    to_btc_address="..."
    amount="17.50"
    -------------
    {}

new-btc-address

    -------------
    {"btc_address": "..."}

my-balance

    -------------
    {
        "available": {
            "btc": "17.50"
            "usd": "0.02"
        }
        "pending": {
            "btc": "5000.0"
        }
    }

Orders

place-order

    trade_amt="0.39"
    trade_cur="USD"
    for_amt="1.05"
    for_cur="BTC"
    -------------
    {"oid": "..."}

cancel-order

    oid="..."
    -------------

my-open-orders

    -------------
    TODO

Options

Mt Gox says "coming soon"

Margin Trading

Mt Gox says "coming soon"

Trust and Identity

attach-identity-to-transfer

    transfer_json=json_encode({
        identity_url: "..."
        identity_public_key: "...base64 of TODO..."
        bitcoin_transfer: "...base64 of TODO..."
    })
    identity_signature="...base64 of TODO..."
    coinholder_signature="...base64 of TODO..."
    -------------

Invoices

An invoice is a bitcoin address, an amount, a currency, and optional extra info.

A currency of BTC means "please send me (amount) BTC"

A non-BTC currency means "please send me (X) BTC along with an option you've purchased (to trade (X) BTC for (amount) (currency) in the next 30 seconds)". This probably won't be implemented for a while...

{
    // a one-time address, so it can also serve to identify the invoice
    "btc_address": "..."
    
    "amount": "17.05"
    "currency": "BTC"
    
    info: {
        // all fields are optional:
        hub_url: "..."
        memo: "..."
        t: ms since 1970
        lat: "..."
        lng: "..."
        random: "..."
    }
}

pay-invoice

Normally you'd just use a normal Bitcoin transfer, possibly expedited via things like attach-identity-to-transfer. You'd only use this call when you need to include an option.

    TODO
    -------------

post-invoice

    invoice_json="..."
    signature="...base64 of TODO..."
    -------------

withdraw-invoice

    invoice_bitcoin_address="..."
    signature="...base64 of TODO..."
    -------------

find-invoices

all request params are optional

    t=
    lat=
    lng=
    random=
    -------------
    invoices: [{...}, ...]
    more_exist: true/false

Account Creation

create-account

    -------------
    {
        "account": "..."
        "authkey": {...}
    }

Authkeys

create-authkey

    -------------
    {"authkey": {...}}

change-authkey-permissions

    TODO
    -------------