NAV
shell php

Introduction

API Endpoint

https://api.indiesquare.me/v2/
API Endpoint

https://api.indiesquare.me/v2/

*** We use guzzlehttp library in examples ***

・composer.json

"require": {
    "guzzlehttp/guzzle": "6.*"
}

・index.php

<?php

require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();

echo $client->get('https://api.indiesquare.me/v2/addresses/17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW/balances')->getBody();

IndieSquare API provides digital token management features. It makes it easy to create your own token on the blockchain or integrate digital token into your applications. Currently, IndieSquare API supports Counterparty as a blockchain platform.

Schema

All API access is over HTTPS, and accessed from the https://api.indiesquare.me url. All data is sent and received as JSON.

Timezones

All timestamps are returned in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ e.g. 2014-02-27T15:05:06+01:00

API Key

Everyone can use IndieSquare API without an API Key however requests may be limited. IndieSquare API will return HTTP 429 response if you exceed the limitation. You can create an API Key on Indieboard. https://indiesquare.me/tokens/dashboard/apikey

HTTP status code 401 will be returned if the provided API Key is not a valid.

Request with API Key

curl -H 'X-Api-Key:abcd0efg12hi3j4klm5n678opqrstu9vwxyz' https://api.indiesquare.me/v2/addresses/17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW/balances
Request with API Key

$client->request('GET', 'https://api.indiesquare.me/v2/addresses/17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW/balances', [
    'headers' => [
        'X-Api-Key' => 'abcd0efg12hi3j4klm5n678opqrstu9vwxyz'
    ]
]);

Objects

IndieSquare’s API returns these objects below.

Balance

Balance Object represents a public address on the blockchain and their balances.

Attribute Type Description
token String The token name
balance Numeric The balance
unconfirmed_balance double The unconfirmed balance

Token

Token Object represents a token’s information.

Attribute Type Description
token String The token name
description String The description
token_image_url String The token image url
quantity Numeric The total issued quantity
issuer String The issuer’s public address
divisible Numeric The divisibility of the balance (0 = non-divisible, 1 = divisible)
locked Numeric Whether the token is locked (0 = unlocked, 1 = locked)

Token Holder

Token Holder Object represents token holder information.

Attribute Type Description
name String The token holder name
address String The bitcoin address
quantity Numeric The holding quantity
ratio Numeric The holding ratio

UTXO

UTXO Object represents the utxos of a public address

Attribute Type Description
address String The bitcoin address
txid String The transaction id
vout Numeric The index of the output
script_pub_key String The public key of the script
amount Numeric The amount of the transaction
confirmations Numeric The confirmation number
time Numeric The timestamp of the transaction

History

History Object represents the history of a public address

Attribute Type Description
type String The type of the transaction
token String The name of token
quantity Numeric The quantity of the transaction
source String The source public address of the transaction
destination String The destination public address of the transaction
category String The category of the transaction
time String The timestamp of the transaction
block_time Numeric The unix timestamp of the transaction
tx_index Numeric The Transaction Index

History Type

Type Description
send Send token
issuance Issuance token
order Dex order
dividend Dividend token

History Category

Type Description
send Send token
receive Receive token

Order

Order Object represents the order transaction

Attribute Type Description
source String The bitcoin address
give_token String The token name to give
get_token String The token name requested in return
give_quantity Numeric The quantities of the token to give
get_quantity Numeric The quantities of the token requested in return
order_amount Numeric
price Numeric

Order History

Order History Object represents the order history of a public address

Attribute Type Description
type String The type of the order (buy or sell)
give_token String The token name to give
get_token String The token name requested in return
give_quantity Numeric The quantities of the token to give
get_quantity Numeric The quantities of the token requested in return
order_amount Numeric
price Numeric
tx_index Numeric The transaction index of the transaction
tx_hash String The hash of the the order transaction
block_index Numeric The block height of the transaction
status String The status of the transaction
block_time Numeric The unix timestamp of the transaction
time String The time of the transaction

Address API

IndieSquare’s Address API allows you to look up information on a particular token about public addresses on the blockchain.

Balance

curl https://api.indiesquare.me/v2/addresses/17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW/balances
echo $client->get('https://api.indiesquare.me/v2/addresses/17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW/balances')->getBody();
[
   {
      "token":"BTC",
      "balance":0.0004203,
      "unconfirmed_balance":0
   },
   {
      "token":"XCP",
      "balance":0,
      "unconfirmed_balance":0
   }
]

The Address Balance Endpoint is a method to get a subset of information on a public address.

Resource Method Return Object
/addresses/:address/balances GET Array[Balance]

Issued Token

