Get a wallet or

Inputs.io API

Send and receive Bitcoin payments with a few lines of code on any web server (no bitcoind installation required) with the Inputs.io API. Take advantage of the no-fee, no confirmations instant payment network.

You'll need to have a Inputs wallet first, so make an account. We recommend keeping your API accounts and your personal Inputs.io wallets seperate.

An API key is required. All API requests must carry the API key - you can generate one in the security tab

Add an Inputs button to your site so your visitors can pay without leaving the page.


Callbacks

The easiest way to take payments is to use the callbacks. Set a callback URL in the security tab, and we'll visit that when you receive a payment. Variables are passed through GET.

  • Bitcoin payments are callbacked when they confirm (1-5 confirms depending on size). We call with the GET variables txid (bitcoin network txid), from (one of the Bitcoin address(es) that sent the BTC), recv (the Bitcoin address where you received the payment) and amount in BTC.
  • Inputs.io payments are callbacked instantly. We call with the GET variables txid (starts with io), from (the email of the sender, urlencoded), amount (the amount of BTC), and note - you may need to urldecode it.

Tip: Parse the note field! Tell your users to input data like their username (to credit the deposit to), what they want to bet on, etc. It's good practice to return the TX if you fail to parse the notes, with Error: starting in the notes field. When you get a transaction, make sure that you are not responding to an error and causing an infinite loop.

Tip #2: If you are decoding the from field, make sure to use rawurldecode otherwise user+plus@webmail.com will decode to user plus@webmail.com.

Echo just *OK* after you successfully process the transaction! If we don't get exactly *OK*, we will callback the URL again once after two blocks (10 to 30 minutes).

It is very important to make sure the request came from our IP, 50.116.37.202

Example callback

How you might implement it:

$mysqli = new mysqli("localhost", "user", "password", "databasename");
$apikey = "my_api_key";
$pin = "1234";
if($_SERVER["REMOTE_ADDR"] == "50.116.37.202"){
	if(isset($_GET["note"])){
		$note = $mysqli->real_escape_string($_GET["note"]);
		$amount = $mysqli->real_escape_string($_GET["amount"]);
		$userExistsQ = $mysqli->query("SELECT COUNT(*) FROM users WHERE username='$note'");
		if($userExistsQ->fetch_row()[0] === "0"){
			// user does not exist. send the coins back
			$sendBackTo = urlencode($_GET["from"]);
			$returnNote = urlencode("Error: Username not found. Please include exactly your username in the notes field.");
			$url = "https://inputs.io/api?key=$apikey&action=send&address=$sendBackTo&amount={$_GET['amount']}&note=$returnNote&pin=$pin";
			if(substr($note, 0, 7) != "Error: "){
				// do not callback error messages
				file_get_contents($url);
			}
		} else {
			$mysqli->query("UPDATE users SET balance=balance+$amount WHERE username='$note'");
		}
	} else {
		// Someone sent to our Bitcoin address. This shouldn't happen if we don't post it anywhere.
	}
	echo "*OK*"; //echo OK to confirm we processed it
}
		

Get Balance

https://inputs.io/api?key=[API key]&action=getbalance
Returns your confirmed balance, unconfirmed balance, total transactions, total received, total sent, limit used, the current BTCUSD exchange rate, USDEUR, USDGBP and USDCAD in a JSON array. The amount is in satoshis! 1 BTC = 100000000 satoshis.


Get Last Transactions

https://inputs.io/api?key=[API key]&action=gettransactions&from=[How many TX to skip, 0 for most recent]
This call returns 25 transactions, in JSON format. Example output of one transaction:
[{"id":"45","txid":">I23722c62d763b53866f353c9273e0ba52d80ddb30fc1e38231b6a7147ffc80","from":"admin@glados.cc","to":"test@glados.cc","amount":100000,"note":"API Example","time":"1372227211","to_addr":"","balance":"85.95889472", "read":0}, ... ]
The amount is in satoshis! 1 BTC = 100000000 satoshis.


Send Transaction

https://inputs.io/api?key=[API key]&action=send&address=[To addr, urlencoded]&amount=[Amount (BTC)]&note=[Note]&pin=[PIN]
You can send to a bitcoin address or email address (if they use Inputs.io). If you are sending to a Bitcoin address on Inputs.io, we will send it through the offchain network.

Possible responses:

  • MISSING_VARS: You didn't enter the address, amount and PIN.
  • INVALID_AMOUNT: The amount is not a valid number.
  • BELOW_MIN: The amount is below the minimum send amount (currently 0.0001 BTC, 0.1 mBTC)
  • LIMIT REACHED: You reached your sending limit per 48hr window. This can be changed in the Security tab.
  • MYSELF: You are trying to send to yourself!
  • NO_BALANCE: Not enough balance to complete this transaction. If you're sending to a Bitcoin address, there is a 0.0005 BTC fee
  • SEND_FAILED: Sending somehow failed via the Bitcoin network.
  • INVALID_ADDRESS: Invalid address you are trying to send to.
  • VOUCHER_[24 char code]: You were sending to an email address that haven't registered for Inputs. We generated a voucher.
  • JSON Array: This is a getBalance response. It indicates that sending was successful.


Transaction Details

https://inputs.io/api?key=[API key]&action=txdetails&txid=[TXID]
Returns details about a specific transaction. The format is the same as gettransactions, except without the account balance after transaction.


Sign & Verify Message

You can sign messages with your Bitcoin addresses. The signed message can be verified by anyone that the person who owns that address has said the following message. Make sure to encode it for URL!

https://inputs.io/api?key=[API key]&action=signmessage&address=[Your Bitcoin address]&message=[Your message]

The output will be the signed message.

https://inputs.io/api?key=[API key]&action=verifymessage&message=[Signed message]

Returns the address used to sign it if it is true, returns false / nothing if it the message cannot be verified.


Generate and redeem vouchers

You can generate and redeem vouchers through the API. This is similar to sending payments, however you get a code back that can be used to redeem the coins.

https://inputs.io/api?key=[API key]&action=genvoucher&amount=[Amount in BTC]&pin=[Your PIN]

You will either get back VOUCHER_[24 char string] or an error message like LIMIT_REACHED, INVALID_AMOUNT, etc (similar to sending).

https://inputs.io/api?key=[API key]&action=redeemvoucher&voucher=[Voucher code]

The possible responses are NO_VOUCHER, REDEEMED, or OK_[amount] (credited to your account).


Advanced Features

Inputs.io also provides some advanced features for interacting with the Bitcoin blockchain. These will be expanded over time.