Bitcoin (BTC)
General Information
Get Node Information
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/mainnet/info' \
-H 'ContentType: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/info HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
}
});
$.get('https://api.cryptoapis.io/v1/bc/btc/mainnet/info').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/info",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/info');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/info")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/info'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
response = requests.get(url, headers=headers)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/info")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
Get("https://api.cryptoapis.io/v1/bc/btc/mainnet/info")
}
Response Body
{
"payload": {
"difficulty": 7182852313938.317,
"headers": 546904,
"chain": "main",
"chainWork": "000000000000000000000000000000000000000003b8fe71a1bf647effbc862f",
"mediantime": 1540234846,
"blocks": 546904,
"bestBlockHash": "0000000000000000001c940339b65f3c1d85006041e9602bc9bda2c495e2ca82",
"currency": "BTC",
"transactions": 342149347,
"verificationProgress": 0.9999964749471614
}
}
Info
General information about a blockchain is available by GET-ing the base resource.
HTTP Request
GET /v1/bc/btc/${NETWORK}/info
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
The returned object contains a litany of information about the blockchain, including its height, the time/hash of the latest block, and more.
Get Block By Hash
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/blocks/0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381 HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
}
});
$.get('https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/blocks/0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
response = requests.get(url, headers=headers)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
Get("https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381")
}
Response Body
{
"payload": {
"hash": "00000000000000000009917a263a01b80d3cbe6e69b562a29d62de9170551be8",
"strippedsize": 909570,
"size": 1264413,
"weight": 3993123,
"height": 564349,
"version": 536870912,
"versionHex": "20000000",
"merkleroot": "95439d11e918c9fd9a901dcf22203d60f538d660ae74efb7cb566825420fd3b7",
"time": "2019-02-23 17:33:30 UTC", //deprecated
"datetime": "2019-02-23 17:33:30 UTC",
"mediantime": "2019-02-23 16:53:23 UTC",
"nonce": 117587101,
"bits": "172e6f88",
"difficulty": 6061518831027.271,
"chainwork": "00000000000000000000000000000000000000000532b1d8837e5d34f183a10a",
"previousblockhash": "0000000000000000002b4efdd796d0288213b7d2f2849ec95e9be9a9a722e5e6",
"nextblockhash": "0000000000000000002aa120a6e7200a6a726f15b793b41868acf2a7b24f1850",
"transactions": 3004,
"tx":[
"347d96855d41b77f1e23048fff11c18e9fe699ee69b0b402338f34189734e0a2",
...
"6bb1b2dc66d2dde53aebcebb8ecef19a69f77322dab2fdbc8e6088bfbda13649"
],
"confirmations": 1,
"timestamp": 1550943210
}
}
Info
Block Hash endpoint gives you detail information for particular block in the blockchain
HTTP Request
GET /v1/bc/btc/${NETWORK}/blocks/${BLOCK_HASH}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
BLOCK_HASH | ------- | Hash of the block in blockchain |
BLOCK_HASH is a string
representing the hash of the block you’re interested in querying, for example:
0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381
The returned object contains information about the block in JSON format, including its height, the number of transactions in it, transaction hashes listed in the canonical order in which they appear in the block, and more.
Get Block by Height
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/546903' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/blocks/546903 HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
}
});
$.get('https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/546903').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/blocks/546903",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/546903');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/546903")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/546903'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
response = requests.get(url, headers=headers)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/546903")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
Get("https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/546903")
}
Response Body
{
"payload": {
"hash": "00000000000000000009917a263a01b80d3cbe6e69b562a29d62de9170551be8",
"strippedsize": 909570,
"size": 1264413,
"weight": 3993123,
"height": 564349,
"version": 536870912,
"versionHex": "20000000",
"merkleroot": "95439d11e918c9fd9a901dcf22203d60f538d660ae74efb7cb566825420fd3b7",
"time": "2019-02-23 17:33:30 UTC", //deprecated
"datetime": "2019-02-23 17:33:30 UTC",
"mediantime": "2019-02-23 16:53:23 UTC",
"nonce": 117587101,
"bits": "172e6f88",
"difficulty": 6061518831027.271,
"chainwork": "00000000000000000000000000000000000000000532b1d8837e5d34f183a10a",
"previousblockhash": "0000000000000000002b4efdd796d0288213b7d2f2849ec95e9be9a9a722e5e6",
"nextblockhash": "0000000000000000002aa120a6e7200a6a726f15b793b41868acf2a7b24f1850",
"transactions": 3004,
"tx":[
"347d96855d41b77f1e23048fff11c18e9fe699ee69b0b402338f34189734e0a2",
...
"6bb1b2dc66d2dde53aebcebb8ecef19a69f77322dab2fdbc8e6088bfbda13649"
],
"confirmations": 1,
"timestamp": 1550943210
}
}
Info
Block Height endpoint gives you detail information for particular block in the blockchain
HTTP Request
GET /v1/bc/btc/${NETWORK}/blocks/${BLOCK_HEIGHT}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
BLOCK_HEIGHT | ------- | Height of the block in blockchain |
BLOCK_HEIGHT is a integer
representing the height of the block you’re interested in querying, for example:
546903
The returned object contains information about the block in JSON format, including its height, the number of transactions in it, transaction hashes listed in the canonical order in which they appear in the block, and more.
Get Latest Block
Sample Data
curl -X GET https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/latest \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/blocks/latest HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/latest",
"method": "GET",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "GET",
"hostname": [
"https://api.cryptoapis.io"
],
"port": "8021",
"path": [
"v1",
"bc",
"btc",
"mainnet",
"blocks",
"latest"
],
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/latest');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/latest")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("GET", "v1,bc,btc,mainnet,blocks,latest", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/latest")
.get()
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/blocks/latest"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"hash": "0000000000000000001ca87bd09c2fc80a0ef3966c6473553b118583e0a73381",
"strippedsize": 956276,
"size": 1124359,
"weight": 3993187,
"height": 546903,
"version": 536870912,
"versionHex": "20000000",
"merkleroot": "c60a59ea073b3fbe6426da111da042f75a76435b0d0ee05e177749052cfc5e6b",
"time": "2018-10-22 19:46:31 UTC", //deprecated
"datetime": "2018-10-22 19:46:31 UTC",
"mediantime": "2018-10-22 18:50:11 UTC",
"nonce": 3498325829,
"bits": "17272fbd",
"difficulty": 7182852313938.317,
"chainwork": "000000000000000000000000000000000000000003b8f7e937daa747f14ee0a8",
"previousblockhash": "00000000000000000014b10d64dd3e60b038233ccca693b13ce9f1ee6afc26f9",
"transactions": 949,
"tx": [
"89067219fdf8343024cc9f0f4d9016ac7b8e131d19fa05bff1cc08b06bed500d",
...
"7beefdba268eb412dddd7bd422fa4916731dd2e9d1be9666962d7d50202e8316"
],
"confirmations": 17446,
"timestamp": 1540237591
}
}
Info
Latest Block Endpoint gives you detail information for the latest block in the blockchain
HTTP Request
GET /v1/bc/btc/${NETWORK}/blocks/latest
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
The returned object contains information about the latest block in JSON format, including its height, the number of transactions in it and more.
Addresses
Crypto APIs Address API allows you to look up information about public addresses on the blockchain, generate single-use, low-value key pairs with corresponding addresses, help generate multisig addresses, and collect multiple addresses into a single shortcut for address viewing, all based on the coin/chain resource you’ve selected for your endpoints.
If you’re new to blockchains, you can think of public addresses as similar to bank account numbers in a traditional ledger. The biggest differences:
- Anyone can generate a public address themselves (through ECDSA in Bitcoin). No single authority is needed to generate new addresses; it’s just public-private key cryptography.
- Public addresses are significantly more lightweight. Consequently, and unlike traditional bank accounts, you can (and should!) generate new addresses for every transaction.
- Addresses can also leverage pay-to-script-hash, which means they can represent exotic things beyond a single private-public key pair; the most prominent example being multi-signature addresses that require n-of-m signatures to spend.
Get Address Details
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/mainnet/address/1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/address/1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
}
});
$.get('https://api.cryptoapis.io/v1/bc/btc/mainnet/address/1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/address/1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/address/1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/address/1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/address/1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
response = requests.get(url, headers=headers)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/address/1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
Get("https://api.cryptoapis.io/v1/bc/btc/mainnet/address/1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ")
}
Response Body
{
"payload": {
"address": "1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ",
"totalSpent": "50",
"totalReceived": "50",
"balance": "0",
"txi": 1,
"txo": 1,
"txsCount": 2,
"addresses": [
"1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ"
]
}
}
Info
The default Address Endpoint strikes a general information about addresses.
HTTP Request
GET /v1/bc/btc/${NETWORK}/address/${ADDRESS}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
ADDRESS | ------- | Address in blockchain |
ADDRESS is a string representing the public address (or wallet/HD wallet name) you’re interested in querying, for example:
1DBrYbe5U7LGDcHA5tiLCxivZ7JZAGqGhJ
or
mfd1JDV824jpfQkmhYaXtAZGULndSFYudT,mqvMWHkgYGkigx3wiZVhJVDbJhsEkkeKqM,n3WfwHYPuuiiyNK5oJ69Beq4qa2sdHniTV
The second type address is a multisignature address. Since multisignature addresses may be treated as common addresses the following query for the same results is possible:
GET /v1/bc/btc/testnet/address/mfd1JDV824jpfQkmhYaXtAZGULndSFYudT,mqvMWHkgYGkigx3wiZVhJVDbJhsEkkeKqM,n3WfwHYPuuiiyNK5oJ69Beq4qa2sdHniTV
{
"payload": {
"address": "mfd1JDV824jpfQkmhYaXtAZGULndSFYudT,mqvMWHkgYGkigx3wiZVhJVDbJhsEkkeKqM,n3WfwHYPuuiiyNK5oJ69Beq4qa2sdHniTV",
"totalSpent": "0.0001",
"totalReceived": "0.0001",
"balance": "0",
"txi": 1,
"txo": 1,
"txsCount": 2,
"addresses": [
"mfd1JDV824jpfQkmhYaXtAZGULndSFYudT",
"mqvMWHkgYGkigx3wiZVhJVDbJhsEkkeKqM",
"n3WfwHYPuuiiyNK5oJ69Beq4qa2sdHniTV"
]
}
}
The returned object contains information about the address, including its balance in bitcoins and the number of transactions associated with it. The endpoint omits any detailed transaction information, but if that isn’t required by your application, then it’s the fastest and preferred way to get public address information.
Get Multisig Address Details
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/testnet/address/mho4jHBcrNCncKt38trJahXakuaBnS7LK5/multisig' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/address/mho4jHBcrNCncKt38trJahXakuaBnS7LK5/multisig HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
}
});
$.get('https://api.cryptoapis.io/v1/bc/btc/testnet/address/mho4jHBcrNCncKt38trJahXakuaBnS7LK5/multisig').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/address/mho4jHBcrNCncKt38trJahXakuaBnS7LK5/multisig",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/address/mho4jHBcrNCncKt38trJahXakuaBnS7LK5/multisig');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/address/mho4jHBcrNCncKt38trJahXakuaBnS7LK5/multisig")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/testnet/address/mho4jHBcrNCncKt38trJahXakuaBnS7LK5/multisig'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
response = requests.get(url, headers=headers)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/address/mho4jHBcrNCncKt38trJahXakuaBnS7LK5/multisig")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
Get("https://api.cryptoapis.io/v1/bc/btc/testnet/address/mho4jHBcrNCncKt38trJahXakuaBnS7LK5/multisig")
}
Response Body
{
"payload": [
{
"address": "mho4jHBcrNCncKt38trJahXakuaBnS7LK5,mzNwee7papMuTrw6hBwKncVNBeg4oAJy4r",
"totalSpent": "0.0001",
"totalReceived": "0.0002",
"balance": "0.0001",
"txi": 1,
"txo": 2,
"txsCount": 2,
"addresses": [
"mho4jHBcrNCncKt38trJahXakuaBnS7LK5",
"mzNwee7papMuTrw6hBwKncVNBeg4oAJy4r"
]
},
{
"address": "mho4jHBcrNCncKt38trJahXakuaBnS7LK5,mpyqeHi88H46FsFanEJu1cPE7sPuUgwbCL",
"totalSpent": "0.0001",
"totalReceived": "0.0002",
"balance": "0.0001",
"txi": 1,
"txo": 2,
"txsCount": 2,
"addresses": [
"mho4jHBcrNCncKt38trJahXakuaBnS7LK5",
"mpyqeHi88H46FsFanEJu1cPE7sPuUgwbCL"
]
},
...
{
"address": "mho4jHBcrNCncKt38trJahXakuaBnS7LK5,mrSRivjq9L9d2cnoeYGZr1qPUuAbS8YLqD",
"totalSpent": "0.0001",
"totalReceived": "0.0002",
"balance": "0.0001",
"txi": 1,
"txo": 2,
"txsCount": 2,
"addresses": [
"mho4jHBcrNCncKt38trJahXakuaBnS7LK5",
"mrSRivjq9L9d2cnoeYGZr1qPUuAbS8YLqD"
]
}
],
"meta": {
"totalCount": 31,
"index": 0,
"limit": 50,
"results": 31
}
}
Info
The Multisig Address Endpoint strikes a general information about a single address that is involved in multisignature addresses.
HTTP Request
GET /v1/bc/btc/${NETWORK}/address/${ADDRESS}/multisig
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
ADDRESS | ------- | Address in blockchain |
LIMIT | ------- | Limit results |
Meta Response
Variable | Type | Description |
---|---|---|
totalCount | int | Total count of the items in the listing for the given criteria |
index | int | Sequential index number of the items list start position (depends on the skip parameter) for the given criteria |
limit | int | Limit number of the items list (depends on the limit parameter) for the given criteria. |
results | int | Count of the items listed in the current response for the given criteria |
ADDRESS is a string representing the public address (or wallet/HD wallet name) you’re interested in querying, for example:
mho4jHBcrNCncKt38trJahXakuaBnS7LK5
The returned object returns a list of multisignature addresses in which the queried address is involved in, including balance in bitcoins and the number of transactions associated with it, and more.
Generate Address
Sample Data
curl -X POST 'https://api.cryptoapis.io/v1/bc/btc/mainnet/address' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
POST /v1/bc/btc/mainnet/address HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
}
});
$.post('https://api.cryptoapis.io/v1/bc/btc/mainnet/address')
.then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/address",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/address');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/address")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/address'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
response = requests.post(url, headers=headers, data={})
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/address")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
Post("https://api.cryptoapis.io/v1/bc/btc/mainnet/address")
}
Response Body
{
"payload": {
"privateKey": "18da04769fe3c2087ac770351231de97efc3e710544c42a03403c42fe238da85",
"publicKey": "03af90e5ddde840eea6db1b80f90adc44031d182c838d983b458dd92a21f93ada2",
"address": "12zCbo4dXBqtsbU6FZgsovdDR93t1zQirb",
"wif": "Kx424rXfrRMyuYhTtJEkQeHe4AtQVe7noV5DJ5qn32XJWgwwVFQm"
}
}
Info
The Generate Address endpoint allows you to generate private-public key-pairs along with an associated public address. No information is required with this POST request.
HTTP Request
POST /v1/bc/btc/${NETWORK}/address
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
The returned object contains a private key in hex-encoded and wif-encoded format, a public key, and a public address.
Get Transactions By Address
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
}
});
$.get('https://api.cryptoapis.io/v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
response = requests.get(url, headers=headers)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
Get("https://api.cryptoapis.io/v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions")
}
Response Body
{
"payload": [
{
"txid": "af176117c26241433946ec967433bbf34e8297446a64553f827c52314eea96a7",
"hash": "af176117c26241433946ec967433bbf34e8297446a64553f827c52314eea96a7",
"index": 19,
"version": 2,
"size": 587,
"vsize": 587,
"locktime": 0,
"time": "2019-02-25 12:04:54 UTC",
"datetime": "2019-02-25 12:04:54 UTC", //deprecated
"blockhash": "00000000000001a8489e34bd83b180bf6f030fe9ccf57d4ef5fb9713ff05741c",
"blockheight": 1481535,
"blocktime": "2019-02-25 12:04:54 UTC",
"timestamp": 1551096294,
"confirmations": 27,
"txins": [
{
"txout": "02c4c9c002e2da17d9edb0144a876d7bf92be0afdb2373a4d1d25f96fee5c826",
"vout": 1,
"amount": "0.00075333",
"addresses": [
"mtFYoSowT3i649wnBDYjCjewenh8AuofQb"
],
"script": {
"asm": "3044022072ffc0d6ba2acbf11de33d7bf2723d667a166eeadad1920d98732ce29593e5310220605de47003debe7580ee85b3c877f04b311b391ee3381bb0a0c71ed43c023c06[ALL] 02275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469",
"hex": "473044022072ffc0d6ba2acbf11de33d7bf2723d667a166eeadad1920d98732ce29593e5310220605de47003debe7580ee85b3c877f04b311b391ee3381bb0a0c71ed43c023c06012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469"
},
"votype": "pubkeyhash"
},
...
{
"txout": "02c4c9c002e2da17d9edb0144a876d7bf92be0afdb2373a4d1d25f96fee5c826",
"vout": 2,
"amount": "0.00071338",
"addresses": [
"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9"
],
"script": {
"asm": "304402200c6e7995f478b629472c86fba4493b403a9fb1822813d2d2ac6d613f45d520fc022036ee5dbedcae9bcd9d86cea34999b0c0d081f340d33aa696a63f151ae3022f8c[ALL] 0378883486db7490326ac593c968312a980e0166f152bcb88b18a5dd823c5c5b1f",
"hex": "47304402200c6e7995f478b629472c86fba4493b403a9fb1822813d2d2ac6d613f45d520fc022036ee5dbedcae9bcd9d86cea34999b0c0d081f340d33aa696a63f151ae3022f8c01210378883486db7490326ac593c968312a980e0166f152bcb88b18a5dd823c5c5b1f"
},
"votype": "pubkeyhash"
}
],
"txouts": [
{
"amount": "0.00018",
"type": "pubkeyhash",
"spent": false,
"addresses": [
"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz"
],
"script": {
"asm": "OP_DUP OP_HASH160 45bfa6143f69be3475e17724397f1146a60a81f3 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a91445bfa6143f69be3475e17724397f1146a60a81f388ac",
"reqsigs": 1
}
},
...
{
"amount": "0.00059909",
"type": "pubkeyhash",
"spent": false,
"addresses": [
"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9"
],
"script": {
"asm": "OP_DUP OP_HASH160 7b9a627a184897f10d31d73d87c2eea191d8f501 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac",
"reqsigs": 1
}
}
]
},
{
"txid": "02c4c9c002e2da17d9edb0144a876d7bf92be0afdb2373a4d1d25f96fee5c826",
"hash": "02c4c9c002e2da17d9edb0144a876d7bf92be0afdb2373a4d1d25f96fee5c826",
"index": 3,
"version": 2,
"size": 406,
"vsize": 406,
"locktime": 0,
"time": "2019-02-25 11:47:50 UTC", //deprecated
"datetime": "2019-02-25 11:47:50 UTC",
"blockhash": "000000000000019cb1dbf81c08d53b106bbb2f00952102ba5287505b19a9281c",
"blockheight": 1481533,
"blocktime": "2019-02-25 11:47:50 UTC",
"timestamp": 1551095270,
"confirmations": 29,
"txins": [
{
"txout": "ba559f7866d714328165f95b446268458a179b06f680ed788146db76614977cd",
"vout": 1,
"amount": "0.00161544",
"addresses": [
"mtFYoSowT3i649wnBDYjCjewenh8AuofQb"
],
"script": {
"asm": "304402202c0a4c2edf30feb367d358f537aa0ffcf620c38d82c6a8735652c7329430fd11022051d549a4955884c3cff92c5236b3adfd739a45b365bf436fc870375d659c026b[ALL] 02275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469",
"hex": "47304402202c0a4c2edf30feb367d358f537aa0ffcf620c38d82c6a8735652c7329430fd11022051d549a4955884c3cff92c5236b3adfd739a45b365bf436fc870375d659c026b012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469"
},
"votype": "pubkeyhash"
},
{
"txout": "ba559f7866d714328165f95b446268458a179b06f680ed788146db76614977cd",
"vout": 2,
"amount": "0.00092537",
"addresses": [
"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9"
],
"script": {
"asm": "304402205ce86d13e347c3dc9d02b88c77ad0c30364947f36e6a3f0acb14e9647776d2c2022058686057784ab1c617a8671a2b2f00f50b389c578ea98632583487c58f68bd7b[ALL] 0378883486db7490326ac593c968312a980e0166f152bcb88b18a5dd823c5c5b1f",
"hex": "47304402205ce86d13e347c3dc9d02b88c77ad0c30364947f36e6a3f0acb14e9647776d2c2022058686057784ab1c617a8671a2b2f00f50b389c578ea98632583487c58f68bd7b01210378883486db7490326ac593c968312a980e0166f152bcb88b18a5dd823c5c5b1f"
},
"votype": "pubkeyhash"
}
],
"txouts": [
{
"amount": "0.00024",
"type": "pubkeyhash",
"spent": false,
"addresses": [
"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz"
],
"script": {
"asm": "OP_DUP OP_HASH160 45bfa6143f69be3475e17724397f1146a60a81f3 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a91445bfa6143f69be3475e17724397f1146a60a81f388ac",
"reqsigs": 1
}
},
...
{
"amount": "0.00071338",
"type": "pubkeyhash",
"spent": true,
"addresses": [
"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9"
],
"script": {
"asm": "OP_DUP OP_HASH160 7b9a627a184897f10d31d73d87c2eea191d8f501 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac",
"reqsigs": 1
}
}
]
}
],
"meta": {
"totalCount": 23,
"index": 0,
"limit": 50,
"results": 23
}
}
Info
The Address Transactions Endpoint returns all information available about a particular address, including an array of complete transactions.
HTTP Request
GET /v1/bc/btc/${NETWORK}/address/${ADDRESS}/transactions?index=0&limit=50
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
ADDRESS | ------- | Address in blockchain |
index | 0 | First index of returned txs |
limit | 50 | Sets the number of returned txs |
Meta Response
Variable | Type | Description |
---|---|---|
totalCount | int | Total count of the items in the listing for the given criteria |
index | int | Sequential index number of the items list start position (depends on the skip parameter) for the given criteria |
limit | int | Limit number of the items list (depends on the limit parameter) for the given criteria. |
results | int | Count of the items listed in the current response for the given criteria |
The default values of the query parameters index
and limit
are as follows: 0 and 50.
ADDRESS is a string representing the public address you’re interested in querying, for example:
mtFYoSowT3i649wnBDYjCjewenh8AuofQb
The returned object contains information about the address, including the number of transactions associated with it, and the corresponding full transaction records in descending order by blocktime.
Multiple Addresses Info Endpoint
Code samples
curl -X POST 'https://api.cryptoapis.io/v1/bc/btc/testnet/address/show-multiple' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'\
-d '{
"addresses" : ["2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77","n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1", "2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg"]
}'
POST /v1/bc/btc/testnet/address/show-multiple HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"addresses" : ["2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77","n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1", "2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg"]
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/address/show-multiple",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"addresses\": [\"2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77\",\"n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1\", \"2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg\"]}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
const https = require('https');
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/address/show-multiple",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ addresses:
["2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77","n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1", "2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg"],
});
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/address/show-multiple');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"addresses": ["2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77","n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1", "2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg"]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/address/show-multiple")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"addresses\": [\"2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77\",\"n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1\", \"2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg\"]}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"addresses\": [\"2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77\",\"n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1\", \"2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg\"]}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/testnet/addresses/show-multiple, payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"addresses\": [\"2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77\",\"n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1\", \"2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg\"]}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/address/show-multiple")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/address/show-multiple"
payload := strings.NewReader("{\n\t\"addresses\": [\"2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77\",\"n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1\", \"2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg\"]}");
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": [
{
"address": "2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77",
"totalSpent": "145.02303975",
"totalReceived": "245.16751045",
"balance": "100.1444707",
"txi": 51,
"txo": 73,
"txsCount": 74,
"addresses": [
"2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77"
]
},
{
"address": "n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1",
"totalSpent": "188.73546971",
"totalReceived": "14122.06566072",
"balance": "13933.33019101",
"txi": 142,
"txo": 15347,
"txsCount": 15369,
"addresses": [
"n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1"
]
},
{
"address": "2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg",
"totalSpent": "3753.07419126",
"totalReceived": "17926.54240162",
"balance": "14173.46821036",
"txi": 1647,
"txo": 33027,
"txsCount": 33032,
"addresses": [
"2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg"
]
}
],
"meta": {
"totalCount": 3,
"limit": 3,
"results": 3
}
}
Info
The Multiple Addresses Info Endpoint strikes a general information about the given addresses in the array.
HTTP Request
GET /v1/bc/btc/${NETWORK}/address/show-multiple
Request Object
{
"addresses": [
"2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77",
"n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1",
"2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg"
]
}
Max length of the array is 10 elements
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
As you can see from the code example, you need to provide several public addresses within the addresses array.
The endpoint returns a string array with information about the addresses, including its balance in BTC and the number of transactions associated with it.
Wallets
Hierarchical Deterministic (HD) Wallets
We also offer support for HD Wallets, which make it easy to manage multiple addresses under a single name. All HD wallet addresses are derived from a single seed. Please see BIP32 for more background on HD wallets.
HD Wallets can be created, deleted, and have new addresses generated. However, unlike normal Wallets, addresses cannot be removed.
When creating a wallet, one can optionally include one or more “subchain” indexes. These subchains can later be referenced when generating new addresses or sending txs. If none are provided in wallet creation, the wallet will derive & use addresses straight from the given extended pubkey. If no index is given when using the wallet with other APIs, it defaults to using the wallet’s first (sub) chain.
In BIP32 notation, the wallet layout is m/0, m/1, … and m/i/0, m/i/1, … for each subchain i if the wallet has subchains. For example, the path of the fourth address generated is m/3 for a non-subchain wallet. The path of the fourth address at subchain index two is m/2/3. Note that this is different from the default BIP32 wallet layout.
If you want to use BIP32 default wallet layout you can submit the extended public key of m/0’ (which can only be derived from your master private key) with subchain indexes = [0, 1]. Subchain index 0 represents the external chain (of account 0) and will discover all k keypairs that look like: m/0’/0/k. Subchain index 1 represents the internal chain (of account 0) and will discover all k keypairs in m/0’/1/k.
If you want to use BIP 44 layout (for BTC), you can submit the extended public key of m/44’/0’/0’. (which can only be derived from your master private key) with subchain indexes = [0, 1]. Subchain index 0 represents the external chain (of account 0) and will discover all k keypairs in m/44’/0’/0’/0/k. Subchain index 1 represents the internal chain (of account 0) and will discover all k keypairs in m/44’/0’/0’/1/k.
If an address ahead of current addresses listed in an HD Wallet receives a transaction, it will be added, along with any addresses between the new address and the last used one.
Using Wallets
Both HD Wallets and normal Wallets can be leveraged by the Address API, just by using their $NAME instead of $ADDRESS. They can also be used with Events and with the Transaction API. In general, using a wallet instead of an address in an API will have the effect of batching the set of addresses contained in the wallet
The following code examples should be considered serially; that is to say, the results will appear as if each API call were done sequentially. Also, $NAME is a string representing the name of your wallet, for example:
alice
As you’ll see in the examples, if you’re using HD Wallets, take care to use the appropriate resource (e.g. /wallets/hd
instead of /wallets
).
Create Wallet
Sample Data
#### normal wallet
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/ \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"walletName" : "demowallet",
"addresses": ["1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA", "1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5", "1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH"]
}'
#### hd wallet
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/ \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"walletName" : "demohdwallet",
"addressCount" : 5,
"password" : "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32"
}'
#### normal wallet
POST /v1/bc/btc/mainnet/wallets HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"walletName" : "demowallet",
"addresses" : ["1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA", "1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5", "1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH"]
}
#### hd wallet
POST /v1/bc/btc/mainnet/wallets/hd HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"walletName" : "demohdwallet",
"addressCount" : 5,
"password" : "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32"
}
// normal wallet
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"walletName\" : \"demowallet\",\n\t\"addresses\" : [\"1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA\", \"1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5\", \"1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH\"]\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
// hd wallet
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"walletName\" : \"demohdwallet\",\n\t\"addressCount\" : 5,\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\"\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
// normal wallet
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/wallets",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
walletName: 'demowallet',
addresses:
["1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA", "1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5", "1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH"] }));
req.end();
// hd wallet
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/wallets/hd",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
walletName: 'demohdwallet',
addressCount: 5,
password: '8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32' }));
req.end();
<?php
// normal wallet
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"walletName" : "demowallet",
"addresses" : ["1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA", "1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5", "1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH"]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
// hd wallet
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"walletName" : "demohdwallet",
"addressCount" : 5,
"password" : "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
#### normal wallet
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"walletName\" : \"demowallet\",\n\t\"addresses\" : [\"1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA\", \"1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5\", \"1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH\"]\n}"
response = http.request(request)
puts response.read_body
#### hd wallet
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"walletName\" : \"demohdwallet\",\n\t\"addressCount\" : 5,\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\"\n}"
response = http.request(request)
puts response.read_body
#### normal wallet
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"walletName\" : \"demowallet\",\n\t\"addresses\" : [\"1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA\", \"1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5\", \"1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH\"]\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/mainnet/wallets", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
#### hd wallet
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"walletName\" : \"demohdwallet\",\n\t\"addressCount\" : 5,\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\"\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/mainnet/wallets/hd", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
// normal wallet
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\\n\t\"walletName\" : \"demowallet\",\n\t\"addresses\" : [\"1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA\", \"1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5\", \"1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH\"]\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
// hd wallet
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"walletName\" : \"demohdwallet\",\n\t\"addressCount\" : 5,\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\"\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
// notmal wallet
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets"
payload := strings.NewReader("{\n\t\"walletName\" : \"demowallet\",\n\t\"addresses\" : [\"1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA\", \"1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5\", \"1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH\"]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
// hd wallet
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd"
payload := strings.NewReader("{\n\t\"walletName\" : \"demohdwallet\",\n\t\"addressCount\" : 5,\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
// normal wallet
{
"payload": {
"addresses": [
"1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA",
"1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5",
"1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH"],
"walletName": "demowallet"
}
}
// hd wallet
{
"payload": {
"addresses": [
{
"path": "M/0H/0/0",
"address": "1M9H2qRkNAvjpBbaAknZBWYia7YKb3sskq"
},
{
"path": "M/0H/0/1",
"address": "1MXoSgaYLt2F9JRguHPbTiNmtw4UijLSvD"
},
{
"path": "M/0H/0/2",
"address": "1L5ZEe9e2d8bkCAzrub2AFjUNbGNtZNqEg"
},
{
"path": "M/0H/0/3",
"address": "15XL2G1eTbGT6xY7YrgsL1RtqvYnib8V56"
},
{
"path": "M/0H/0/4",
"address": "1BpWypWFVJPMHaSuL5oozAc8Zpe9FTiPcw"
}
],
"walletName": "demohdwallet"
}
}
HTTP Request
normal wallet
POST /v1/bc/btc/${NETWORK}/wallets
hd wallet
POST /v1/bc/btc/${NETWORK}/wallets/hd
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or mainnet) |
WALLET_NAME | ------- | Wallet name |
ADDRESSES | ------- | Array of addresses that will be added to wallet |
ADDRESS_COUNT | ------- | Number of addresses that should be generated in the new wallet |
PASSWORD | ------- | Wallet password |
Request Wallet Object
{
"walletName" : ${WALLET_NAME},
"addresses" : ${ADDRESSES}
}
Request HD Wallet Object
{
"walletName" : ${WALLET_NAME},
"addressCount" : ${ADDRESS_COUNT},
"password" : ${PASSWORD}
}
This endpoint allows you to create a new wallet, by POSTing a partially filled out Wallet or HDWallet object, depending on the endpoint.
For normal wallets, you must include WALLET_NAME attribute and at least one public address in the ADDRESSES array.
For HD wallets, you must include WALLET_NAME, the ADDRESS_COUNT and the PASSWORD attributes.
If successful, it will return a Wallet or HDWallet object with the data you requested.
List My Wallets
Sample Data
#### normal wallet
curl -X GET \
https://api.cryptoapis.io/v1/bc/btc/testnet/wallets \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
#### hd wallet
curl -X GET \
https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd \
-H 'Content-Type: application/json'
-H 'X-API-Key: my-api-key'
#### normal wallet
GET /v1/bc/btc/testnet/wallets HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
#### hd wallet
GET /v1/bc/btc/testnet/wallets/hd HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
// normal wallet
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets",
"method": "GET",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
// hd wallet
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd",
"method": "GET",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
// normal wallet
var http = require("http");
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/wallets",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
// hd wallet
var http = require("http");
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/wallets/hd",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
// normal wallet
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/wallets');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
// hd wallet
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
####normal wallet
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
#### hd wallet
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
#### normal wallet
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
"Content-Type": "application/json",
"X-API-Key", "my-api-key"
}
conn.request("GET", "/v1/bc/btc/testnet/wallets", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
#### hd wallet
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
"Content-Type": "application/json",
"X-API-Key", "my-api-key"
}
conn.request("GET", "/v1/bc/btc/testnet/wallets/hd", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
// normal wallet
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets")
.get()
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
// hd wallet
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd")
.get()
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
// normal wallet
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
// hd wallet
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
// normal wallet
{
"payload": [
"demowallet",
"newwallet",
"specialwallet"
],
"meta": {
"totalCount": 3,
"results": 3
}
}
// hd wallet
{
"payload": [
"newhdwallet",
"specialhdwallet"
],
"meta": {
"totalCount": 2,
"results": 2
}
}
HTTP Request
normal wallet
GET /v1/bc/btc/${NETWORK}/wallets
hd wallet
GET /v1/bc/btc/${NETWORK}/wallets/hd
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
This endpoint returns a string array ($NAMEARRAY) of active wallet names (both normal ор HD) under the token you queried. You can then query detailed information on individual wallets (via their names) by leveraging the Get Wallet Endpoint.
Get Wallet Details
Sample Data
#### normal wallet
curl -X GET \
https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/demowallet \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
#### hd wallet
curl -X GET \
https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/demohdwallet \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
#### normal wallet
GET /v1/bc/btc/testnet/wallets/demowallet HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
#### hd wallet
GET /v1/bc/btc/testnet/wallets/hd/demohdwallet HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
// normal wallet
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/demowallet",
"method": "GET",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
// hd wallet
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/demohdwallet",
"method": "GET",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
// normal wallet
var http = require("http");
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/wallets/demowallet",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
// hd wallet
var http = require("http");
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/wallets/hd/demohdwallet",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
// normal wallet
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/demowallet');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
// hd wallet
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/demohdwallet');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
####noraml wallet
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/demowallet")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
#### hd wallet
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/demohdwallet")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
#### normal wallet
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
"Content-Type": "application/json",
"X-API-Key", "my-api-key"
}
conn.request("GET", "/v1/bc/btc/testnet/wallets/demowallet", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
#### hd wallet
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
"Content-Type": "application/json",
"X-API-Key", "my-api-key"
}
conn.request("GET", "/v1/bc/btc/testnet/wallets/hd/demohdwallet", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
// normal wallet
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/demowallet")
.get()
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
// hd wallet
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/demohdwallet")
.get()
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
// notmal wallet
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/demowallet"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
// hd wallet
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/demohdwallet"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
// normal wallet
{
"payload": {
"walletName": "demowallet",
"addresses": [
{
"address": "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"balance": "0.00005238"
}
],
"totalBalance": "0.00005238"
},
"meta": {
"totalCount": 1,
"limit": 50,
"results": 1
}
}
// hd wallet
{
"payload": {
"walletName": "demohdwallet",
"addresses": [
{
"address": "n18C8hBRbKGk8RVR1XUwFzqtNvsr5auvRP",
"path": "M/0H/0/0",
"balance": "0.00000000"
},
{
"address": "mvG4tCVnuWXkktMi5NepWdn2vtf97NcLrT",
"path": "M/0H/0/1",
"balance": "0.00000000"
},
{
"address": "n46mQTPEBPBsdfmWhxtTpZuHFkupriLhjX",
"path": "M/0H/0/2",
"balance": "0.00032"
}
],
"totalBalance": "0.00032"
}
}
HTTP Request
normal wallet
GET /v1/bc/btc/${NETWORK}/wallets/${WALLET_NAME}
hd wallet
GET /v1/bc/btc/${NETWORK}/wallets/hd/${WALLET_NAME}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
WALLET_NAME | ------- | Wallet name |
This endpoint returns a Wallet or HDWallet based on its WALLET_NAME.
Add Addresses To Wallet
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses \
-H 'authorization: my-api-key' \
-H 'content-type: application/json' \
-d '{
"addresses" : ["1Eeu3eC2b35LWtjXeRMJMSfrDnfDEjNwW6", "13ZiD6gSv75aNKdRyoUN39R3oSZEPML7er"]
}'
POST /v1/bc/btc/mainnet/wallets/demowallet/addresses HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"addresses" : ["1Eeu3eC2b35LWtjXeRMJMSfrDnfDEjNwW6", "13ZiD6gSv75aNKdRyoUN39R3oSZEPML7er"]
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses",
"method": "POST",
"headers": {
"content-type": "application/json",
"authorization": "my-api-key"
},
"processData": false,
"data": "{\n\t\"addresses\" : [\"1Eeu3eC2b35LWtjXeRMJMSfrDnfDEjNwW6\", \"13ZiD6gSv75aNKdRyoUN39R3oSZEPML7er\"]\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"port": null,
"path": "/v1/bc/btc/mainnet/wallets/demowallet/addresses",
"headers": {
"content-type": "application/json",
"authorization": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ addresses:
[ '1Eeu3eC2b35LWtjXeRMJMSfrDnfDEjNwW6',
'13ZiD6gSv75aNKdRyoUN39R3oSZEPML7er' ] }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'authorization' => 'my-api-key',
'content-type' => 'application/json'
));
$request->setBody('{
"addresses" : ["1Eeu3eC2b35LWtjXeRMJMSfrDnfDEjNwW6", "13ZiD6gSv75aNKdRyoUN39R3oSZEPML7er"]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'my-api-key'
request.body = "{\n\t\"addresses\" : [\"1Eeu3eC2b35LWtjXeRMJMSfrDnfDEjNwW6\", \"13ZiD6gSv75aNKdRyoUN39R3oSZEPML7er\"]\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("api.cryptoapis.io")
payload = "{\n\t\"addresses\" : [\"1Eeu3eC2b35LWtjXeRMJMSfrDnfDEjNwW6\", \"13ZiD6gSv75aNKdRyoUN39R3oSZEPML7er\"]\n}"
headers = {
'content-type': "application/json",
'authorization': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/mainnet/wallets/demowallet/addresses", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"addresses\" : [\"1Eeu3eC2b35LWtjXeRMJMSfrDnfDEjNwW6\", \"13ZiD6gSv75aNKdRyoUN39R3oSZEPML7er\"]\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("authorization", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses"
payload := strings.NewReader("{\n\t\"addresses\" : [\"1Eeu3eC2b35LWtjXeRMJMSfrDnfDEjNwW6\", \"13ZiD6gSv75aNKdRyoUN39R3oSZEPML7er\"]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"addresses": [
"1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA",
"1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5",
"1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH",
"1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R"
],
"walletName": "wallet"
}
}
HTTP Request
POST /v1/bc/btc/${NETWORK}/wallets/${WALLET_NAME}/addresses
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
WALLET_NAME | ------- | Wallet name |
Request Wallet Object
{
"addresses" : ${ADDRESSES}
}
This endpoint allows you to add public addresses to the $WALLET_NAME wallet, by POSTing a partially filled out Wallet object. You only need to include the additional addresses in a new addresses array in the object. If successful, it will return the newly modified Wallet, including an up-to-date, complete listing of addresses.
Generate Address in Wallet
Sample Data
#### normal wallet
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses/generate \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
#### hd wallet
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet/addresses/generate \
-H 'content-type: application/json' \
-H 'authorization: my-api-key' \
-d '{
"addressCount": 3,
"password": "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32"
}'
#### normal wallet
POST /v1/bc/btc/mainnet/wallets/demowallet/addresses/generate HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
#### hd wallet
POST /v1/bc/btc/mainnet/wallets/hd/demohdwallet/addresses/generate HTTP/1.1
Host: api.cryptoapis.io
X-API-Key: my-api-key
Content-Type: application/json
{
"addressCount": 3,
"password": "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32"
}
// normal wallet
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses/generate",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
// hd wallet
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet/addresses/generate",
"method": "POST",
"headers": {
"authorization": "my-api-key",
"content-type": "application/json"
},
"processData": false,
"data": "{\n\t\"addressCount\": 3,\n\t\"password\": \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\"\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
// normal wallet
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/wallets/demowallet/addresses/generate",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
// hd wallet
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"port": null,
"path": "/v1/bc/btc/mainnet/wallets/hd/demohdwallet/addresses/generate",
"headers": {
"authorization": "my-api-key",
"content-type": "application/json"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ addressCount: 3, password: '8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32' }));
req.end();
<?php
// noraml wallet
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses/generate');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
// hd wallet
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet/addresses/generate');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'my-api-key'
));
$request->setBody('{
"addressCount": 3,
"password": "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
#### noraml wallet
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses/generate")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
#### hd wallet
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet/addresses/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["authorization"] = 'my-api-key'
request["content-type"] = 'application/json'
request.body = "{\n\t\"addressCount\": 3,\n\t\"password\": \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\"\n}"
response = http.request(request)
puts response.read_body
#### normal wallet
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/mainnet/wallets/demowallet/addresses/generate", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
#### hd wallet
import http.client
conn = http.client.HTTPSConnection("api.cryptoapis.io")
payload = "{\n\t\"addressCount\": 3,\n\t\"password\": \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\"\n}"
headers = {
'authorization': "my-api-key",
'content-type': "application/json"
}
conn.request("POST", "/v1/bc/btc/mainnet/wallets/hd/demohdwallet/addresses/generate", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
// normal wallet
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses/generate")
.post(null)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
// hd wallet
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"addressCount\": 3,\n\t\"password\": \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\"\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet/addresses/generate")
.post(body)
.addHeader("authorization", "my-api-key")
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
// normal wallet
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/addresses/generate"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
// hd wallet
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet/addresses/generate"
payload := strings.NewReader("{\n\t\"addressCount\": 3,\n\t\"password\": \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "my-api-key")
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
// normal wallet
{
"payload": {
"wallet_info": {
"walletName": "demowallet",
"addresses": [
"1MfyBywPTSj9aAPr8cccCTcch71fd4vkDA",
"1B5WsYR8m4axbmEMMifveDL2gtZjtpaFr5",
"1KRYkrh3dAkeBWPwxDZhrz9u8xf5NRK9UH",
"1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R"
]
},
"address_info": {
"privateKey": "99d1ffc2264f57479e948405d97b50a09e2a197d4c7b9d4271fd6d0cc722f4f3",
"address": "1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R",
"publicKey": "03f2ff3a306245a78066636b2f3587dcddecbbcca2db0ab1ec2cbc257069853dde",
"wif": "L2NiZnxNptPpZBNXYARaFV6vLonvZMNRp1hGYACbyzYxtYLmbGoZ",
}
}
}
// hd wallet
{
"payload": {
"addresses": [
{
"address": "1B8DBKwUZPQ5m2GmKxAnH4GaVLMNXmDEks",
"path": "M/0H/0/3"
},
{
"address": "1MrLV9fnq93Gdqg6uDDioZSDjKgnf866Ne",
"path": "M/0H/0/4"
},
{
"address": "1JQwoe3vFKNPA19MWwYL7jasuh9rwjznMz",
"path": "M/0H/0/5"
}
],
"walletName": "demohdwallet"
}
}
HTTP Request
normal wallet
POST /v1/bc/btc/${NETWORK}/wallets/${WALLET_NAME}/addresses/generate
hd wallet
POST /v1/bc/btc/${NETWORK}/wallets/hd/${WALLET_NAME}/addresses/generate
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
WALLET_NAME | ------- | Wallet name |
Request HD Wallet Object
{
"addressCount" : ${ADDRESS_COUNT},
"password" : ${ENCRYPTED_PASSWORD}
}
This endpoint allows you to generate a new address associated with the WALLET_NAME wallet, similar to the Generate Address Endpoint. If successful, it will return the newly created addresses.
Remove Addresses from Wallet
curl -X DELETE \
https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/address/1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
DELETE /v1/bc/btc/mainnet/wallets/demowallet/address/1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/address/1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R",
"method": "DELETE",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "DELETE",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/wallets/demowallet/address/1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/address/1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R');
$request->setMethod(HTTP_METH_DELETE);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/address/1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Delete.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
"Content-Type": "application/json",
"X-API-Key", "my-api-key"
}
conn.request("DELETE", "/v1/bc/btc/mainnet/wallets/demowallet/address/1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/address/1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R")
.delete(null)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet/address/1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"message": "address 1Ho72xi1JDv7inZ7BrLivJShSkcwARtP2R was successfully deleted!"
}
}
HTTP Request
DELETE /v1/bc/btc/${NETWORK}/wallets/${WALLET_NAME}/address/${ADDRESS}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
WALLET_NAME | ------- | Wallet name |
ADDRESS | ------- | Address which should be deleted |
This endpoint allows you to delete an $ADDRESS associated with the WALLET_NAME wallet.
Delete Wallet
#### normal wallet
curl -X DELETE \
https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
#### hd wallet
curl -X DELETE \
https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
#### normal wallet
DELETE /v1/bc/btc/mainnet/wallets/demowallet HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
#### hd wallet
DELETE /v1/bc/btc/mainnet/wallets/hd/demohdwallet HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
// normal wallet
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet",
"method": "DELETE",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
//hd wallet
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet",
"method": "DELETE",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
// normal wallet
var http = require("http");
var options = {
"method": "DELETE",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/wallets/demowallet",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
// hd wallet
var http = require("http");
var options = {
"method": "DELETE",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/wallets/hd/demohdwallet",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
// normal wallet
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet');
$request->setMethod(HTTP_METH_DELETE);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
// hd wallet
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet');
$request->setMethod(HTTP_METH_DELETE);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
#### normal wallet
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Delete.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
#### hd wallet
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
#### normal wallet
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
"Content-Type": "application/json",
"X-API-Key", "my-api-key"
}
conn.request("DELETE", "/v1/bc/btc/mainnet/wallets/demowallet", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
#### hd wallet
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("DELETE", "/v1/bc/btc/mainnet/wallets/hd/demohdwallet", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
// normal wallet
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet")
.delete(null)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
// hd wallet
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet")
.delete(null)
.addHeader("content-type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
// normal wallet
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/demowallet"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.Defaubtclient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
// hd wallet
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/demohdwallet"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"message": "Wallet demowallet was successfully deleted!"
}
}
{
"payload": {
"message": "Wallet demohdwallet was successfully deleted!"
}
}
HTTP Request
normal wallet
DELETE /v1/bc/btc/${NETWORK}/wallets/${WALLET_NAME}
hd wallet
DELETE /v1/bc/btc/${NETWORK}/wallets/hd/${WALLET_NAME}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
WALLET_NAME | ------- | Wallet name |
This endpoint deletes the Wallet or HD Wallet with WALLET_NAME.
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
WALLET_NAME | ------- | Wallet name |
Create XPub
Sample Data
curl -X POST 'https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
-d '{
"password": "SECRET123456"
}'
POST /v1/bc/btc/mainnet/wallets/hd/xpub HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"password": "SECRET123456"
}
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"password\": \"SECRET123456\"\n}"
});
$.post('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub')
.then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/wallets/hd/xpub",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
req.write(JSON.stringify({ password: 'SECRET123456' }));
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"password": "SECRET123456"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"password\": \"SECRET123456\"\n}"
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
payload = "{\n\t\"password\": \"SECRET123456\"\n}"
response = requests.post(url, payload, headers)
OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create(mediaType, "{\n\t\"password\": \"SECRET123456\"\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub"
payload := strings.NewReader("{\n\t\"password\": \"SECRET123456\"\n}")
req, _ := http.NewRequest("POST", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
}
Response Body
{
payload": {
"wallet_info": {
"walletName": "demowallet",
"addresses": [
"1FAAN8GSmni6VpS7nh7MAZZry2y9SoAHb",
"18sHg9CiQauURUwtB23jXkQc54FsD4ECKG"
]
},
"address_info": {
"privateKey": "7662b19db068aa373b591b83478dc243c60d11ba812b2a678c3a2b2db20dd764",
"publicKey": "03761e771ec1505d2d349cc6362c8bd76fe2f78c759211eaf2217fe129901e0928",
"address": "18sHg9CiQauURUwtB23jXkQc54FsD4ECKG",
"wif": "L1BqVUYPhyL71wg53Tre9a5bWq5kFLwV7mQVfrmSR5DnKqNuy8Wk"
}
}
Info
Create XPub Endpoint allows you to create a random extended public key (based on your password), xpriv and wif.
HTTP Request
POST /v1/bc/btc/${NETWORK}/wallets/hd/xpub
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
Get XPub Change Addresses
Sample Data
curl -X POST 'https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/change' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
-d '{
"xpub":"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk",
"from": 0,
"to": 3
}'
POST /v1/bc/btc/mainnet/wallets/hd/xpub/addresses/change HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"xpub":"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk",
"from": 0,
"to": 3
}
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\",\n\t\"from\": 0,\n\t\"to\": 3\n}"
});
$.post('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/change')
.then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/change",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
req.write(JSON.stringify({ xpub: 'xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk',
from: 0,
to: 3 }));
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/change');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"xpub":"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk",
"from": 0,
"to": 3
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/change")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\",\n\t\"from\": 0,\n\t\"to\": 3\n}"
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/change'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
payload = "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\",\n\t\"from\": 0,\n\t\"to\": 3\n}"
response = requests.post(url, payload, headers)
OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create(mediaType, "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\",\n\t\"from\": 0,\n\t\"to\": 3\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/change")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/change"
payload := strings.NewReader("{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\",\n\t\"from\": 0,\n\t\"to\": 3\n}")
req, _ := http.NewRequest("POST", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
}
Response Body
{
"payload": [
"1PWoj4w5hsuhkAGmJ5F5JCoWgaEAMVSTk5",
"1AgDiXq2Bxz88irfcnUWiwX1ShjMnTztgR",
"16k3eB7rH7JWscGKLhwCNGeSoYP4KTi7jy"
],
"meta": {
"totalCount": 3,
"results": 3
}
}
Info
Get XPub Change Addresses Endpoint allows you to get the change(KeyPurpose: Change) addresses associated with the specified xpub. Since those are hierarchically ordered we provide the arguments from and to - both integeres, in order to be able to get the addresses in the specific positions. If you request, e.g. "from": 0
and "to": 50
, this will return the first 50 change addresses linked to the specified xpub.
HTTP Request
POST /v1/bc/btc/${NETWORK}/wallets/hd/xpub/addresses/change
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
Get XPub Receive Addresses
Sample Data
curl -X POST 'https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/receive' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
-d '{
"xpub":"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk",
"from": 0,
"to": 3
}'
POST /v1/bc/btc/mainnet/wallets/hd/xpub/addresses/receive HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"xpub":"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk",
"from": 0,
"to": 3
}
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\",\n\t\"from\": 0,\n\t\"to\": 3\n}"
});
$.post('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/receive')
.then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/receive",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
req.write(JSON.stringify({ xpub: 'xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk',
from: 0,
to: 3 }));
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/receive');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"xpub":"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk",
"from": 0,
"to": 3
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/receive")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\",\n\t\"from\": 0,\n\t\"to\": 3\n}"
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/receive'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
payload = "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\",\n\t\"from\": 0,\n\t\"to\": 3\n}"
response = requests.post(url, payload, headers)
OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create(mediaType, "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\",\n\t\"from\": 0,\n\t\"to\": 3\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/receive")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses/receive"
payload := strings.NewReader("{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\",\n\t\"from\": 0,\n\t\"to\": 3\n}")
req, _ := http.NewRequest("POST", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
}
Response Body
{
"payload": [
"1ATeJNj2rWwrb2CzzJfWXkNh82UZj6GWy2",
"146N7YNRnx2LqAf954SAWkR81zQVV1A33Y",
"16nLiCMaHKTdR91ZW6RrFMrnEmEtgUkYMi"
],
"meta": {
"totalCount": 3,
"results": 3
}
}
Info
Get XPub receive Addresses Endpoint allows you to get the receive(KeyPurpose: RECEIVE_FUNDS) addresses associated with the specified xpub. Since those are hierarchically ordered we provide the arguments from and to - both integeres, in order to be able to get the addresses in the specific positions. If you request, e.g. "from": 0
and "to": 50
, this will return the first 50 receive addresses linked to the specified xpub.
HTTP Request
POST /v1/bc/btc/${NETWORK}/wallets/hd/xpub/addresses/receive
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
Import Address as a Wallet
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/import\
-H 'content-type: application/json' \
-H 'authorization: my-api-key' \
-d '{
"walletName": "testImportWallet",
"password": "SECRET123456",
"privateKey": "8aeb39b5f9b0xxxxxxxc7001c1cecc112712c9448b",
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1"
}'
POST /v1/bc/btc/testnet/wallets/hd/import HTTP/1.1
Host: api.cryptoapis.io
X-API-Key: my-api-key
Content-Type: application/json
{
"walletName": "testImportWallet",
"password": "SECRET123456",
"privateKey": "8aeb39b5f9b0xxxxxxxc7001c1cecc112712c9448b",
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1"
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/import",
"method": "POST",
"headers": {
"authorization": "my-api-key",
"content-type": "application/json"
},
"processData": false,
"data": "{\n \"walletName\": \"testImportWallet\",\n \"password\": \"SECRET123456\",\n \"privateKey\": \"8aeb39b5f9b0xxxxxxxc7001c1cecc112712c9448b\",\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\"\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
// hd wallet
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/wallets/hd/import,
"headers": {
"authorization": "my-api-key",
"content-type": "application/json"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ walletName: 'testImportWallet',
password: 'SECRET123456',
privateKey: '8aeb39b5f9b0xxxxxxxc7001c1cecc112712c9448b',
address: 'mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1' }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/import');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'my-api-key'
));
$request->setBody('{
"walletName": "testImportWallet",
"password": "SECRET123456",
"privateKey": "8aeb39b5f9b0xxxxxxxc7001c1cecc112712c9448b",
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/import")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["authorization"] = 'my-api-key'
request["content-type"] = 'application/json'
request.body = "{\n \"walletName\": \"testImportWallet\",\n \"password\": \"SECRET123456\",\n \"privateKey\": \"8aeb39b5f9b0xxxxxxxc7001c1cecc112712c9448b\",\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\"\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPSConnection("api.cryptoapis.io")
payload = "{\n \"walletName\": \"testImportWallet\",\n \"password\": \"SECRET123456\",\n \"privateKey\": \"8aeb39b5f9b0xxxxxxxc7001c1cecc112712c9448b\",\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\"\n}"
headers = {
'authorization': "my-api-key",
'content-type': "application/json"
}
conn.request("POST", "/v1/bc/btc/testnet/wallets/hd/demohdwallet/addresses/generate", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"walletName\": \"testImportWallet\",\n \"password\": \"SECRET123456\",\n \"privateKey\": \"8aeb39b5f9b0xxxxxxxc7001c1cecc112712c9448b\",\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\"\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/import")
.post(body)
.addHeader("authorization", "my-api-key")
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/import"
payload := strings.NewReader("{\n \"walletName\": \"testImportWallet\",\n \"password\": \"SECRET123456\",\n \"privateKey\": \"8aeb39b5f9b0xxxxxxxc7001c1cecc112712c9448b\",\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "my-api-key")
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"walletName": "testImportWallet",
"addresses": [
{
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1"
}
]
}
}
HTTP Request
POST /v1/bc/btc/${NETWORK}/wallets/hd/import
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
Request HD Wallet Object
{
"password" : ${ENCRYPTED_PASSWORD},
"walletName": ${WALLET_NAME},
"privateKey": ${ADDRESS_PRIVATE_KEY},
"address": ${ADDRESS}
}
This endpoint allows you to import a BTC address. Although it is only an address it will be treated as an HDwallet. Therefore, with the imported wallet users can make transactions and payment forwardings. Moreover, imported wallets can be listed and deleted.
Transactions
Crypto APIs Transaction API allows you to look up information about unconfirmed transactions, query transactions based on hash, create and propagate your own transactions, including multisignature transactions, and embed data on the blockchain—all based on the coin/chain resource you’ve selected for your endpoints.
If you’re new to blockchains, the idea of transactions is relatively self-explanatory. Here’s what’s going on underneath the hood: a transaction takes previous “unspent transaction outputs” (also known as UTXOs) as “transaction inputs” and creates new “locking scripts” on those inputs such that they are “sent” to new addresses (to become new UTXOs). While most of these public addresses are reference points for single private keys that can “unlock” the newly created UTXOs, occasionally they are sent to more exotic addresses through pay-to-script-hash, typically multisignature addresses.
Generally speaking, UTXOs are generated from previous transactions (except for Coinbase inputs).
Get Transaction Details By Transaction ID (Txid)
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/txid/5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/txs/txid/5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2 HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
}
});
$.get('https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/txid/5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/txs/txid/5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/txid/5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/txid/5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/txid/5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
response = requests.get(url, headers=headers)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/txid/5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
Get("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/txid/5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2")
}
Response Body
{
"payload": {
"txid": "5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2",
"hash": "5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2",
"index": 1,
"version": 1,
"size": 158,
"vsize": 158,
"locktime": 0,
"time": "2010-09-16 05:03:47 UTC",
"blockhash": "000000000043a8c0fd1d6f726790caa2a406010d19efd2780db27bdbbd93baf6",
"blockheight": 80000,
"blocktime": "2010-09-16 05:03:47 UTC",
"timestamp": 1284613427,
"confirmations": 484349,
"txins": [
{
"txout": "f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6",
"vout": 0,
"amount": "50.00000000",
"addresses": [
"1JBSCVF6VM6QjFZyTnbpLjoCJTQEqVbepG"
],
"script": {
"asm": "304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d1090db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b2415[ALL]",
"hex": "48304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d1090db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501"
},
"votype": "pubkey"
}
],
"txouts": [
{
"amount": "50.00000000",
"type": "pubkeyhash",
"spent": true,
"addresses": [
"16ro3Jptwo4asSevZnsRX6vfRS24TGE6uK"
],
"script": {
"asm": "OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914404371705fa9bd789a2fcd52d2c580b65d35549d88ac",
"reqsigs": 1
}
}
]
}
}
Info
The Transaction Txid Endpoint returns detailed information about a given transaction based on its id.
HTTP Request
GET /v1/bc/btc/${NETWORK}/txs/txid/${TXID}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
TXID | ------- | Id of the transaction in blockchain |
TXID is a string
representing the id of the block you’re interested in querying, for example:
5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2
The returned object contains information about the transaction in JSON format, including its block information, the total amount transacted with it (in bitcoins), the inputs and outputs, and more.
Get Transactions By Block Number
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/block/00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/txs/block/00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1 HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
}
});
$.get('https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/block/00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/txs/block/00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var request = https.request(options, function (response) {
response.on("data", function (data) {
console.log(data);
});
});
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/block/00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/block/00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/block/00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
response = requests.get(url, headers=headers)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/block/00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
import (
"gopkg.in/resty.v0"
)
func main()
{
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("X-API-Key", "my-api-key").
Get("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/block/00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1")
}
Response Body
{
"payload": [
{
"txid": "8bb6329aac853def9f99161e584145eade14e3f6499e74e03e14b30c3650f8f7",
"hash": "0bb7409e661a0c2785b4c9e716e92148e6f2bdae32013773c2220308193a3bfe",
"index": 0,
"version": 1,
"size": 5167,
"vsize": 5140,
"locktime": 0,
"time": "2018-10-07 03:13:38 UTC",
"blockhash": "00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1",
"blockheight": 544704,
"blocktime": "2018-10-07 03:13:38 UTC",
"timestamp": 1538882018,
"confirmations": 39012,
"txins": [
{
"coinbase": "03c04f080004cc79b95b042af18a0d0cfaac655d6f050000000000000a636b706f6f6c0c2f636b706f6f6c2e6f72672f"
}
],
"txouts": [
{
"amount": "3.63760569",
"type": "scripthash",
"spent": true,
"addresses": [
"32LA7cmsj35LH7cK1MjvwyoLEmYpuWAD9k"
],
"script": {
"asm": "OP_HASH160 07063a601afa20bedc42930fab7b02bc02f3f58b OP_EQUAL",
"hex": "a91407063a601afa20bedc42930fab7b02bc02f3f58b87",
"reqsigs": 1
}
},
...
{
"amount": "0.00000000",
"type": "nulldata",
"spent": true,
"script": {
"asm": "OP_RETURN aa21a9ed1a18b5f23c9f15697a96677281e9dfd369ad33b67e9d2a4b6b525311d586245c",
"hex": "6a24aa21a9ed1a18b5f23c9f15697a96677281e9dfd369ad33b67e9d2a4b6b525311d586245c"
}
}
]
}
],
"meta": {
"totalCount": 56,
"index": 0,
"limit": 50,
"results": 50
}
}
Info
The Transaction Index by Block Endpoint returns detailed information about a list of transactions. The endpoint is useable both with block height and block hash. index
and limit
query parameters might also be used, as their default values are, as follows: 0, 1. Therefore, if none is specified the returned object will be the first transaction (the coinbase transaction) included in the block.
HTTP Request
GET /v1/bc/btc/${NETWORK}/txs/block/${BLOCK}?index=0&limit=1
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
BLOCK | ------- | Block height or block hash in blockchain |
index | 0 | index to start from |
limit | 1 | number of transactions to be returned |
Meta Response
Variable | Type | Description |
---|---|---|
totalCount | int | Total count of the items in the listing for the given criteria |
index | int | Sequential index number of the items list start position (depends on the skip parameter) for the given criteria |
limit | int | Limit number of the items list (depends on the limit parameter) for the given criteria. |
results | int | Count of the items listed in the current response for the given criteria |
BLOCK is a string
or an integer
representing the hash or the height of the block you’re interested in querying, for example:
00000000000000000008b7233b8abb1519d0a1bc6579e209955539c303f3e6b1
or
544704
The returned object contains information about the transaction in JSON format, including its block information, the total amount transacted with it (in bitcoins), the inputs and outputs, and more.
Get Unconfirmed Transactions
Sample Data
curl -X POST 'https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/unconfirmed' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/txs/unconfirmed HTTP/1.1
Host: api.cryptoapis.io
X-API-Key: my-api-key
Content-Type: application/json
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/unconfirmed",
"method": "GET",
"headers": {
"authorization": "my-api-key",
"content-type": "application/json"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"port": null,
"path": "/v1/bc/btc/mainnet/txs/unconfirmed",
"headers": {
"authorization": "my-api-key",
"content-type": "application/json"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/unconfirmed');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/unconfirmed")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/unconfirmed"
headers = {
'content-type': "application/json",
'authorization': "my-api-key"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/unconfirmed")
.get()
.addHeader("authorization", "my-api-key")
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/unconfirmed"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("authorization", "my-api-key")
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": [
{
"txid": "e54b1d0a9f946a488cadaa948ac7fc570fe5fcbe7ee3b0449c973021d3a303d5",
"hash": "e54b1d0a9f946a488cadaa948ac7fc570fe5fcbe7ee3b0449c973021d3a303d5",
"version": 2,
"size": 191,
"vsize": 191,
"locktime": 1481958,
"time": "2019-02-27 12:11:18 UTC",
"timestamp": 1551269478,
"txins": [
{
"txout": "6ba5421b3db08039c6c08cbac43eb4e9d79bb3e58f4d9e1dc36fbf446f8c5b45",
"vout": 0,
"amount": "4.03748536",
"addresses": [
"msPLQLf2MdSKm1psLMXwGdTSzpFwJzDEYv"
],
"script": {
"asm": "30440220675913704ff2b07217b6a04eac977593aafdd0e1f66c44c8bd56c969c5499130022013c660b2b75747d774fb781161b9bd22e553028490acce83e28c182d358666b7[ALL] 0214e7d2765c60b92d010b5b72680b03ddebef783ebf5bad004bad6273ee1e6833",
"hex": "4730440220675913704ff2b07217b6a04eac977593aafdd0e1f66c44c8bd56c969c5499130022013c660b2b75747d774fb781161b9bd22e553028490acce83e28c182d358666b701210214e7d2765c60b92d010b5b72680b03ddebef783ebf5bad004bad6273ee1e6833"
},
"votype": "pubkeyhash"
}
],
"txouts": [
{
"amount": "4.03748344",
"type": "pubkeyhash",
"spent": false,
"addresses": [
"mvE9nxwUnP7bxJmNVw5NWki7tu8u3AHW6K"
],
"script": {
"asm": "OP_DUP OP_HASH160 a15c69f1cb00562b6379de144faf9c75e8f305f4 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914a15c69f1cb00562b6379de144faf9c75e8f305f488ac",
"reqsigs": 1
}
}
]
},
{
"txid": "237615a7a1222990599d9a154b99d9c2fa7106eea8f0c313d8045e461a593b88",
"hash": "237615a7a1222990599d9a154b99d9c2fa7106eea8f0c313d8045e461a593b88",
"version": 1,
"size": 192,
"vsize": 192,
"locktime": 0,
"time": "2019-02-27 12:11:15 UTC",
"timestamp": 1551269475,
"txins": [
{
"txout": "cd8a29eddbcc58c704a075fe23e05ea094abd19160605b05f701b7568da6a49d",
"vout": 1,
"amount": "0.12241585",
"addresses": [
"ms1TnG8UQGstnWHtoPfcj8HDivhPStrZj3"
],
"script": {
"asm": "3045022100e9f80af7f7d27137d13f51f091a0242c5c7bf95843e66e4aefe401b0a8df28f402201246db81055e6d0a5e27aebbf217865e2fa11a09110ba9aca2d7af9510bff495[ALL] 03eb9806e12f77ab01ae8280073dfd7f61f9f8a99e1292ff82de7ac37b6d959693",
"hex": "483045022100e9f80af7f7d27137d13f51f091a0242c5c7bf95843e66e4aefe401b0a8df28f402201246db81055e6d0a5e27aebbf217865e2fa11a09110ba9aca2d7af9510bff495012103eb9806e12f77ab01ae8280073dfd7f61f9f8a99e1292ff82de7ac37b6d959693"
},
"votype": "pubkeyhash"
}
],
"txouts": [
{
"amount": "0.12236885",
"type": "pubkeyhash",
"spent": false,
"addresses": [
"mpfb93q3hN8Cw5SqxTHBuqfUS6pZTtMNAs"
],
"script": {
"asm": "OP_DUP OP_HASH160 645b3758b9ee9879a65b8cf92cd0fc2b07fb693d OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914645b3758b9ee9879a65b8cf92cd0fc2b07fb693d88ac",
"reqsigs": 1
}
}
]
},
...
],
"meta": {
"totalCount": 106,
"index": 0,
"limit": 50,
"results": 106
}
}
Info
The Unconfirmed Transactions Endpoint returns an array of the latest transactions relayed by nodes in a blockchain that haven’t been included in any blocks.
HTTP Request
GET /v1/bc/btc/${NETWORK}/txs/unconfirmed?index=0&limit=100
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
index | 0 | skip parameter |
limit | ------- | Sets the number of returned txs |
Meta Response
Variable | Type | Description |
---|---|---|
totalCount | int | Total count of the items in the listing for the given criteria |
index | int | Sequential index number of the items list start position (depends on the skip parameter) for the given criteria |
limit | int | Limit number of the items list (depends on the limit parameter) for the given criteria. |
results | int | Count of the items listed in the current response for the given criteria |
The returned object is an array of transactions that haven’t been included in blocks, arranged in reverse chronological order (latest is first, then older transactions follow).
Decode Raw Transactions
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/decode \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"hex": "0200000005c1ab663c05cc557f522d55d42734eb3fe7bfacf3737cba5102233b312b0c95590000000000ffffffffbfd5dc9ac3129f2a9788d0ab2c201861790d66ce147bf6ebe8ee44019b69ed790100000000ffffffff2837839555246cc3f0f9374f73030341d641f3beae71eeafb2461f8ba8daa1d40000000000ffffffffbe23166dca2f0b9a24d9704e5e6ecfe3e57265cda29468e68c19644d24e1f1c70000000000ffffffff41994176b4bb3f00bb128a982b907e0a3b139ac02d90253c61815dea3d16f98d0000000000ffffffff0140420f00000000001976a9141a96349a5025735fe18f3e783098e471edbad83388ac00000000"
}'
POST /v1/bc/btc/mainnet/txs/decode HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"hex": "0200000005c1ab663c05cc557f522d55d42734eb3fe7bfacf3737cba5102233b312b0c95590000000000ffffffffbfd5dc9ac3129f2a9788d0ab2c201861790d66ce147bf6ebe8ee44019b69ed790100000000ffffffff2837839555246cc3f0f9374f73030341d641f3beae71eeafb2461f8ba8daa1d40000000000ffffffffbe23166dca2f0b9a24d9704e5e6ecfe3e57265cda29468e68c19644d24e1f1c70000000000ffffffff41994176b4bb3f00bb128a982b907e0a3b139ac02d90253c61815dea3d16f98d0000000000ffffffff0140420f00000000001976a9141a96349a5025735fe18f3e783098e471edbad83388ac00000000"
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/decode",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"hex\": \"0200000005c1ab663c05cc557f522d55d42734eb3fe7bfacf3737cba5102233b312b0c95590000000000ffffffffbfd5dc9ac3129f2a9788d0ab2c201861790d66ce147bf6ebe8ee44019b69ed790100000000ffffffff2837839555246cc3f0f9374f73030341d641f3beae71eeafb2461f8ba8daa1d40000000000ffffffffbe23166dca2f0b9a24d9704e5e6ecfe3e57265cda29468e68c19644d24e1f1c70000000000ffffffff41994176b4bb3f00bb128a982b907e0a3b139ac02d90253c61815dea3d16f98d0000000000ffffffff0140420f00000000001976a9141a96349a5025735fe18f3e783098e471edbad83388ac00000000\"\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/txs/decode",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ hex: '0200000005c1ab663c05cc557f522d55d42734eb3fe7bfacf3737cba5102233b312b0c95590000000000ffffffffbfd5dc9ac3129f2a9788d0ab2c201861790d66ce147bf6ebe8ee44019b69ed790100000000ffffffff2837839555246cc3f0f9374f73030341d641f3beae71eeafb2461f8ba8daa1d40000000000ffffffffbe23166dca2f0b9a24d9704e5e6ecfe3e57265cda29468e68c19644d24e1f1c70000000000ffffffff41994176b4bb3f00bb128a982b907e0a3b139ac02d90253c61815dea3d16f98d0000000000ffffffff0140420f00000000001976a9141a96349a5025735fe18f3e783098e471edbad83388ac00000000' }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/decode');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"hex": "0200000005c1ab663c05cc557f522d55d42734eb3fe7bfacf3737cba5102233b312b0c95590000000000ffffffffbfd5dc9ac3129f2a9788d0ab2c201861790d66ce147bf6ebe8ee44019b69ed790100000000ffffffff2837839555246cc3f0f9374f73030341d641f3beae71eeafb2461f8ba8daa1d40000000000ffffffffbe23166dca2f0b9a24d9704e5e6ecfe3e57265cda29468e68c19644d24e1f1c70000000000ffffffff41994176b4bb3f00bb128a982b907e0a3b139ac02d90253c61815dea3d16f98d0000000000ffffffff0140420f00000000001976a9141a96349a5025735fe18f3e783098e471edbad83388ac00000000"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/decode")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"hex\": \"0200000005c1ab663c05cc557f522d55d42734eb3fe7bfacf3737cba5102233b312b0c95590000000000ffffffffbfd5dc9ac3129f2a9788d0ab2c201861790d66ce147bf6ebe8ee44019b69ed790100000000ffffffff2837839555246cc3f0f9374f73030341d641f3beae71eeafb2461f8ba8daa1d40000000000ffffffffbe23166dca2f0b9a24d9704e5e6ecfe3e57265cda29468e68c19644d24e1f1c70000000000ffffffff41994176b4bb3f00bb128a982b907e0a3b139ac02d90253c61815dea3d16f98d0000000000ffffffff0140420f00000000001976a9141a96349a5025735fe18f3e783098e471edbad83388ac00000000\"\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"hex\": \"0200000005c1ab663c05cc557f522d55d42734eb3fe7bfacf3737cba5102233b312b0c95590000000000ffffffffbfd5dc9ac3129f2a9788d0ab2c201861790d66ce147bf6ebe8ee44019b69ed790100000000ffffffff2837839555246cc3f0f9374f73030341d641f3beae71eeafb2461f8ba8daa1d40000000000ffffffffbe23166dca2f0b9a24d9704e5e6ecfe3e57265cda29468e68c19644d24e1f1c70000000000ffffffff41994176b4bb3f00bb128a982b907e0a3b139ac02d90253c61815dea3d16f98d0000000000ffffffff0140420f00000000001976a9141a96349a5025735fe18f3e783098e471edbad83388ac00000000\"\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/mainnet/txs/decode", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"hex\": \"0200000005c1ab663c05cc557f522d55d42734eb3fe7bfacf3737cba5102233b312b0c95590000000000ffffffffbfd5dc9ac3129f2a9788d0ab2c201861790d66ce147bf6ebe8ee44019b69ed790100000000ffffffff2837839555246cc3f0f9374f73030341d641f3beae71eeafb2461f8ba8daa1d40000000000ffffffffbe23166dca2f0b9a24d9704e5e6ecfe3e57265cda29468e68c19644d24e1f1c70000000000ffffffff41994176b4bb3f00bb128a982b907e0a3b139ac02d90253c61815dea3d16f98d0000000000ffffffff0140420f00000000001976a9141a96349a5025735fe18f3e783098e471edbad83388ac00000000\"\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/decode")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/decode"
payload := strings.NewReader("{\n\t\"hex\": \"0200000005c1ab663c05cc557f522d55d42734eb3fe7bfacf3737cba5102233b312b0c95590000000000ffffffffbfd5dc9ac3129f2a9788d0ab2c201861790d66ce147bf6ebe8ee44019b69ed790100000000ffffffff2837839555246cc3f0f9374f73030341d641f3beae71eeafb2461f8ba8daa1d40000000000ffffffffbe23166dca2f0b9a24d9704e5e6ecfe3e57265cda29468e68c19644d24e1f1c70000000000ffffffff41994176b4bb3f00bb128a982b907e0a3b139ac02d90253c61815dea3d16f98d0000000000ffffffff0140420f00000000001976a9141a96349a5025735fe18f3e783098e471edbad83388ac00000000\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"txid": "9e45e9998d376a3f59043d1c81cfc698af92f3e9fd5d8e4a0fa0ec66729b40de",
"hash": "9e45e9998d376a3f59043d1c81cfc698af92f3e9fd5d8e4a0fa0ec66729b40de",
"size": 249,
"vsize": 249,
"version": 2,
"locktime": 0,
"vin": [
{
"txid": "59950c2b313b230251ba7c73f3acbfe73feb3427d4552d527f55cc053c66abc1",
"sequence": 4294967295,
"vout": 0,
"scriptSig": {}
},
{
"txid": "79ed699b0144eee8ebf67b14ce660d796118202cabd088972a9f12c39adcd5bf",
"sequence": 4294967295,
"vout": 1,
"scriptSig": {}
},
{
"txid": "d4a1daa88b1f46b2afee71aebef341d6410303734f37f9f0c36c245595833728",
"sequence": 4294967295,
"vout": 0,
"scriptSig": {}
},
{
"txid": "c7f1e1244d64198ce66894a2cd6572e5e3cf6e5e4e70d9249a0b2fca6d1623be",
"sequence": 4294967295,
"vout": 0,
"scriptSig": {}
},
{
"txid": "8df9163dea5d81613c25902dc09a133b0a7e902b988a12bb003fbbb476419941",
"sequence": 4294967295,
"vout": 0,
"scriptSig": {}
}
],
"vout": [
{
"value": "0.01",
"n": 0,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 1a96349a5025735fe18f3e783098e471edbad833 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a9141a96349a5025735fe18f3e783098e471edbad83388ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": [
"13RaWSweWrGHPKNaRCRu14HtsCUgKNbLUp"
]
}
}
]
}
}
Info
We also offer the ability to decode raw transactions without sending propagating them to the network; perhaps you want to double-check another client library or confirm that another service is sending proper transactions.
HTTP Request
POST /v1/bc/btc/${NETWORK}/txs/decode
Request Object
{
"hex": "${HEX}"
}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or mainnet) |
HEX | ------- | hex of raw transaction |
$HEX is a hex-encoded raw representation of your transaction, for example:
0200000005c1ab663c05cc557f522d55d42734eb3fe7bfacf3737cba5102233b312b0c95590000000000ffffffffbfd5dc9ac3129f2a9788d0ab2c201861790d66ce147bf6ebe8ee44019b69ed790100000000ffffffff2837839555246cc3f0f9374f73030341d641f3beae71eeafb2461f8ba8daa1d40000000000ffffffffbe23166dca2f0b9a24d9704e5e6ecfe3e57265cda29468e68c19644d24e1f1c70000000000ffffffff41994176b4bb3f00bb128a982b907e0a3b139ac02d90253c61815dea3d16f98d0000000000ffffffff0140420f00000000001976a9141a96349a5025735fe18f3e783098e471edbad83388ac00000000
If it succeeds, you’ll receive your decoded TX object.
Creating Transactions
Info
Using Crypto APIs, you can push transactions to blockchains one of two ways:
Use our two-endpoint process outlined below, wherein we generate a TXSkeleton based on your input address, output address, and value to transfer. In either case, for security reasons, we never take possession of your private keys. We do use private keys with our Microtransaction API, but they are for low-value transactions and we discard them immediately from our servers’ memory.
New Transaction Endpoint
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/testnet/txs/create \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"inputs": [{
"address": "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"value": 0.0004
}, {
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"value": 0.0004
}],
"outputs": [{
"address": "mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9",
"value": 0.0018
}],
"fee": {
"address" : "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"value": 0.00023141
},
"data": "CRYPTOAPISROCKS",
"replaceable": true
}'
POST /v1/bc/btc/testnet/txs/create HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"inputs": [{
"address": "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"value": 0.0004
}, {
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"value": 0.0004
}],
"outputs": [{
"address": "mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9",
"value": 0.0018
}],
"fee": {
"address" : "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"value": 0.00023141
},
"data": "CRYPTOAPISROCKS",
"replaceable": true
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/txs/create",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n \"inputs\": [{\n \"address\": \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n \"value\": 0.0004\n }, {\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.0004\n }],\n \"outputs\": [{\n \"address\": \"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9\",\n \"value\": 0.0018\n }],\n \"fee\": {\n \t\"address\" : \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n \"value\": 0.00023141\n },\n \"data\": \"CRYPTOAPISROCKS\",\n \"replaceable\": true\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/txs/create",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ inputs:
[ { address: 'mtFYoSowT3i649wnBDYjCjewenh8AuofQb', value: 0.0004 },
{ address: 'mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1', value: 0.0004 } ],
outputs: [ { address: 'mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9', value: 0.0018 } ],
fee:
{ address: 'mtFYoSowT3i649wnBDYjCjewenh8AuofQb',
value: 0.00023141 },
data: 'CRYPTOAPISROCKS',
replaceable: true }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/txs/create');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"inputs": [{
"address": "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"value": 0.0004
}, {
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"value": 0.0004
}],
"outputs": [{
"address": "mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9",
"value": 0.0018
}],
"fee": {
"address" : "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"value": 0.00023141
},
"data": "CRYPTOAPISROCKS",
"replaceable": true
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/txs/create")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n \"inputs\": [{\n \"address\": \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n \"value\": 0.0004\n }, {\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.0004\n }],\n \"outputs\": [{\n \"address\": \"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9\",\n \"value\": 0.0018\n }],\n \"fee\": {\n \t\"address\" : \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n \"value\": 0.00023141\n },\n \"data\": \"CRYPTOAPISROCKS\",\n \"replaceable\": true\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n \"inputs\": [{\n \"address\": \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n \"value\": 0.0004\n }, {\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.0004\n }],\n \"outputs\": [{\n \"address\": \"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9\",\n \"value\": 0.0018\n }],\n \"fee\": {\n \t\"address\" : \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n \"value\": 0.00023141\n },\n \"data\": \"CRYPTOAPISROCKS\",\n \"replaceable\": true\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/testnet/txs/create, payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"inputs\": [{\n \"address\": \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n \"value\": 0.0004\n }, {\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.0004\n }],\n \"outputs\": [{\n \"address\": \"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9\",\n \"value\": 0.0018\n }],\n \"fee\": {\n \t\"address\" : \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n \"value\": 0.00023141\n },\n \"data\": \"CRYPTOAPISROCKS\",\n \"replaceable\": true\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/txs/create")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/txs/create"
payload := strings.NewReader("{\n \"inputs\": [{\n \"address\": \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n \"value\": 0.0004\n }, {\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.0004\n }],\n \"outputs\": [{\n \"address\": \"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9\",\n \"value\": 0.0018\n }],\n \"fee\": {\n \t\"address\" : \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n \"value\": 0.00023141\n },\n \"data\": \"CRYPTOAPISROCKS\",\n \"replaceable\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"hex": "020000000260b02d56d1aeb581f8afe0cf9d5e3046f4a6d1caeee4ad199cc7cb8d4b4362910100000000fdffffff400d41544ff3112f692a6c1c4ede29b509a8e629d6f68d35de62ed34734d56270100000000fdffffff04dc110300000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac9a4f0400000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0000000000000000116a0f43525950544f41504953524f434b5320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac00000000"
}
}
To use Crypto APIs two-endpoint transaction creation tool, first you need to provide the input address(es), output address, and value to transfer (in bitcoin). Provide this in a partially-filled out TX request object.
HTTP Request
POST /v1/bc/btc/${NETWORK}/txs/create
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or mainnet) |
As you can see from the code example, you only need to provide a single public address within the addresses array of both the input and output of your TX request object. You also need to fill in the value with the amount you’d like to transfer from one address to another.
Required fields are:
{
"inputs": [{
"address": "...",
"value": ...
},
...],
"outputs": [{
"address": "...",
"value": ...
},
...],
"fee": {
"address": "...",
"value": ...
}
}
Optional fields include:
{
"locktime": ...,
"data": "...",
"replaceable": false/true
}
You need to include data
(string) field only if you want to send messages/metadata with the transaction. replaceable
(boolean) field is only required if you want to allow the transaction to be replaced by a transaction with higher fees (e.g. if you set a low fee and miners are not picking the transaction up for a long period of time). By default replaceable
is set to false.
Locktime
(integer) has a default value of zero. Use locktime
if a transaction should be delayed to a specific time.
As a return object, you’ll receive a JSON containing a slightly-more complete TX alongside data you need to sign in the tosign array. You’ll need this object for the next steps of the transaction creation process.
Validating the Data to Sign
For the extra cautious, you can protect yourself from a potential malicious attack on Crypto APIs by validating the data we’re asking you to sign. Unfortunately, it’s impossible to do so directly, as pre-signed signature data is hashed twice using SHA256. To get around this, set the includeToSignTx URL flag to true. The optional tosign_tx array will be returned within the JSON, which you can use in the following way:
- Decoding the hex-encoded string using our /txs/decode endpoint (or an independent, client-side source) should give you the output addresses and amounts that match your work-in-progress transaction.
Sign Transactions
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/testnet/txs/sign \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"hex":"020000000393d3ba1a02fd978b494e79ed199247079eb4f766fadc0b807c0734d4b18bd9810000000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00100000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00200000000ffffffff0320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac08c60000000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0c8c0000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac00000000",
"wifs" : [
"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud"
]
}'
POST /v1/bc/btc/testnet/txs/sign HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"hex":"020000000393d3ba1a02fd978b494e79ed199247079eb4f766fadc0b807c0734d4b18bd9810000000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00100000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00200000000ffffffff0320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac08c60000000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0c8c0000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac00000000",
"wifs" : [
"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud"
]
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/txs/sign",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n \"hex\":\"020000000393d3ba1a02fd978b494e79ed199247079eb4f766fadc0b807c0734d4b18bd9810000000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00100000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00200000000ffffffff0320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac08c60000000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0c8c0000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac00000000\",\n \"wifs\" : [\n \"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud\"\n ]\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/txs/sign",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ hex: '020000000393d3ba1a02fd978b494e79ed199247079eb4f766fadc0b807c0734d4b18bd9810000000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00100000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00200000000ffffffff0320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac08c60000000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0c8c0000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac00000000',
wifs: [ 'cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud' ] }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/txs/sign');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"hex":"020000000393d3ba1a02fd978b494e79ed199247079eb4f766fadc0b807c0734d4b18bd9810000000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00100000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00200000000ffffffff0320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac08c60000000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0c8c0000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac00000000",
"wifs" : [
"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud"
]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/txs/sign")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n \"hex\":\"020000000393d3ba1a02fd978b494e79ed199247079eb4f766fadc0b807c0734d4b18bd9810000000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00100000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00200000000ffffffff0320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac08c60000000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0c8c0000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac00000000\",\n \"wifs\" : [\n \"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud\"\n ]\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n \"hex\":\"020000000393d3ba1a02fd978b494e79ed199247079eb4f766fadc0b807c0734d4b18bd9810000000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00100000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00200000000ffffffff0320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac08c60000000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0c8c0000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac00000000\",\n \"wifs\" : [\n \"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud\"\n ]\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/testnet/txs/sign", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"hex\":\"020000000393d3ba1a02fd978b494e79ed199247079eb4f766fadc0b807c0734d4b18bd9810000000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00100000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00200000000ffffffff0320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac08c60000000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0c8c0000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac00000000\",\n \"wifs\" : [\n \"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud\"\n ]\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/txs/sign")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/txs/sign"
payload := strings.NewReader("{\n \"hex\":\"020000000393d3ba1a02fd978b494e79ed199247079eb4f766fadc0b807c0734d4b18bd9810000000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00100000000ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be00200000000ffffffff0320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac08c60000000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0c8c0000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac00000000\",\n \"wifs\" : [\n \"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"hex": "020000000393d3ba1a02fd978b494e79ed199247079eb4f766fadc0b807c0734d4b18bd981000000006a47304402202769801183cd50eb2bd6c316a55add49fa4c0fd7216b523f394b97fe410b582d02205c76f4009b38b82a20f88b5f6af45f09220ba43d7e1c2064fa74807ddb299d7f012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be0010000006a47304402204a24a1de4b4e552d1f53121825d139b1d1739d149df5a01d2ead760b865635c2022047a9b8f4d29dac29e9eacff6aea67249dcf716d576a00dbe24cf92c34a272909012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff7dbd03383a240f27c7735af707e823da894e11732c5fe5919adff1672b817be0020000006a473044022057a3fa58744fffebcb8a1bea4a99bd61049678d4ee9250c5f66ea17198ebd97a022078abef9098838d06e9a51099ce010f0dc74c6b1284de03a929bcdabab8fd4cd40121039299b5f32a4834e27662397b7ade9cacdd9cd7243b83c039c22da3c6dc0b28c7ffffffff0320bf0200000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac08c60000000000001976a9148bafc8dad0c87025278b4cc1c80ac8d402cb59eb88ac0c8c0000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac00000000",
"complete": true
}
}
Info
The Sign Transactions Endpoint allows users to sign a raw transaction.
HTTP Request
POST /v1/bc/btc/${NETWORK}/txs/sign
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
The returned object is a hexadecimal string that represents the signed transaction. This hexadecimal is used by the Send Transactions Endpoint in order to broadcast the transaction into the Bitcoin blockchain.
Send Transactions
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/testnet/txs/send/ \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"hex" : "02000000012ef6ff4aaa76aaff4bea235df134923a830a89d2fbdea5fdc330c9a42eb920a8010000006a47304402205c44fb58b3eaa907cccb2cac87749f00cb52f0d050d183ebba80d672413b9a540220749c8b53665db9f36d5e760ad627b0e22072a6cf91a5d77d35ac2b95d4c1ea54012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff02c8320000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac80380100000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac00000000"
}'
POST /v1/bc/btc/testnet/txs/send HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"hex" : "02000000012ef6ff4aaa76aaff4bea235df134923a830a89d2fbdea5fdc330c9a42eb920a8010000006a47304402205c44fb58b3eaa907cccb2cac87749f00cb52f0d050d183ebba80d672413b9a540220749c8b53665db9f36d5e760ad627b0e22072a6cf91a5d77d35ac2b95d4c1ea54012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff02c8320000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac80380100000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac00000000"
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/txs/send",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"hex\" : \"02000000012ef6ff4aaa76aaff4bea235df134923a830a89d2fbdea5fdc330c9a42eb920a8010000006a47304402205c44fb58b3eaa907cccb2cac87749f00cb52f0d050d183ebba80d672413b9a540220749c8b53665db9f36d5e760ad627b0e22072a6cf91a5d77d35ac2b95d4c1ea54012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff02c8320000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac80380100000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac00000000\"\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/txs/send",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ hex: '02000000012ef6ff4aaa76aaff4bea235df134923a830a89d2fbdea5fdc330c9a42eb920a8010000006a47304402205c44fb58b3eaa907cccb2cac87749f00cb52f0d050d183ebba80d672413b9a540220749c8b53665db9f36d5e760ad627b0e22072a6cf91a5d77d35ac2b95d4c1ea54012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff02c8320000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac80380100000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac00000000' }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/txs/send');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"hex" : "02000000012ef6ff4aaa76aaff4bea235df134923a830a89d2fbdea5fdc330c9a42eb920a8010000006a47304402205c44fb58b3eaa907cccb2cac87749f00cb52f0d050d183ebba80d672413b9a540220749c8b53665db9f36d5e760ad627b0e22072a6cf91a5d77d35ac2b95d4c1ea54012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff02c8320000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac80380100000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac00000000"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/txs/send")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"hex\" : \"02000000012ef6ff4aaa76aaff4bea235df134923a830a89d2fbdea5fdc330c9a42eb920a8010000006a47304402205c44fb58b3eaa907cccb2cac87749f00cb52f0d050d183ebba80d672413b9a540220749c8b53665db9f36d5e760ad627b0e22072a6cf91a5d77d35ac2b95d4c1ea54012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff02c8320000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac80380100000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac00000000\"\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"hex\" : \"02000000012ef6ff4aaa76aaff4bea235df134923a830a89d2fbdea5fdc330c9a42eb920a8010000006a47304402205c44fb58b3eaa907cccb2cac87749f00cb52f0d050d183ebba80d672413b9a540220749c8b53665db9f36d5e760ad627b0e22072a6cf91a5d77d35ac2b95d4c1ea54012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff02c8320000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac80380100000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac00000000\"\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/testnet/txs/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"hex\" : \"02000000012ef6ff4aaa76aaff4bea235df134923a830a89d2fbdea5fdc330c9a42eb920a8010000006a47304402205c44fb58b3eaa907cccb2cac87749f00cb52f0d050d183ebba80d672413b9a540220749c8b53665db9f36d5e760ad627b0e22072a6cf91a5d77d35ac2b95d4c1ea54012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff02c8320000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac80380100000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac00000000\"\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/txs/send")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/txs/send"
payload := strings.NewReader("{\n\t\"hex\" : \"02000000012ef6ff4aaa76aaff4bea235df134923a830a89d2fbdea5fdc330c9a42eb920a8010000006a47304402205c44fb58b3eaa907cccb2cac87749f00cb52f0d050d183ebba80d672413b9a540220749c8b53665db9f36d5e760ad627b0e22072a6cf91a5d77d35ac2b95d4c1ea54012102275753690ab58df3c923001e94d407e30b03e60b1f2461729a1dd4f37ebe2469ffffffff02c8320000000000001976a914481e003d23566c1789dc9362085c3a0876570c7c88ac80380100000000001976a9147b9a627a184897f10d31d73d87c2eea191d8f50188ac00000000\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"txid": "dd033f3d0639f9ed7fdcef5966d931e833f13364cdf7c742af0ea5f04806bc62"
}
}
Transaction Send Endpoint allows users to broadcast the signed transaction to the Bitcoin blockchain.
HTTP Request
POST /v1/bc/btc/${NETWORK}/txs/send
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
If broadcasting is successful, you’ll receive a JSON with the hash of the unconfirmed transaction.
New Transaction
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/new \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"createTx": {
"inputs": [{
"address": "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"value": 0.00009
}, {
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"value": 0.00004
}, {
"address": "mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9",
"value": 0.00005
}],
"outputs": [{
"address": "mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz",
"value": 0.00018
}],
"fee": {
"address": "mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz",
"value": 0.00023141
}
},
"wifs" : [
"cUGddnJmuzfzpWXNwt1SRnQ8GMqZdQ1vg8BtwjG8f275pvExPzaX", "cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud", "cV2u6dqfiQthWfPixJ7ucFW5Tza1ubLr6ipM35vSTy9xGEKbCbaJ"
]
}'
POST /v1/bc/btc/mainnet/txs/new HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"createTx": {
"inputs": [{
"address": "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"value": 0.00009
}, {
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"value": 0.00004
}, {
"address": "mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9",
"value": 0.00005
}],
"outputs": [{
"address": "mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz",
"value": 0.00018
}],
"fee": {
"address": "mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz",
"value": 0.00023141
}
},
"wifs" : [
"cUGddnJmuzfzpWXNwt1SRnQ8GMqZdQ1vg8BtwjG8f275pvExPzaX", "cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud", "cV2u6dqfiQthWfPixJ7ucFW5Tza1ubLr6ipM35vSTy9xGEKbCbaJ"
]
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/new",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"createTx\": { \n\t\t\t\"inputs\": [{\n\t\t\t\"address\": \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n\t\t\t\"value\": 0.00009\n\t\t}, {\n\t\t\t\"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n\t\t\t\"value\": 0.00004\n\t\t}, {\n\t\t\t\"address\": \"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9\",\n\t\t\t\"value\": 0.00005\n\t\t}],\n\t\t\"outputs\": [{\n\t\t\t\"address\": \"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz\",\n\t\t\t\"value\": 0.00018\n\t\t}],\n\t\t\n\t\t\"fee\": {\n\t\t\t\"address\": \"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz\",\n\t\t\t\"value\": 0.00023141\n\t\t}\n\t}, \n\t \"wifs\" : [\n \"cUGddnJmuzfzpWXNwt1SRnQ8GMqZdQ1vg8BtwjG8f275pvExPzaX\", \"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud\", \"cV2u6dqfiQthWfPixJ7ucFW5Tza1ubLr6ipM35vSTy9xGEKbCbaJ\"\n ]\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/txs/new",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ createTx:
{ inputs:
[ { address: 'mtFYoSowT3i649wnBDYjCjewenh8AuofQb',
value: 0.00009 },
{ address: 'mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1',
value: 0.00004 },
{ address: 'mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9',
value: 0.00005 } ],
outputs:
[ { address: 'mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz',
value: 0.00018 } ],
fee:
{ address: 'mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz',
value: 0.00023141 } },
wifs:
[ 'cUGddnJmuzfzpWXNwt1SRnQ8GMqZdQ1vg8BtwjG8f275pvExPzaX',
'cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud',
'cV2u6dqfiQthWfPixJ7ucFW5Tza1ubLr6ipM35vSTy9xGEKbCbaJ' ] }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/new');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"createTx": {
"inputs": [{
"address": "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"value": 0.00009
}, {
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"value": 0.00004
}, {
"address": "mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9",
"value": 0.00005
}],
"outputs": [{
"address": "mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz",
"value": 0.00018
}],
"fee": {
"address": "mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz",
"value": 0.00023141
}
},
"wifs" : [
"cUGddnJmuzfzpWXNwt1SRnQ8GMqZdQ1vg8BtwjG8f275pvExPzaX", "cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud", "cV2u6dqfiQthWfPixJ7ucFW5Tza1ubLr6ipM35vSTy9xGEKbCbaJ"
]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/new")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"createTx\": { \n\t\t\t\"inputs\": [{\n\t\t\t\"address\": \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n\t\t\t\"value\": 0.00009\n\t\t}, {\n\t\t\t\"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n\t\t\t\"value\": 0.00004\n\t\t}, {\n\t\t\t\"address\": \"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9\",\n\t\t\t\"value\": 0.00005\n\t\t}],\n\t\t\"outputs\": [{\n\t\t\t\"address\": \"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz\",\n\t\t\t\"value\": 0.00018\n\t\t}],\n\t\t\n\t\t\"fee\": {\n\t\t\t\"address\": \"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz\",\n\t\t\t\"value\": 0.00023141\n\t\t}\n\t}, \n\t \"wifs\" : [\n \"cUGddnJmuzfzpWXNwt1SRnQ8GMqZdQ1vg8BtwjG8f275pvExPzaX\", \"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud\", \"cV2u6dqfiQthWfPixJ7ucFW5Tza1ubLr6ipM35vSTy9xGEKbCbaJ\"\n ]\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"createTx\": { \n\t\t\t\"inputs\": [{\n\t\t\t\"address\": \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n\t\t\t\"value\": 0.00009\n\t\t}, {\n\t\t\t\"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n\t\t\t\"value\": 0.00004\n\t\t}, {\n\t\t\t\"address\": \"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9\",\n\t\t\t\"value\": 0.00005\n\t\t}],\n\t\t\"outputs\": [{\n\t\t\t\"address\": \"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz\",\n\t\t\t\"value\": 0.00018\n\t\t}],\n\t\t\n\t\t\"fee\": {\n\t\t\t\"address\": \"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz\",\n\t\t\t\"value\": 0.00023141\n\t\t}\n\t}, \n\t \"wifs\" : [\n \"cUGddnJmuzfzpWXNwt1SRnQ8GMqZdQ1vg8BtwjG8f275pvExPzaX\", \"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud\", \"cV2u6dqfiQthWfPixJ7ucFW5Tza1ubLr6ipM35vSTy9xGEKbCbaJ\"\n ]\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/mainnet/txs/new", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"createTx\": { \n\t\t\t\"inputs\": [{\n\t\t\t\"address\": \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n\t\t\t\"value\": 0.00009\n\t\t}, {\n\t\t\t\"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n\t\t\t\"value\": 0.00004\n\t\t}, {\n\t\t\t\"address\": \"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9\",\n\t\t\t\"value\": 0.00005\n\t\t}],\n\t\t\"outputs\": [{\n\t\t\t\"address\": \"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz\",\n\t\t\t\"value\": 0.00018\n\t\t}],\n\t\t\n\t\t\"fee\": {\n\t\t\t\"address\": \"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz\",\n\t\t\t\"value\": 0.00023141\n\t\t}\n\t}, \n\t \"wifs\" : [\n \"cUGddnJmuzfzpWXNwt1SRnQ8GMqZdQ1vg8BtwjG8f275pvExPzaX\", \"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud\", \"cV2u6dqfiQthWfPixJ7ucFW5Tza1ubLr6ipM35vSTy9xGEKbCbaJ\"\n ]\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/new")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/new"
payload := strings.NewReader("{\n\t\"createTx\": { \n\t\t\t\"inputs\": [{\n\t\t\t\"address\": \"mtFYoSowT3i649wnBDYjCjewenh8AuofQb\",\n\t\t\t\"value\": 0.00009\n\t\t}, {\n\t\t\t\"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n\t\t\t\"value\": 0.00004\n\t\t}, {\n\t\t\t\"address\": \"mrnWMV41vXivQX9yiY9ACSK5uPo3TfJdv9\",\n\t\t\t\"value\": 0.00005\n\t\t}],\n\t\t\"outputs\": [{\n\t\t\t\"address\": \"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz\",\n\t\t\t\"value\": 0.00018\n\t\t}],\n\t\t\n\t\t\"fee\": {\n\t\t\t\"address\": \"mmskWH7hG9CJNzb16JaVFJyWdgAwcVEAkz\",\n\t\t\t\"value\": 0.00023141\n\t\t}\n\t}, \n\t \"wifs\" : [\n \"cUGddnJmuzfzpWXNwt1SRnQ8GMqZdQ1vg8BtwjG8f275pvExPzaX\", \"cSEjySAREyai8eQhgoqixzmxCeSP8QtbwHxptL8ijofg68ZMjoud\", \"cV2u6dqfiQthWfPixJ7ucFW5Tza1ubLr6ipM35vSTy9xGEKbCbaJ\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"txid":"81d98bb1d434077c800bdcfa66f7b49e07479219ed794e498b97fd021abad393"
}
}
The New Transaction Endpoint combines the other three endpoints: Create, Sign and Send Endpoints. Users should provide the inputs and outputs fields with the corresponding data, as well as the fee and the wifs(private ECDSA keys) of the addresses. Therefore, the endpoint creates, signs and broadcasts the new transaction to the Bitcoin Blockchain. For more information, see the examples.
Users can set three optional fields within the createTx
object: data
, replaceable
and locktime
.
"createTx": {
"inputs": [ {
"address": "...",
"value": ...
}],
"outputs": [{
"address": "...",
"value": ...
}],
"fee": {
"address": "...",
"value": ...
},
"locktime": ...,
"data": "CRYPTOAPISROCKS",
"replaceable": false/true
}
You need to include data
(string) field only if you want to send messages/metadata with the transaction. replaceable
(boolean) field is only required if you want to allow the transaction to be replaced by a transaction with higher fees (e.g. if you set a low fee and miners are not picking the transaction up for a long period of time). By default replaceable
is set to false.
Locktime
(integer) has a default value of zero. Use locktime
if a transaction should be delayed to a specific time.
HTTP Request
POST /v1/bc/btc/${NETWORK}/txs/new
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
New Transaction Using HDWallet
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/hdwallet \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"walletName": "demohdwallet",
"password" : "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32",
"outputs": [{
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"value": 0.004
}],
"fee": {
"value": 0.00023141
},
"locktime": 0
}'
POST /v1/bc/btc/mainnet/txs/hdwallet HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"walletName": "demohdwallet",
"password" : "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32",
"outputs": [{
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"value": 0.004
}],
"fee": {
"value": 0.00023141
},
"locktime": 0
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/hdwallet",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"walletName\": \"demohdwallet\",\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\t\"outputs\": [{\n\t\t\"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n\t\t\"value\": 0.004\n\t}],\n\t\n\t\"fee\": {\n\t\t\"value\": 0.00023141\n\t},\n\t\"locktime\": 0\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/txs/hdwallet",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ walletName: 'demohdwallet',
password: '8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32',
outputs: [ { address: 'mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1', value: 0.004 } ],
fee: { value: 0.00023141 },
locktime: 0 }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/hdwallet');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"walletName": "demohdwallet",
"password" : "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32",
"outputs": [{
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"value": 0.004
}],
"fee": {
"value": 0.00023141
},
"locktime": 0
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/hdwallet")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"walletName\": \"demohdwallet\",\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\t\"outputs\": [{\n\t\t\"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n\t\t\"value\": 0.004\n\t}],\n\t\n\t\"fee\": {\n\t\t\"value\": 0.00023141\n\t},\n\t\"locktime\": 0\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"walletName\": \"demohdwallet\",\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\t\"outputs\": [{\n\t\t\"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n\t\t\"value\": 0.004\n\t}],\n\t\n\t\"fee\": {\n\t\t\"value\": 0.00023141\n\t},\n\t\"locktime\": 0\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/mainnet/txs/hdwallet", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"walletName\": \"demohdwallet\",\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\t\"outputs\": [{\n\t\t\"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n\t\t\"value\": 0.004\n\t}],\n\t\n\t\"fee\": {\n\t\t\"value\": 0.00023141\n\t},\n\t\"locktime\": 0\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/hdwallet")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/hdwallet"
payload := strings.NewReader("{\n\t\"walletName\": \"demohdwallet\",\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\t\"outputs\": [{\n\t\t\"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n\t\t\"value\": 0.004\n\t}],\n\t\n\t\"fee\": {\n\t\t\"value\": 0.00023141\n\t},\n\t\"locktime\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"txid": "20aa774b7f439ae5d5bb4dd0101362c4011f68bbdaef59b5ae5e3eba39b973bc"
}
}
New Transaction Using HDWallet Endpoint provides the possibility to create, sign and send new transactions using your HDWallet. The mandatory fields are: walletName, password, outputs and fee (see example). There are a few optional fields, such as: inputs, fee address and locktime. If input addresses are not included, then the system will automatically choose addresses from the wallet. However, if included, a list of addresses from the wallet and the values should be specified. Fee address is optional and if is specified the fee will be proportionally distributed among the input addresses.
Three optional fields are available:
{
"locktime": ...,
"data": "...",
"replaceable": false/true
}
You need to include data
(string) field only if you want to send messages/metadata with the transaction. replaceable
(boolean) field is only required if you want to allow the transaction to be replaced by a transaction with higher fees (e.g. if you set a low fee and miners are not picking the transaction up for a long period of time). By default replaceable
is set to false.
Locktime
(integer) has a default value of zero. Use locktime
if a transaction should be delayed to a specific time.
HTTP Request
POST /v1/bc/btc/${NETWORK}/txs/hdwallet
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or mainnet) |
See the example where the complete JSON object request (mandatory* and optional fields inlcuded) is shown.
The complete JSON object request:
{
"walletName*": "walletName",
"password*" : "...",
"inputs":[{
"address":"n...",
"value":0.1
},{
"address":"n...",
"value":0.3
}],
"outputs*": [{
"address": "m...",
"value": 0.4
}],
"fee": {
"address": "n...",
"value*": 0.0002314
},
"locktime": 0,
"data": "CRYPTOAPISROCKS",
"replaceable": true
}
Transactions Fee
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/fee' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/txs HTTP/1.1
Host: api.cryptoapis.io
X-API-Key: my-api-key
Content-Type: application/json
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/fee",
"method": "GET",
"headers": {
"authorization": "my-api-key",
"content-type": "application/json"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"port": null,
"path": "/v1/bc/btc/mainnet/txs",
"headers": {
"authorization": "my-api-key",
"content-type": "application/json"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/fee');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/fee")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import requests
url = "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/fee"
headers = {
'content-type': "application/json",
'authorization': "my-api-key"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/fee")
.get()
.addHeader("authorization", "my-api-key")
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/fee"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("authorization", "my-api-key")
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"min": "0.00000129",
"max": "0.08474670",
"average": "0.00029540",
"average_bytes": "540",
"recommended": "0.00025245",
"unit": "btc"
}
}
Info
Transactions Fee Endpoint gives information about the fees for all transactions included in the last 70 blocks. min
shows the lowest fee, max
is the highest and average
- the average fee. recommended
is the fee that we consider as the one that corresponds to a cheap and fast execution. However, it is only a suggestion and should be used at users' sole discretion. average_bytes
represents the average size of the transactions in bytes and is used for the calculations of the recommended
fee price. All fees are in btc.
HTTP Request
GET /v1/bc/btc/${NETWORK}/txs/fee
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
Refund Transaction
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/testnet/txs/refund \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"txid" : "155203217b6080de07fbd501228ec364e6abfb82453e0a0a04ba3f1832946dfb",
"wif": "cV2u6dqfiQthW......M35vSTy9xGEKbCbaJ",
"fee": 0.000123
}'
POST /v1/bc/btc/testnet/txs/refund HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"txid" : "155203217b6080de07fbd501228ec364e6abfb82453e0a0a04ba3f1832946dfb",
"wif": "cV2u6dqfiQthW......M35vSTy9xGEKbCbaJ",
"fee": 0.000123
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/txs/refund",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"txid\" : \"155203217b6080de07fbd501228ec364e6abfb82453e0a0a04ba3f1832946dfb\",\n\t\"wif\": \"cV2u6dqfiQthW......M35vSTy9xGEKbCbaJ\",\n\t\"fee\": 0.000123\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/txs/refund",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ txid: '155203217b6080de07fbd501228ec364e6abfb82453e0a0a04ba3f1832946dfb',
wif: 'cV2u6dqfiQthW......M35vSTy9xGEKbCbaJ',
fee: 0.000123 }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/txs/refund');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"txid" : "155203217b6080de07fbd501228ec364e6abfb82453e0a0a04ba3f1832946dfb",
"wif": "cV2u6dqfiQthW......M35vSTy9xGEKbCbaJ",
"fee": 0.000123
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/txs/refund")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"txid\" : \"155203217b6080de07fbd501228ec364e6abfb82453e0a0a04ba3f1832946dfb\",\n\t\"wif\": \"cV2u6dqfiQthW......M35vSTy9xGEKbCbaJ\",\n\t\"fee\": 0.000123\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"txid\" : \"155203217b6080de07fbd501228ec364e6abfb82453e0a0a04ba3f1832946dfb\",\n\t\"wif\": \"cV2u6dqfiQthW......M35vSTy9xGEKbCbaJ\",\n\t\"fee\": 0.000123\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/testnet/txs/refund", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"txid\" : \"155203217b6080de07fbd501228ec364e6abfb82453e0a0a04ba3f1832946dfb\",\n\t\"wif\": \"cV2u6dqfiQthW......M35vSTy9xGEKbCbaJ\",\n\t\"fee\": 0.000123\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/txs/refund")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/txs/refund"
payload := strings.NewReader("{\n\t\"txid\" : \"155203217b6080de07fbd501228ec364e6abfb82453e0a0a04ba3f1832946dfb\",\n\t\"wif\": \"cV2u6dqfiQthW......M35vSTy9xGEKbCbaJ\",\n\t\"fee\": 0.000123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"txid":"9bed0c9a2ca62280aca35dd57fb24757dca9f18a9215471c5f59adab314a4aed"
}
}
The Refund Transaction Endpoint allows users easily to return the amount in btc they have received from an unknown source.
Only two fields are required: the txid
of the transcation and the wif
of the recipient address (see examples).
There is an optional field fee
. If fee
field is not set the system will set the recommended fee from the Transaction Fee Endpoint.
HTTP Request
POST /v1/bc/btc/${NETWORK}/txs/refund
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
Payment Forwarding
Payment Forwarding is an automatic way to move any received funds to another wallet, it's mainly used to move funds once received to cold wallets. Moving funds from hot wallets to cold wallets is a common practice in the market, it's used by all exchanges and wallets. You can subscribe for payment forwarding for any wallet/address you own, in the subscription you mention where to move the funds and how to notify you once done. Crypto APIs will monitor the wallet/address you have subscription for and once any funds are received, Crypto APIs will move them to the target wallet/address then notify you by sending a call to the URL you have specified. commerce without necessarily requiring extensive setup barriers, like registering new accounts. In that spirit, our Payment Forwarding API is the easiest way to accept—and consolidate—payments securely without forcing your users to create accounts and jump through unnecessary loops. It’s also a generic way to automatically transfer value from one address to another. One of the well-known benefits of cryptocurrency is the ability to allow users to partake in online commerce without necessarily requiring extensive setup barriers, like registering new accounts. In that spirit, our Payment Forwarding API is the easiest way to accept—and consolidate—payments securely without forcing your users to create accounts and jump through unnecessary loops. It’s also a generic way to automatically transfer value from one address to another. While there are many possible use cases, the two we hear most about are: A way to generate payment-specific addresses for which funds will automatically transfer to a main merchant address. Great for automatic merchandise (whether physical or virtual) processing.
We do not take a fee on payment forwarding, other than the required miner fee; payments are free. However, as part of your own services, you can include a fee (either fixed or a percentage) that will also be automatically transfered to your own address in the same transaction. Fee-based business models are thus easily achieved, and moreover, easily auditable via the blockchain.
Create Payment
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/testnet/payments \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"wallet": "demohdwallet",
"callback": "http://myaddress.com/paymet_forwarding_hook",
"from": "n3qkBXM2xufzcJvwEjGzHDYTRWLFNJ9Vmx",
"to": "mr3nDS1RSLzJryatXm9uDU6XCodWi3mLoa",
"password": "SECRET123456",
"confirmations": 2,
"fee": 0.00022827
}'
POST /v1/bc/btc/testnet/payments HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"wallet": "demohdwallet",
"callback": "http://myaddress.com/paymet_forwarding_hook",
"from": "n3qkBXM2xufzcJvwEjGzHDYTRWLFNJ9Vmx",
"to": "mr3nDS1RSLzJryatXm9uDU6XCodWi3mLoa",
"password" : "SECRET123456",
"confirmations": 2,
"fee": 0.00022827
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/payments",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n \"wallet\": \"demohdwallet\",\n \"callback\": \"http://myaddress.com/paymet_forwarding_hook\",\n \"from\": \"n3qkBXM2xufzcJvwEjGzHDYTRWLFNJ9Vmx\",\n \"to\": \"mr3nDS1RSLzJryatXm9uDU6XCodWi3mLoa\",\n \"password\" : \"SECRET123456\",\n \"confirmations\": 2,\n \"fee\": 0.00022827\n}\n"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "https://api.cryptoapis.io/v1/bc/btc/testnet/payments",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ wallet: 'demohdwallet',
callback: 'http://myaddress.com/paymet_forwarding_hook',
from: 'n3qkBXM2xufzcJvwEjGzHDYTRWLFNJ9Vmx',
to: 'mr3nDS1RSLzJryatXm9uDU6XCodWi3mLoa',
password: 'SECRET123456',
confirmations: 2,
fee: 0.00022827 }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/payments');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"wallet": "demohdwallet",
"callback": "http://myaddress.com/paymet_forwarding_hook",
"from": "n3qkBXM2xufzcJvwEjGzHDYTRWLFNJ9Vmx",
"to": "mr3nDS1RSLzJryatXm9uDU6XCodWi3mLoa",
"password" : "SECRET123456",
"confirmations": 2,
"fee": 0.00022827
}
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/payments")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n \"wallet\": \"demohdwallet\",\n \"callback\": \"http://myaddress.com/paymet_forwarding_hook\",\n \"from\": \"n3qkBXM2xufzcJvwEjGzHDYTRWLFNJ9Vmx\",\n \"to\": \"mr3nDS1RSLzJryatXm9uDU6XCodWi3mLoa\",\n \"password\" : \"SECRET123456\",\n \"confirmations\": 2,\n \"fee\": 0.00022827\n}\n"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n \"wallet\": \"demohdwallet\",\n \"callback\": \"http://myaddress.com/paymet_forwarding_hook\",\n \"from\": \"n3qkBXM2xufzcJvwEjGzHDYTRWLFNJ9Vmx\",\n \"to\": \"mr3nDS1RSLzJryatXm9uDU6XCodWi3mLoa\",\n \"password\" : \"SECRET123456\",\n \"confirmations\": 2,\n \"fee\": 0.00022827\n}\n"
headers = {
'Content-Type': "application/json",
'X-API-Key': 'my-api-key'
}
conn.request("POST", "/v1/bc/btc/testnet/payments", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"wallet\": \"demohdwallet\",\n \"callback\": \"http://myaddress.com/paymet_forwarding_hook\",\n \"from\": \"n3qkBXM2xufzcJvwEjGzHDYTRWLFNJ9Vmx\",\n \"to\": \"mr3nDS1RSLzJryatXm9uDU6XCodWi3mLoa\",\n \"password\" : \"SECRET123456\",\n \"confirmations\": 2,\n \"fee\": 0.00022827\n}\n");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/payments")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/payments"
payload := strings.NewReader("{\n \"wallet\": \"demohdwallet\",\n \"callback\": \"http://myaddress.com/paymet_forwarding_hook\",\n \"from\": \"n3qkBXM2xufzcJvwEjGzHDYTRWLFNJ9Vmx\",\n \"to\": \"mr3nDS1RSLzJryatXm9uDU6XCodWi3mLoa\",\n \"password\" : \"SECRET123456\",\n \"confirmations\": 2,\n \"fee\": 0.00022827\n}\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"from": "n3qkBXM2xufzcJvwEjGzHDYTRWLFNJ9Vmx",
"to": "mr3nDS1RSLzJryatXm9uDU6XCodWi3mLoa",
"callback": "http://myaddress.com/paymet_forwarding_hook",
"wallet": "demohdwallet",
"uuid": "e034c540-c688-4902-8872-013cc5ce6a30",
"confirmations": 2,
"fee": "0.00022827"
}
}
Info
In order to create a payment forwarding you need to include the following data (POST request): - wallet - from - to - callback (url) - wallet password - confirmations - fee (optional)
If field fee
is not set, the payment forwarding will be executed with the recommended
fee from the Transactions Fee Endpoint.
When payment forwarding is triggered you will receive a notification on the callback(url) you've specified when the payment forwarding was created.
HTTP Request
POST /v1/bc/btc/${NETWORK}/payments
Request Object
{
"from": "${FROM_ADDRESS}",
"to": "${TO_ADDRESS}",
"callback": "${CALLBACK_URL}",
"wallet": ${HD_WALLET_NAME},
"password": ${WALLET_PASSWORD}
"confirmations": ${CONFIRMATIONS}
"fee": ${FEE}
}
After executing the forwarding payment a message will be sent to the specified callback(url), similar to the following:
{
"currency": "BTC",
"network": "testnet",
"type": "PAYMENT_FORWARDING",
"uuid": "19b220ec-eb3c-4ac9-af3b-ed37269b9448",
"txid": "95d88fb742c96378cc30185601088acf97ff5a3dc32399ca0800b4fa171013bc",
"url" : "http://myaddress.com/paymet_forwarding_hook",
"status": "DONE",
"message": "Payment forwarding was successful!"
}
There are total of four payment statuses: DONE, FAILED, PENDING and OUT_OF_BALANCE.
For some reasons the payment forwarding may fail.
{
"payload": {
"currency": "BTC",
"network": "testnet",
"uuid": "19b220ec-eb3c-4ac9-af3b-ed37269b9448",
"type": "PAYMENT_FORWARDING",
"url" : "http://myaddress.com/paymet_forwarding_hook",
"status": "FAILED",
}
}
If status is
FAILED
it means that this forwarding will be executed when the next block is mined.Payments might be pending:
{
"payload": {
"currency": "BTC",
"network": "testnet",
"uuid": "19b220ec-eb3c-4ac9-af3b-ed37269b9448",
"type": "PAYMENT_FORWARDING",
"url" : "http://myaddress.com/paymet_forwarding_hook",
"status": "PENDING",
}
}
When next block is mined an attempt for executing this payment will be made. If the value from the transaction that triggers the payment forwarding is spent before the execution of the payment is done, a message will be sent to the specified url:
{
"currency": "BTC",
"network": "testnet",
"uuid": "19b220ec-eb3c-4ac9-af3b-ed37269b9448",
"type": "PAYMENT_FORWARDING",
"url" : "http://myaddress.com/paymet_forwarding_hook",
"status": "OUT_OF_BALANCE",
"message": "Payment forwarding was not successful! Reason: Balance is not enough!"
}
When status is set to OUT_OF_BALANCE other attempts for executing the payment will not be made.
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | - | Network name (e.g. testnet or mainnet) |
FROM_ADDRESS | - | destination bitcoin address |
TO_ADDRESS | - | target bitcoin address |
CALLBACK_URL | - | callback url addres that will be called after forwarding is processed |
WALLET_NAME | - | wallet created by current USER_ID |
WALLET_PASSWORD | - | wallet password |
CONFIRMATIONS | - | after how many confirmations to execute the payment forwarding |
FEE (Optional) | - | what fee should be paid for the transaction (in BTC) |
List Payment
Sample Data
curl -X GET \
https://api.cryptoapis.io/v1/bc/btc/testnet/payments \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/payments HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/payments",
"method": "GET",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/payments",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/payments');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/payments")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
'Content-Type': "application/json" ,
'X-API-Key': "my-api-key"
}
conn.request("GET", "/v1/bc/btc/testnet/payments", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/payments")
.get()
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/payments"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": [
{
"from": "mgbrYCKAssc6cBnb15HkhjEJn5nY8raAhz",
"to": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"callback": "http://myaddress.com/paymet_forwarding_hook",
"wallet": "demohdwallet",
"uuid": "8930fdf4-5664-49c4-a51e-15c5edf5eb8f",
"fee": "0",
"confirmations": 1
},
{
"from": "mudZF8cTSiSLFCmwTNmpvmLUKogTw2CgVY",
"to": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"callback": "http://myaddress.com/paymet_forwarding_hook",
"wallet": "demohdwallet",
"uuid": "c1dba6dd-67e6-4970-90c5-23dc389c4bcb",
"confirmations": 1
},
{
"from": "mvhThy8jXfYxTFW9XkFLnww9AXzhfkNsan",
"to": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"callback": "http://myaddress.com/paymet_forwarding_hook",
"wallet": "demohdwallet",
"uuid": "721a90d2-af27-4ecb-b790-4ddfb090f2b8",
"confirmations": 3
}
],
"meta": {
"totalCount": 4,
"results": 4
}
}
Info
To list your currently active payment forwarding addresses, you can use this endpoint.
HTTP Request
GET /v1/bc/btc/${NETWORK}/payments
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | - | Network name (e.g. testnet or mainnet) |
This returns the full array of your currently active payment forwarding addresses.
Get My Past Payments Forwardings
Sample Data
curl -X GET \
https://api.cryptoapis.io/v1/bc/btc/testnet/payments/history \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/payments/history HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/payments/history",
"method": "GET",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/payments/history",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/payments/history');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/payments/history")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
'Content-Type': "application/json" ,
'X-API-Key': "my-api-key"
}
conn.request("GET", "/v1/bc/btc/testnet/payments/history", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/payments/history")
.get()
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/payments/history"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": [
{
"status": "DONE",
"uuid": "5f0f275f-6360-47ed-9f29-0a5d68bc9584",
"block_height": 1486198,
"txid": "9f908420e3cd0b939711a809cf7028e4914a0474f61d75438ad8e20cc72da82f",
"payment_uuid": "c1dba6dd-67e6-4970-90c5-23dc389c4bcb"
},
{
"status": "DONE",
"uuid": "721a90d2-af27-4ecb-b790-4ddfb090f2b8",
"block_height": 1486173,
"txid": "1d6136e2357c000811f9352f8db29990e884e9cb3ecf64543120c7962bfc1d68",
"payment_uuid": "721a90d2-af27-4ecb-b790-4ddfb090f2b8"
},
{
"status": "DONE",
"uuid": "859774b8-fba9-4d41-a4a5-a180c92b14ac",
"block_height": 1486181,
"txid": "afb238aa0d0b8d17b30cf63965c5621f1f1c08b94c005c6e5ba812971b68a00a",
"payment_uuid": "c1dba6dd-67e6-4970-90c5-23dc389c4bcb"
}
],
"meta": {
"totalCount": 15,
"limit": 50,
"results": 15
}
}
Info
To list your currently active payment forwarding addresses, you can use this endpoint.
HTTP Request
GET /v1/bc/btc/${NETWORK}/payments/history
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | - | Network name (e.g. testnet or mainnet) |
If the request is successful, you’ll receive a JSON (see the response body) and an HTTP Status Code 200.
Delete Payment
Sample Data
curl -X DELETE \
https://api.cryptoapis.io/v1/bc/btc/testnet/payments/f0e80c20-434b-4195-a1e4-e3cdfd8585f3 \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
DELETE /v1/bc/btc/testnet/payments/f0e80c20-434b-4195-a1e4-e3cdfd8585f3 HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/payments/f0e80c20-434b-4195-a1e4-e3cdfd8585f3",
"method": "DELETE",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "DELETE",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/payments/f0e80c20-434b-4195-a1e4-e3cdfd8585f3",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/payments/f0e80c20-434b-4195-a1e4-e3cdfd8585f3');
$request->setMethod(HTTP_METH_DELETE);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/testnet/payments/f0e80c20-434b-4195-a1e4-e3cdfd8585f3")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Delete.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
'Content-Type': "application/json" ,
'Authoization': "my-api-key"
}
conn.request("DELETE", "/v1/bc/btc/testnet/payments/f0e80c20-434b-4195-a1e4-e3cdfd8585f3", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/payments/f0e80c20-434b-4195-a1e4-e3cdfd8585f3")
.delete(null)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/payments/f0e80c20-434b-4195-a1e4-e3cdfd8585f3"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"message": "Payment Forwarding with uuid f0e80c20-434b-4195-a1e4-e3cdfd8585f3 was successfully deleted"
}
}
Info
When you’re done with a payment forwarding address, you can delete it via its uuid.
HTTP Request
DELETE /v1/bc/btc/${NETWORK}/payments/${PAYMENT_UUID}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | - | Network name (e.g. testnet or mainnet) |
PAYMENT_UUID | - | Generated UUID when payment forwarding was created |
PAYMENT_UUID is a string representing the payment forwarding request you want to delete, for example:
399d0923-e920-48ee-8928-2051cbfbc369
Webhook Notifications
Blockchains are highly transactional systems. Many usage patterns require knowing when an event occurs: i.e., when a transaction is included into a block, or when an unconfirmed transaction is relayed through the network. Instead of requiring you to continuously poll resources, we provide push APIs to facilitate those use cases, and support both WebSockets and Webhooks.
Which Should I Use?
WebSockets are typically used in client applications when a server is not already running: e.g., a web page displaying the most recent transactions or a wallet app updating its UI when a transaction has been confirmed. Websockets are less reliable in longer interactions (> 1 hour) because they require a connection to stay open.
Webhooks are the most reliable way to get event notifications but requires running a server to receive the callbacks. We automatically retry HTTP requests 5 times.
A Webhook request expects a response with status code 200 (OK) or it will retry the request.
Webhook Types
Info
We support a number of different event types, and you can filter your notification requests depending on how you structure your Event request object.
Event | Description |
---|---|
NEW_BLOCK | Triggered for every new block added to the blockchain you’ve selected as your base resource. The payload is a Block. |
CONFIRMED_TX | Triggered for every new transaction making it into a new block; in other words, for every first transaction confirmation. This is equivalent to listening to the new-block event and fetching each transaction in the new Block. The payload is a confirmed transaction. |
ADDRESS | Triggered any time an address appears in a transaction in a new block added to the blockchain or into the unconfirmed queue and waiting to be mined |
TRANSACTION_CONFIRMATIONS | Receive confirmations for a specified address. The payload is a json object that includes the transaction hash, the address, the block number, and the current and max confirmations. |
Create New Block Webhook
By creating New Block Webhook, you will receive a notification after every new block.
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"event" : "NEW_BLOCK",
"url" : "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5"
}'
POST /v1/bc/btc/mainnet/hooks HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"event" : "NEW_BLOCK",
"url" : "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5"
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"event\" : \"NEW_BLOCK\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\"\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/hooks",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ event: 'NEW_BLOCK',
url: 'http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5' }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"event" : "NEW_BLOCK",
"url" : "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"event\" : \"NEW_BLOCK\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\"\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"event\" : \"NEW_BLOCK\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\"\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "Bearer my-genrated-token"
}
conn.request("POST", "/v1/bc/btc/mainnet/hooks", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"event\" : \"NEW_BLOCK\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\"\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks"
payload := strings.NewReader("{\n\t\"event\" : \"NEW_BLOCK\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "Bearer my-generated-toke")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"id": "d0bd12a4-fdda-4ee3-a3a2-0c4782497871",
"event": "NEW_BLOCK",
"webhookId": "12d45342-8ed9-4c4a-aab0-6f47218ab583",
"created": "2019-10-22 11:24:31 UTC",
"active": true
}
}
HTTP Request
POST /v1/bc/bch/${NETWORK}/hooks
Request Object
{
"event": "NEW_BLOCK",
"url":{CALLBACK_URL}
}
The sent message will be similar to the following:
{
"currency": "BTC",
"network": "mainnet",
"url": "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5",
"type": "NEW_BLOCK",
"blockHeight": 570008,
"blockHash": "00000000000000000029a327e7d6f2ba04d126019744e4b513ab0f7d4b00c361"
}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | - | Network name (e.g. testnet or mainnet) |
EVENT | - | Webhook Event |
CALLBACK_URL | - | Webhook callback url |
Create Confirmed Transaction Webhook
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"event" : "CONFIRMED_TX",
"url" : "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5",
"transaction": "850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04",
"confirmations": 3
}'
POST /v1/bc/btc/mainnet/hooks HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"event" : "CONFIRMED_TX",
"url" : "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5",
"transaction": "850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04",
"confirmations": 3
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"event\" : \"CONFIRMED_TX\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\",\n\t\"transaction\": \"850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04\",\n\t\"confirmations\": 3\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/hooks",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ event: 'CONFIRMED_TX',
url: 'http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5',
transaction: '850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04',
confirmations: 3 }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"event" : "CONFIRMED_TX",
"url" : "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5",
"transaction": "850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04",
"confirmations": 3
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"event\" : \"CONFIRMED_TX\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\",\n\t\"transaction\": \"850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04\",\n\t\"confirmations\": 3\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"event\" : \"CONFIRMED_TX\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\",\n\t\"transaction\": \"850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04\",\n\t\"confirmations\": 3\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "Bearer my-genrated-token"
}
conn.request("POST", "/v1/bc/btc/mainnet/hooks", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"event\" : \"CONFIRMED_TX\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\",\n\t\"transaction\": \"850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04\",\n\t\"confirmations\": 3\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks"
payload := strings.NewReader("{\n\t\"event\" : \"CONFIRMED_TX\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\",\n\t\"transaction\": \"850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04\",\n\t\"confirmations\": 3\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "Bearer my-generated-toke")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"uuid": "3027a4d9-1a3e-478a-ab35-08f48679b238",
"event": "CONFIRMED_TX",
"confirmations": 3,
"transaction": "850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04",
"webhookId": "12d45342-8ed9-4c4a-aab0-6f47218ab583",
"created": "2019-10-23 05:59:37 UTC",
"active": true
}
}
Using a partially filled out Event, you can create a Webhook using this resource.
HTTP Request
POST /v1/bc/btc/${NETWORK}/hooks
Request Object
{
"event": "CONFIRMED_TX",
"url":{CALLBACK_URL},
"transaction" : ${TRANSACTION}},
"confirmations" : ${CONFIRMATIONS}
}
The sent message will be similar to the following:
{
"blockHeight": 569847,
"blockHash": "000000000000000000039dc2f1ab48a072d5d3fdc8d8a9cf7b726e894133d904",
"currency": "BTC",
"network": "mainnet",
"url": "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5",
"type": "CONFIRMED_TX",
"txid": "850039bf081ad580aba73217752647e640929624e11e71d21011511e48a98e04",
"confirmations": 3
}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | - | Network name (e.g. testnet or mainnet) |
EVENT | - | Webhook Event |
CALLBACK_URL | - | Webhook callback url |
TRANSACTION | - | Transaction hash |
CONFIRMATIONS | - | receive Webhook after a specified number of confirmations |
Confirmations can be any number between 1 and 20. Set to 1 means that webhooks will be sent immediately after the block that includes transactions with the specified address is mined. However, since there is the possibility of blockchain block re-write, we suggest that users set the confirmations at least to 3.
Create Address Transaction Webhook
Sample Data
curl -X POST \
'https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"event" : "ADDRESS",
"url" : "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5",
"address": "15XyNC88pujwuuur8DCsXBCfEhJJMzHayU",
"confirmations" : 6
}'
POST /v1/bc/btc/mainnet/hooks HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"event" : "ADDRESS",
"url" : "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5",
"address": "15XyNC88pujwuuur8DCsXBCfEhJJMzHayU",
"confirmations" : 6
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"event\" : \"ADDRESS\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\",\n\t\"address\": \"15XyNC88pujwuuur8DCsXBCfEhJJMzHayU\",\n\t\"confirmations\" : 6\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/hooks",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ event: 'ADDRESS',
url: 'http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5',
address: '15XyNC88pujwuuur8DCsXBCfEhJJMzHayU',
confirmations: 6 }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"event" : "ADDRESS",
"url" : "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5",
"address": "15XyNC88pujwuuur8DCsXBCfEhJJMzHayU",
"confirmations" : 6
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{\n\t\"event\" : \"ADDRESS\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\",\n\t\"address\": \"15XyNC88pujwuuur8DCsXBCfEhJJMzHayU\",\n\t\"confirmations\" : 6\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n\t\"event\" : \"ADDRESS\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\",\n\t\"address\": \"15XyNC88pujwuuur8DCsXBCfEhJJMzHayU\",\n\t\"confirmations\" : 6\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/mainnet/hooks", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"event\" : \"ADDRESS\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\",\n\t\"address\": \"15XyNC88pujwuuur8DCsXBCfEhJJMzHayU\",\n\t\"confirmations\" : 6\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks"
payload := strings.NewReader("{\n\t\"event\" : \"ADDRESS\",\n\t\"url\" : \"http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5\",\n\t\"address\": \"15XyNC88pujwuuur8DCsXBCfEhJJMzHayU\",\n\t\"confirmations\" : 6\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"uuid": "3027a4d9-1a3e-478a-ab35-08f48679b238",
"event": "ADDRESS",
"confirmations" : 6,
"address": "15XyNC88pujwuuur8DCsXBCfEhJJMzHayU",
"webhookId": "12d45342-8ed9-4c4a-aab0-6f47218ab583",
"created": "2019-10-23 06:02:23 UTC",
"active": true
}
}
By creating Address Transaction Webhook, you will receive a notification after a new incoming or outgoing transaction happens and reaches the certain number of confirmations you mentioned in your request "CONFIRMATIONS", 1 confirmation means 1 mined block.
HTTP Request
POST /v1/bc/btc/${NETWORK}/hooks
Request Object
{
"event": "ADDRESS",
"url":{CALLBACK_URL},
"address" : ${ADDRESS},
"confirmations" : ${CONFIRMATIONS}
}
The sent message will be similar to the following:
{
"currency": "BTC",
"network": "mainnet",
"url": "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5",
"type": "ADDRESS",
"blockHeight": 570011,
"blockHash": "00000000000000000025d7fba236834647b864380aa08afaccd72bdb56af5554",
"confirmations": 1,
"address": "bc1qjl8uwezzlech723lpnyuza0h2cdkvxvh54v3dn",
"txid": "ac2e1a495977d773a304d251e55579c862592819167b41e5bfb1a8360c23dd6a"
}
If the address is included in a transaction in the unconfirmed queue waiting to be mined the following message will be sent:
{
"currency": "BTC",
"network": "mainnet",
"url": "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5",
"type": "ADDRESS",
"blockHeight": -1,
"unconfirmed": true,
"address": "bc1qjl8uwezzlech723lpnyuza0h2cdkvxvh54v3dn",
"txid": "dfe3ca89e8ce658a6d527ef81d1ad1f4601dc6dc8a1856d9598cfc6d1c7e5f86"
}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | - | Network name (e.g. testnet or mainnet) |
EVENT | - | Webhook Event |
CALLBACK_URL | - | Webhook callback url |
ADDRESS | - | btc address |
CONFIRMATIONS | - | receive Webhook after a specified number of confirmations |
Confirmations can be any number between 1 and 20. Set to 1 means that webhooks will be sent immediately after the block that includes transactions with the specified address is mined. However, since there is the possibility of blockchain block re-write, we suggest that users set the confirmations at least to 3.
Create Transaction Confirmations Webhook
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"event" : "TRANSACTION_CONFIRMATIONS",
"url" : "https://blockchain.requestcatcher.com",
"confirmations": 3,
"address" : "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1"
}'
POST /v1/bc/btc/mainnet/hooks HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"event" : "TRANSACTION_CONFIRMATIONS",
"url" : "https://blockchain.requestcatcher.com",
"confirmations": 3,
"address" : "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1"
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{ \n \"event\" : \"TRANSACTION_CONFIRMATIONS\",\n \"url\" : \"https://blockchain.requestcatcher.com\",\n \"confirmations\": 3,\n \"address\" : \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\"\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/hooks",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ event: 'TRANSACTION_CONFIRMATIONS',
url: 'https://blockchain.requestcatcher.com',
confirmations: 3,
address: 'mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1' }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"event" : "TRANSACTION_CONFIRMATIONS",
"url" : "https://blockchain.requestcatcher.com",
"confirmations": 3,
"address" : "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
request.body = "{ \n \"event\" : \"TRANSACTION_CONFIRMATIONS\",\n \"url\" : \"https://blockchain.requestcatcher.com\",\n \"confirmations\": 3,\n \"address\" : \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\"\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{ \n \"event\" : \"TRANSACTION_CONFIRMATIONS\",\n \"url\" : \"https://blockchain.requestcatcher.com\",\n \"confirmations\": 3,\n \"address\" : \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\"\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "Bearer my-genrated-token"
}
conn.request("POST", "/v1/bc/btc/mainnet/hooks", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \n \"event\" : \"TRANSACTION_CONFIRMATIONS\",\n \"url\" : \"https://blockchain.requestcatcher.com\",\n \"confirmations\": 3,\n \"address\" : \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\"\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks"
payload := strings.NewReader("{ \n \"event\" : \"TRANSACTION_CONFIRMATIONS\",\n \"url\" : \"https://blockchain.requestcatcher.com\",\n \"confirmations\": 3,\n \"address\" : \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "Bearer my-generated-toke")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": {
"uuid": "7dd6f2cb-6fe5-4533-b6a1-3c739eabaec7",
"event": "TRANSACTION_CONFIRMATIONS",
"confirmations": 3,
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"webhookId": "12d45342-8ed9-4c4a-aab0-6f47218ab583",
"created": "2019-10-23 06:12:06 UTC",
"active": true
}
}
By creating Confirmed Transaction Webhook, you will receive a notification after every confirmation (new block) for every new incoming/outgoing transaction.
HTTP Request
POST /v1/bc/btc/${NETWORK}/hooks
Request Object
{
"event": "TRANSACTION_CONFIRMATIONS",
"url":{CALLBACK_URL},
"address" : ${ADDRESS}},
"confirmations" : ${CONFIRMATIONS}
}
The sent message will be similar to the following:
{
"currentConfirmations": 3,
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"blockHeight": 1519616,
"currency": "BTC",
"type": "TRANSACTION_CONFIRMATIONS",
"txid": "ff9c7c4fce479312d9d4c9f76877b7134a8bbd9e585549244615fdc36855ee4f",
"maxConfirmations": 3,
"network": "testnet"
}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | - | Network name (e.g. testnet or mainnet) |
EVENT | - | Webhook Event |
CALLBACK_URL | - | Webhook callback url |
ADDRESS | - | Address from the blockchain |
CONFIRMATIONS | - | receive Webhook after a specified number of confirmations |
Confirmations can be any number between 1 and 20. Set to 1 means that webhooks will be sent immediately after the block that includes transactions with the specified address is mined. However, since there is the possibility of blockchain block re-write, we suggest that users set the confirmations at least to 3.
Get My Webhookss
Sample Data
curl -X GET \
https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/hooks HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks",
"method": "GET",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var http = require("http");
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/hooks",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
require 'uri'
require 'net/http'
url = URI("https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["X-API-Key"] = 'my-api-key'
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
headers = {
'Content-Type': "application/json' ,
'X-API-Key': 'my-api-key'
}
conn.request("GET", "/v1/bc/btc/mainnet/hooks", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks")
.get()
.addHeader("Content-Type", "application/json")
.addHeader("X-API-Key", "my-api-key")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.cryptoapis.io/v1/bc/btc/mainnet/hooks"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-Key", "my-api-key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response Body
{
"payload": [
{
"uuid":