curl https://api.indiesquare.me/v2/addresses/1965areciqapsuL2hsia2yKkRLfAsH1smG/issuances
echo $client->get('https://api.indiesquare.me/v2/addresses/1965areciqapsuL2hsia2yKkRLfAsH1smG/issuances')->getBody();
[
  {
    "quantity": 1000,
    "token": "YOKAN",
    "description": "res.indiesquare.me/json/YOKAN.json",
    "token_image_url": "https://api.indiesquare.me/v2/tokens/YOKAN/image",
    "issuer": "1965areciqapsuL2hsia2yKkRLfAsH1smG",
    "divisible": 1,
    "locked": 0,
    "holder_count": 0
  },
  {
    "quantity": 2000,
    "token": "DORAYAKI",
    "description": "res.indiesquare.me/json/DORAYAKI.json",
    "token_image_url": "https://api.indiesquare.me/v2/tokens/DORAYAKI/image",
    "issuer": "1965areciqapsuL2hsia2yKkRLfAsH1smG",
    "divisible": 1,
    "locked": 0,
    "holder_count": 1
  },
  {
    "quantity": 0,
    "token": "ZONO",
    "description": "res.indiesquare.me/json/ZONO.json",
    "token_image_url": "https://api.indiesquare.me/v2/tokens/ZONO/image",
    "issuer": "1965areciqapsuL2hsia2yKkRLfAsH1smG",
    "divisible": 1,
    "locked": 0,
    "holder_count": 9
  },
  {
    "quantity": 1000,
    "token": "KARUKAN",
    "description": "res.indiesquare.me/json/KARUKAN.json",
    "token_image_url": "https://api.indiesquare.me/v2/tokens/KARUKAN/image",
    "issuer": "1965areciqapsuL2hsia2yKkRLfAsH1smG",
    "divisible": 1,
    "locked": 0,
    "holder_count": 0
  }
]

The Issued Token Endpoint Endpoint is a method to get issued token information.

Resource Method Return Object
/addresses/:address/issuances GET Array[Token]

UTXO

curl https://api.indiesquare.me/v2/addresses/17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW/utxos
echo $client->get('https://api.indiesquare.me/v2/addresses/17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW/utxos')->getBody();
[
   {
      "address":"17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW",
      "txid":"56af33a1bc4b9fd4b06547bcc8300cacd6ba17b5f741df15ee3e35ad77f6a83d",
      "vout":0,
      "script_pub_key":"76a9144479f825a8038e88d756acbafa6c0c079a79052288ac",
      "amount":0.0002131,
      "confirmations":12198,
      "time":1462241727
   },
   {
      "address":"17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW",
      "txid":"deeaafaa9987839fc734760ae05c82929d51847906878dc09811b4cfbb21626c",
      "vout":0,
      "script_pub_key":"76a9144479f825a8038e88d756acbafa6c0c079a79052288ac",
      "amount":0.0002072,
      "confirmations":12792,
      "time":1461910714
   }
]

The Address UTXO Endpoint is a method to get utxos on a public address.

Resource Method Return Object
/addresses/:address/utxos GET Array[UTXO]

History

curl https://api.indiesquare.me/v2/addresses/17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW/history
echo $client->get('https://api.indiesquare.me/v2/addresses/17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW/history')->getBody();
[
  {
    "type": "send",
    "quantity": "0.0002131",
    "tx_index": 9999999999,
    "source": "159SrNLB6JmQC6HTXpEZ7rDVQ12idajhrf",
    "destination": "17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW",
    "block_time": 1462241727,
    "category": "Receive",
    "time": "2016-05-03T02:15:27+0000",
    "token": "BTC"
  },
  {
    "type": "send",
    "quantity": "0.0002072",
    "tx_index": 10000000000,
    "source": "159SrNLB6JmQC6HTXpEZ7rDVQ12idajhrf",
    "destination": "17F54d4S9aLpvUEsk7MkYWafmzxJhhb9wW",
    "block_time": 1461910714,
    "category": "Receive",
    "time": "2016-04-29T06:18:34+0000",
    "token": "BTC"
  }
]

The History Endpoint is a method to get history of the public address.

Resource Method Return Object
/addresses/:address/history GET Array[History]

Order History

curl https://api.indiesquare.me/v2/addresses/1H1T5mwiyhbXa9Xn3NVr99fLJSLw5csiwA/orderhistory
echo $client->get('https://api.indiesquare.me/v2/addresses/1H1T5mwiyhbXa9Xn3NVr99fLJSLw5csiwA/orderhistory')->getBody();
[
   {
      "type":"buy",
      "give_token":"XCP",
      "get_token":"ZAIF",
      "give_quantity":25,
      "get_quantity":10000,
      "order_amount":10000,
      "price":0.0025,
      "tx_index":516681,
      "tx_hash":"955fce552ca16c401de15ebeb336449b7231c43693a082b05605806978dbfa63",
      "block_index":422162,
      "status":"open",
      "block_time":1469416918,
      "time":"2016-07-25T03:21:58+0000"
   },
   {
      "type":"sell",
      "give_token":"XCP",
      "get_token":"ZAIF",
      "give_quantity":25,
      "get_quantity":10000,
      "order_amount":25,
      "price":400,
      "tx_index":516681,
      "tx_hash":"955fce552ca16c401de15ebeb336449b7231c43693a082b05605806978dbfa63",
      "block_index":422162,
      "status":"open",
      "block_time":1469416918,
      "time":"2016-07-25T03:21:58+0000"
   }
]

The Order History Endpoint is a method to get order history of the public address.

Resource Method Return Object
/addresses/:address/orderhistory GET Array[Order History]

Token API

IndieSquare’s Token API allows you to look up information about token information.

curl https://api.indiesquare.me/v2/tokens?name=CNP
echo $client->get('https://api.indiesquare.me/v2/tokens?name=CNP')->getBody();
[
  {
    "token": "CNPCARD",
    "token_image_url": "https://api.indiesquare.me/v2/tokens/CNPCARD/image"
  },
  {
    "token": "CNPCOIN",
    "token_image_url": "https://api.indiesquare.me/v2/tokens/CNPCOIN/image"
  }
]

The Token Search Endpoint is a method to search token by name.

Resource Method Return Object
/tokens GET Array[Token]
Parameter Type Description
name String The name of the token.

Token

curl https://api.indiesquare.me/v2/tokens/CNPCOIN
echo $client->get('https://api.indiesquare.me/v2/tokens/CNPCOIN')->getBody();
{
  "token": "CNPCOIN",
  "description": "Currency for Coin and Peace blog ",
  "divisible": 1,
  "issuer": "1Na5Z6ZsKrD6TyhGZNRxsK75caiWqpwTCK",
  "quantity": 21000000,
  "locked": 0,
  "token_image_url": "https://api.indiesquare.me/v2/tokens/CNPCOIN/image"
}

Token Endpoint is a method to look up the detailed information of a particular token.

Resource Method Return Object
/tokens/:token GET Token

Token Image

https://api.indiesquare.me/v2/tokens/SARUTOBICARD/image
$client->get('https://api.indiesquare.me/v2/tokens/SARUTOBICARD/image')

Token Image Endpoint is a method to get a token image.

Resource Method Return Object
/tokens/:token/image GET Image Data
Parameter Type Description
width Numeric The width of the image (1〜1024)
height Numeric The height of the image (1〜1024)

Example (SARUTOBICARD)

https://api.indiesquare.me/v2/tokens/SARUTOBICARD/image

https://api.indiesquare.me/v2/tokens/SARUTOBICARD/image?width=100

The height will be a calculated value that maintains the aspect ratio.

https://api.indiesquare.me/v2/tokens/SARUTOBICARD/image?width=50&height=50

The width and height of the returned image are exactly the params (width and height). Aspect ratio will not be maintained.

Token Holders

curl https://api.indiesquare.me/v2/tokens/KAMON/holders
echo $client->get('https://api.indiesquare.me/v2/tokens/KAMON/holders')->getBody();
[
   {
      "name":"cameong",
      "address":"13GMnzsri7mkNoZraR9NSFAZ8v4P6pRTc4",
      "quantity":999972180,
      "ratio":0.99997218
   },
   {
      "name":"Yuta Hoshino",
      "address":"1FVQopV1jYpTFAfD5RnJkftcbpQxQ7Bbo",
      "quantity":11500.4,
      "ratio":1.15004e-5
   },
   {
      "name":"-",
      "address":"1AVDJcAwKTfoYSLc93H7crbd9WE8CFmfob",
      "quantity":1017.5,
      "ratio":1.0175e-6
   }
]

Token Holder Endpoint is a method to show token holder information of a particular token.

Resource Method Return Object
/tokens/:token/holders GET [Token Holder]

Transaction API

IndieSquare’s Transaction API allows you to create transactions and broadcast transactions.

Create Send Transaction

curl -H "Content-Type: application/json" -X POST -d '{"source": "1965areciqapsuL2hsia2yKkRLfAsH1smG", "token": "NETX", "destination": "12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD", "quantity": 1}' https://api.indiesquare.me/v2/transactions/send
echo $client->request('POST', 'https://api.indiesquare.me/v2/transactions/send', [
    'json' => ['source' => '1965areciqapsuL2hsia2yKkRLfAsH1smG', 'destination' => '12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD', 'token' => 'NETX', 'quantity' => 1]
])->getBody();
{
   "unsigned_tx":"010000000414ae2264cdbe754b9ae4be18d84bfeb4f578af553b9b9e4f9cb2303d04ee9e45000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffffec15d27b74516fefd921cecbe043ea63124d28a3903aef8fb1682ccc926b1c62000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffff9878f76e1424c1d1eeb6b15d06902dd8f0c78f9bdb61263e4ca3ae68c571a292000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acfffffffffdac7f1c83b01a8924a8965d356b804c2608bc261fc18041116ddb4a143bc499000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffff0336150000000000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88ac00000000000000001e6a1c246698efc5d81b78ceadf3179316b5eb6cc5c2c347c0b7b42121a94e92180000000000001976a91458b6e991b45487df810f4d96d5315da739637f1788ac00000000"
}

Create Send Transaction Endpoint is a method to create a send transaction and return the unsigned_tx.

Resource Method Return Object
/transactions/send POST {unsigned_tx}
Parameter Type Description
source String The address that will be sending
destination String The address to receive the asset
token String The token name
quantity Numeric The quantities of the asset to send
fee Numeric The specific custom miners’ fee (in satoshi, optional)
fee_per_kb Numeric The fee per kilobyte of transaction data (in satoshi, optional)

Create Issuance Transaction

curl -H "Content-Type: application/json" -X POST -d '{"source": "12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD", "quantity": 1000, "token": "NETX", "divisible": true}' https://api.indiesquare.me/v2/transactions/issuance
echo $client->request('POST', 'https://api.indiesquare.me/v2/transactions/issuance', [
    'json' => ['source' => '12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD', 'quantity' => 1000, 'token' => 'NETX', 'divisible' => true]
])->getBody();
{
   "unsigned_tx":"0100000003cf04cdee0414cdd88008f3b6d690fc2ac0d6b18a99e693ea3b466a1d0c3c1139010000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88acffffffffb542474ee36c7019a7117862425c0cb34cb92fe175312a0517a6a0a363c38d54020000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88acffffffff1381cc7606abcaa79c187a41c576618fdc7d6fb97b86b75974f008924199e3c2020000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88acffffffff0200000000000000004b6a4999535ee47f76e6f29ebaf0c4645b1c81f4caa606afd34af989476a9f2324ad799c4a32dfd4bf08d8309225f4e0335c8b5c75a408ab9db67b62bf48c9f5f1c8f91b2775c20e48d8465b54290000000000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88ac00000000"
}

Create Issuance Transaction Endpoint is a method to create an issuance token transaction and return the unsigned_tx.

Resource Method Return Object
/transactions/issuance POST {unsigned_tx}
Parameter Type Description
source String The address that will be sending
token String The token name
quantity Numeric The quantities of the asset to send
divisible Boolean true = divisible, false = divisible
fee Numeric The specific custom miners’ fee (in satoshi, optional)
fee_per_kb Numeric The fee per kilobyte of transaction data (in satoshi, optional)

Create Order Transaction

curl -H "Content-Type: application/json" -X POST -d '{"source": "12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD", "give_quantity": 10, "give_token": "NETX", "get_quantity": 1, "get_token": "XCP", "expiration": 100}' https://api.indiesquare.me/v2/transactions/order
echo $client->request('POST', 'https://api.indiesquare.me/v2/transactions/order', [
    'json' => ['source' => '12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD', 'give_quantity' => 10, 'give_token' => 'NETX', 'get_quantity' => 1, 'get_token' => 'XCP', 'expiration' => 100]
])->getBody();
{
   "unsigned_tx":"0100000003cf04cdee0414cdd88008f3b6d690fc2ac0d6b18a99e693ea3b466a1d0c3c1139010000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88acffffffffb542474ee36c7019a7117862425c0cb34cb92fe175312a0517a6a0a363c38d54020000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88acffffffff1381cc7606abcaa79c187a41c576618fdc7d6fb97b86b75974f008924199e3c2020000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88acffffffff0200000000000000004b6a4999535ee47f76e6f29ebaf0c4645b1c81f4caa606afd34af989476a9f2324ad799c4a32dfd4bf08d8309225f4e0335c8b5c75a408ab9db67b62bf48c9f5f1c8f91b2775c20e48d8465b54290000000000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88ac00000000"
}

Create Order Transaction Endpoint is a method to create a DEX order and return the unsigned_tx.

Resource Method Return Object
/transactions/order POST {unsigned_tx}
Parameter Type Description
source String The address that will be issuing the order request
give_quantity Numeric The quantities of the asset to give
give_token String The assets to give
get_quantity Numeric The quantities of the asset requested in return
get_token String The assets requested in return
expiration Numeric The number of blocks for which the order should be valid
fee Numeric The specific custom miners’ fee (in satoshi, optional)
fee_per_kb Numeric The fee per kilobyte of transaction data (in satoshi, optional)

Create Cancel Transaction

curl -H "Content-Type: application/json" -X POST -d '{"source": "1MZUJyKLHsSthHY3z68NxLFPhnrDcsPaDk", "offer_hash": "ea8f9eeb36ed8c3001f4c572796d450514b19f108e3d3f35d8631004c5871fbf"}' https://api.indiesquare.me/v2/transactions/cancel
echo $client->request('POST', 'https://api.indiesquare.me/v2/transactions/cancel', [
    'json' => ['source' => '1MZUJyKLHsSthHY3z68NxLFPhnrDcsPaDk', 'offer_hash' => 'ea8f9eeb36ed8c3001f4c572796d450514b19f108e3d3f35d8631004c5871fbf']
])->getBody();
{
   "unsigned_tx":"0100000001bf1f87c5041063d8353f3d8e109fb11405456d7972c5f401308ced36eb9e8fea010000001976a914e1869fa1cec7741a502e7a5bd938ed8f5e354b5488acffffffff0200000000000000002e6a2c0b0b8cb664864cdf2ff70668595e63567b9d8ece36b2383513b6eeab7f1c15e70466593f13bb49618b8afe7079e93a00000000001976a914e1869fa1cec7741a502e7a5bd938ed8f5e354b5488ac00000000"
}

Create Order Cancel Transaction Endpoint is a method to create a DEX order cancel transaction and return the unsigned_tx.

Resource Method Return Object
/transactions/cancel POST {unsigned_tx}
Parameter Type Description
source String The address that will be issuing the order request
offer_hash String The transaction hash of the order
fee Numeric The specific custom miners’ fee (in satoshi, optional)
fee_per_kb Numeric The fee per kilobyte of transaction data (in satoshi, optional)

Broadcast Transaction

curl -H "Content-Type: application/json" -X POST -d '{"tx": "0100000001bf1f87c5041063d8353f3d8e109fb11405456d7972c5f401308ced36eb9e8fea010000001976a914e1869fa1cec7741a502e7a5bd938ed8f5e354b5488acffffffff0200000000000000002e6a2c0b0b8cb664864cdf2ff70668595e63567b9d8ece36b2383513b6eeab7f1c15e70466593f13bb49618b8afe7079e93a00000000001976a914e1869fa1cec7741a502e7a5bd938ed8f5e354b5488ac00000000"}' https://api.indiesquare.me/v2/transactions/broadcast
echo $client->request('POST', 'https://api.indiesquare.me/v2/transactions/broadcast', [
    'json' => ['tx' => '0100000001bf1f87c5041063d8353f3d8e109fb11405456d7972c5f401308ced36eb9e8fea010000001976a914e1869fa1cec7741a502e7a5bd938ed8f5e354b5488acffffffff0200000000000000002e6a2c0b0b8cb664864cdf2ff70668595e63567b9d8ece36b2383513b6eeab7f1c15e70466593f13bb49618b8afe7079e93a00000000001976a914e1869fa1cec7741a502e7a5bd938ed8f5e354b5488ac00000000']
])->getBody();
{
   "txid":"0100000001bf1f87c5041063"
}

Broadcast Transaction Endpoint is a method to broadcast the signed transaction and return the txid.

Resource Method Return Object
/transactions/broadcast POST {txid}
Parameter Type Description
tx String The signed transaction

Decode Transaction

curl -H "Content-Type: application/json" -X POST -d '{"tx": "010000000414ae2264cdbe754b9ae4be18d84bfeb4f578af553b9b9e4f9cb2303d04ee9e45000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffffec15d27b74516fefd921cecbe043ea63124d28a3903aef8fb1682ccc926b1c62000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffff9878f76e1424c1d1eeb6b15d06902dd8f0c78f9bdb61263e4ca3ae68c571a292000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acfffffffffdac7f1c83b01a8924a8965d356b804c2608bc261fc18041116ddb4a143bc499000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffff0336150000000000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88ac00000000000000001e6a1c246698efc5d81b78ceadf3179316b5eb6cc5c2c347c0b7b42121a94e92180000000000001976a91458b6e991b45487df810f4d96d5315da739637f1788ac00000000"}' https://api.indiesquare.me/v2/transactions/decode
echo $client->request('POST', 'https://api.indiesquare.me/v2/transactions/decode', [
    'json' => ['tx' => '010000000414ae2264cdbe754b9ae4be18d84bfeb4f578af553b9b9e4f9cb2303d04ee9e45000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffffec15d27b74516fefd921cecbe043ea63124d28a3903aef8fb1682ccc926b1c62000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffff9878f76e1424c1d1eeb6b15d06902dd8f0c78f9bdb61263e4ca3ae68c571a292000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acfffffffffdac7f1c83b01a8924a8965d356b804c2608bc261fc18041116ddb4a143bc499000000001976a91458b6e991b45487df810f4d96d5315da739637f1788acffffffff0336150000000000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88ac00000000000000001e6a1c246698efc5d81b78ceadf3179316b5eb6cc5c2c347c0b7b42121a94e92180000000000001976a91458b6e991b45487df810f4d96d5315da739637f1788ac00000000']
])->getBody();
{
   "txid":"6c521937d8fa889d71609ebed2e23b694cbca89778c8b8d967167e5a4c9d5b78",
   "version":1,
   "locktime":0,
   "vin":[
      {
         "txid":"459eee043d30b29c4f9e9b3b55af78f5b4fe4bd818bee49a4b75becd6422ae14",
         "vout":0,
         "scriptSig":{
            "asm":"OP_DUP OP_HASH160 58b6e991b45487df810f4d96d5315da739637f17 OP_EQUALVERIFY OP_CHECKSIG",
            "hex":"76a91458b6e991b45487df810f4d96d5315da739637f1788ac"
         },
         "sequence":4294967295
      }
   ],
   "vout":[
      {
         "value":5.43e-5,
         "n":0,
         "scriptPubKey":{
            "asm":"OP_DUP OP_HASH160 1485d9d03b41aaa9dca7d70d7f63ff4a0826100e OP_EQUALVERIFY OP_CHECKSIG",
            "hex":"76a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88ac",
            "reqSigs":1,
            "type":"pubkeyhash",
            "addresses":[
               "12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD"
            ]
         }
      },
      {
         "value":0,
         "n":1,
         "scriptPubKey":{
            "asm":"OP_RETURN 246698efc5d81b78ceadf3179316b5eb6cc5c2c347c0b7b42121a94e",
            "hex":"6a1c246698efc5d81b78ceadf3179316b5eb6cc5c2c347c0b7b42121a94e",
            "type":"nulldata"
         }
      },
      {
         "value":6.29e-5,
         "n":2,
         "scriptPubKey":{
            "asm":"OP_DUP OP_HASH160 58b6e991b45487df810f4d96d5315da739637f17 OP_EQUALVERIFY OP_CHECKSIG",
            "hex":"76a91458b6e991b45487df810f4d96d5315da739637f1788ac",
            "reqSigs":1,
            "type":"pubkeyhash",
            "addresses":[
               "1965areciqapsuL2hsia2yKkRLfAsH1smG"
            ]
         }
      }
   ]
}

Decode Transaction Endpoint is a method to decode the hex.

Resource Method Return Object
/transactions/decode POST {Decoded Transaction}
Parameter Type Description
tx String Transaction Hex

Order API

IndieSquare’s Order API allows you to get order transactions.

Order Book

curl https://api.indiesquare.me/v2/orders/CNPCOIN/book
echo $client->get('https://api.indiesquare.me/v2/orders/CNPCOIN/book')->getBody();
{
   "bid":[
      {
         "source":"1M6aLABuidphUhj8zEcdj54BzpumwiPaj5",
         "give_token":"XCP",
         "give_quantity":0.96,
         "get_token":"CNPCOIN",
         "order_amount":120,
         "get_quantity":120,
         "price":0.008
      }
   ],
   "ask":[
      {
         "source":"19oiQTQMYedkxH47Xd1UkrL6QePHM7Jud9",
         "give_token":"CNPCOIN",
         "order_amount":1848.61714456,
         "give_quantity":1848.61714456,
         "get_token":"XCP",
         "get_quantity":33.2751086,
         "price":0.017999999998875
      }
   ]
}

The Order Book Endpoint is a method to get the list of orders on a token

Resource Method Return Object
/orders/:token/book GET {“bit”:Array[Order], “ask”:Array[Order]}

Order History Book

curl https://api.indiesquare.me/v2/orders/LTBCOIN/history
echo $client->get('https://api.indiesquare.me/v2/orders/LTBCOIN/history')->getBody();
[
   {
      "type":"buy",
      "give_token":"XCP",
      "give_quantity":0.00056997,
      "get_token":"LTBCOIN",
      "get_quantity":56.94005923,
      "status":"completed",
      "price":1.0010000124828e-5,
      "block_index":421635,
      "block_time":1469064341,
      "time":"2016-07-21T01:25:41+0000"
   },
   {
      "type":"sell",
      "give_token":"LTBCOIN",
      "give_quantity":27.05594406,
      "get_token":"XCP",
      "get_quantity":0.00027083,
      "status":"completed",
      "price":1.0009999998499e-5,
      "block_index":421635,
      "block_time":1469064341,
      "time":"2016-07-21T01:25:41+0000"
   }
]

The Order History Endpoint is a method to get the order history on a token

Resource Method Return Object
/orders/:token/history GET Array[Order]

Market/Fees API

IndieSquare’s Market/Fees API allows you to get market and transaction fee information.

Ticker

curl https://api.indiesquare.me/v2/market/ticker
echo $client->get('https://api.indiesquare.me/v2/market/ticker')->getBody();
{
   "AUD":{
      "last":879.8,
      "symbol":"$"
   },
   "CAD":{
      "last":861.89,
      "symbol":"$"
   },

   .
   .
   .

   "USD":{
      "last":656.75,
      "symbol":"$"
   },
   "XCP":{
      "last":"0.00467149",
      "symbol":"XCP"
   }
}

Ticker Endpoint is a method to get exchange rates between BTC and some currencies.

Resource Method Return Object
/market/ticker GET {Exchange Rate}

Token Price

curl https://api.indiesquare.me/v2/market/CNPCOIN/price
echo $client->get('https://api.indiesquare.me/v2/market/CNPCOIN/price')->getBody();
{
   "BTC":{
      "price":0.008
   }
}

Token Price Endpoint is a method to get exchange rates between BTC and a token.

Resource Method Return Object
/market/:token/price GET {Exchange Rate}
curl https://api.indiesquare.me/v2/fees/recommended
echo $client->get('https://api.indiesquare.me/v2/fees/recommended')->getBody();
{
   "fastestFee":60906,
   "halfHourFee":39059,
   "hourFee":26786,
   "unit":"satoshis_per_kb"
}

Fee Endpoint is a method to get recommended transaction fees.

Resource Method Return Object
/fees/recommended GET {Recommended Transaction Fees}

System Status API

IndieSquare’s Status API allows you to get IndieSquare’s service status.

Reorg

curl https://api.indiesquare.me/v2/status/reorg
echo $client->get('https://api.indiesquare.me/v2/status/reorg')->getBody();
{
   "isReorg":false
}

Reorg Endpoint is a method to get the reorg status.

Resource Method Return Object
/status/reorg GET {Reorg status}

WebSocket and Webhook

IndieSquare provides two type of real-time notifications.

WebSocket

<html>
  <head>
  <title>IndieSquare WebSocket Test</title>
  <script>
    function init() {
      websocket = new WebSocket("wss://ws.indiesquare.me");
      websocket.onopen = function() { document.getElementById("output").innerHTML += "<p>> CONNECTED</p>"; };
      websocket.onmessage = function(evt) { document.getElementById("output").innerHTML += "<p style='color: blue;'>> RESPONSE: " + evt.data + "</p>"; };
    }
    window.addEventListener("load", init, false);
  </script>
  </head>
  <body>
    <div id="output"></div>
  </body>
</html>

---

> CONNECTED
> RESPONSE:
{
   "event":"new-tx",
   "transaction":{
      "type":"send",
      "source":"16Huc2gVydUnMMskVQnLTfvmL6eL1nFBEX",
      "destination":"1AeqgtHedfA2yVXH6GiKLS2JGkfWfgyTC6",
      "token":"DATABITS",
      "quantity":10000
   }
}

wss://ws.indiesquare.me is WebSocket connection URL.

Webhook

IndieSquare’s Webhook API allows you to get filtered real-time token transfer data.

Create WebHook Endpoint

curl -H 'X-Api-Key:YOUR_API_KEY' -H "Content-Type: application/json" -X POST -d '{"event": "new-block", "url": "http://requestb.in/1jmyngh2"}' https://api.indiesquare.me/v2/webhooks

{
   "event":"new-block",
   "url":"http:\/\/requestb.in\/1jmyngh2",
   "id":"dde8db44513d92f0f7b2ff4e7ac163df"
}

Create WebHook Endpoint is a method to create a webhook.

Resource Method Return Object
/webhooks POST -
Parameter Type Description
event String The event type; “new-block”, “new-tx”
url String The webhook url
type String The type of transaction; “send”, “order”, “cancel”, “issuance”
token String The token name
address String The bitcoin address

List WebHooks Endpoint

curl -H 'X-Api-Key:YOUR_API_KEY' https://api.indiesquare.me/v2/webhooks

[
   {
      "id":"dde8db44513d92f0f7b2ff4e7ac163df",
      "event":"new-block"
   }
]

List WebHooks Endpoint is a method to get your webhook list.

Resource Method Return Object
/webhooks GET -

WebHook ID Endpoint

curl -H 'X-Api-Key:YOUR_API_KEY' https://api.indiesquare.me/v2/webhooks/dde8db44513d92f0f7b2ff4e7ac163df

{
   "id":"dde8db44513d92f0f7b2ff4e7ac163df",
   "event":"new-block"
}

WebHook ID Endpoint is a method to get a webhook.

Resource Method Return Object
/webhooks/:id GET -

Delete WebHook Endpoint

curl -H 'X-Api-Key:YOUR_API_KEY' -X DELETE https://api.indiesquare.me/v2/webhooks/dde8db44513d92f0f7b2ff4e7ac163df

Delete WebHook Endpoint is a method to delete a webhook.

Resource Method Return Object
/webhooks/:id DELETE -

SDK

The IndieSquare Blockchain Platform and SDK makes it easy to implement decentralized applications. The SDK is fully integrated with the IndieSquare service for managing your tokens on blockchain.

Initialize SDK

<script src="https://cdn.indiesquare.me/v0.1.0/indiesquare.js"></script>

var indiesquare = new IndieSquare();
We do not have PHP SDK but you can sign transactions by using PHP bitcoin libraries.

・composer.json

"require": {
  "guzzlehttp/guzzle": "6.*",
  "bitwasp/bitcoin": "v0.0.7",
  "bitwasp/buffertools": "v0.1.8",
  "mdanter/ecc": "v0.3.*"
}

・sample.php

<?php

use GuzzleHttp\Client;
use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Key\PrivateKeyFactory;
use BitWasp\Bitcoin\Transaction\TransactionBuilder;
use BitWasp\Bitcoin\Transaction\TransactionFactory;

require 'vendor/autoload.php';

// Create Send Transaction

$client = new GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.indiesquare.me/v2/transactions/send',[
        'json' => ['source' => '13H53e9HCtjb2W7C8rJC9MnDdGp5zYdCPy', 'destination' => '13wHEC9vgvhYyTbPCyEjLWq9TgGUf8Rv9p', 'token' => 'XZCOIN', 'quantity' => 1]
])->getBody();

// Decode Hex to Transaction object

$transaction = TransactionFactory::fromHex(json_decode($response)->unsigned_tx);
$builder = new TransactionBuilder(Bitcoin::getEcAdapter(), $transaction);

// Private Key

$privKey = PrivateKeyFactory::fromWif('PRIVATE_KEY');

// Sign
foreach ($transaction->getInputs()->getInputs() as $idx => $input) {
    $outputScript = $input->getScript();
    $builder->signInputWithKey($privKey, $outputScript, $idx);
}

// Broadcast
$response = $client->request('POST', 'https://api.indiesquare.me/v2/transactions/broadcast',[
        'json' => ['tx' => $builder->getTransaction()->getHex()]
])->getBody();

echo json_decode($response)->txid;

Send

var params = {
  source : '1965areciqapsuL2hsia2yKkRLfAsH1smG',
  token : 'NETX',
  destination : '12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD',
  quantity : 1
}

indiesquare.send(params, function(unsignedTx, error) {
  console.log(unsignedTx);
});

Send is a method to create a send transaction and return the unsigned_tx.

Method Return Object
send(params, callback(unsignedTx, error)) unsignedTx

Issuance

var params = {
    source: '12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD',
    quantity: 1000,
    token: 'NETX',
    divisible: true
}

indiesquare.issuance(params, function(unsignedTx, error) {
  console.log(unsignedTx);
});

Issuance is a method to create an issuance transaction and return the unsigned_tx.

Method Return Object
issuance(params, callback(unsignedTx, error)) unsignedTx

Order

var params = {
    source: '12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD',
    give_quantity: 10,
    give_token: 'NETX',
    get_quantity: 1,
    get_token: 'XCP',
    expiration: 100
}

indiesquare.order(params, function(unsignedTx, error) {
  console.log(unsignedTx);
});

Order is a method to create an order transaction and return the unsigned_tx.

Method Return Object
order(params, callback(unsignedTx, error)) unsignedTx

Order Cancel

var params = {
    source: '12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD',
    offer_hash: 'e4f6d3da5ec41aeeda0c4df78636d06a1eebbbfe77217d39b7908580b4d73058'
}

indiesquare.cancel(params, function(unsignedTx, error) {
  console.log(unsignedTx);
});

Order Cancel is a method to create an order cancel transaction and return the unsigned_tx.

Method Return Object
cancel(params, callback(unsignedTx, error)) unsignedTx

Sign & Broadcast

indiesquare.signByApp(unsignedTx, connect, success, error);

We recommend you sign and broadcast a transaction via the IndieSquare Wallet app so that your private key is not exposed from your app and very easy to use.

Method Return Object
signByApp(unsignedTx, connect(data, urlScheme, error), sign(txid, error)) txid

Example (Send Transaction)

<script src="https://cdn.indiesquare.me/v0.1.0/indiesquare.js"></script>
<script src="https://cdn.rawgit.com/davidshimjs/qrcodejs/master/qrcode.min.js"></script>
<script>

var indiesquare = new IndieSquare();

var params = {
  source : '1965areciqapsuL2hsia2yKkRLfAsH1smG',
  token : 'NETX',
  destination : '12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD',
  quantity : 1
}

indiesquare.send(params, function(unsignedTx, error) {

  var connect = function (data, urlScheme, error) {
    if (urlScheme) {
      document.location = urlScheme;
    } else {
      new QRCode(document.getElementById('qrcode'), data);
    }
  }

  var sign = function (txid, error) {
    console.log('sign and broadcast are done. txid = ' + txid);
  }

  indiesquare.signByApp(unsignedTx, connect, sign);
});
</script>
<div id="qrcode" />
  1. Save this code as index.html and open it.
  2. QR code will be displayed and read it from IndieSquare wallet app system-link function.
  3. Sign dialog will be opened on the app. Unlock by fingerprint authentication or pin code.
  4. Sign callback will be called and will show the txid on console.