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 generate single-use, low-value key pairs with corresponding addresses 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.
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.
Addresses & Transactions Data
Crypto APIs Addresses & Transactions Data API allows you to look up information about public addresses on the blockchain as well as to look up information about unconfirmed transactions, query transactions based on hash or block.
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"
],
"unconfirmedBalance": "0.00000000"
}
}
Info
The default Address Endpoint strikes a general information about addresses.
If you want to see the unconfirmed balance, set checkUnconfirmedbalance
to true
.
HTTP Request
GET /v1/bc/btc/${NETWORK}/address/${ADDRESS}?checkUnconfirmedBalance=true
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
ADDRESS | ------- | Address in blockchain |
checkUnconfirmedBalance | false | (boolean) returns unconfirmedBalance |
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.
Get Basic Transactions By Address
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/testnet/address/n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg/basic/transactions' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/address/n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg/basic/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/n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg/basic/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/n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg/basic/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/n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg/basic/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/n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg/basic/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/n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg/basic/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/n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg/basic/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/n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg/basic/transactions")
}
Response Body
{
"payload": [
{
"txid": "ace6f04e13d4c9482dec860eeccab59e5bf50bfd8bf966ab179131c0b218d5e8",
"amount": 0.00015802,
"fee": 0.00015198,
"unit": "btc",
"datetime": "2020-03-04 11:25:57 UTC",
"timestamp": 1583321157,
"confirmations": 502,
"sent": {
"mnetBQ8h3srGd3oNT4uczwcQpXjR6AE73E": 0.00021,
"n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg": 0.0001
},
"received": {
"mnetBQ8h3srGd3oNT4uczwcQpXjR6AE73E": 0.00015802
}
},
{
"txid": "ffa143f44b114be4db0091500ab189c5d50f29758970a54e7a1dc08c2b47ea50",
"amount": 0.11484588,
"fee": 0.00000168,
"unit": "btc",
"datetime": "2020-03-03 09:20:12 UTC",
"timestamp": 1583227212,
"confirmations": 728,
"sent": {
"2NCJCzQFPANPkRmYDidKcUao9c9fLp5HeXV": 0.11484756
},
"received": {
"n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg": 0.0001,
"2NDEprTde2Uci9zqNVNWc1eXkCe8NENi3gY": 0.11474588
}
}
],
"meta": {
"totalCount": 4,
"index": 0,
"limit": 50,
"results": 4
}
}
Info
The Address Basic Transactions Endpoint returns basic information available about a particular address, including an array of basic transactions.
HTTP Request
GET /v1/bc/btc/${NETWORK}address/${ADDRESS}/basic/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:
n1s4jV66dGSX6TDezLRWZgcEuH5Sy2Pujg
The returned object contains an array with basic transaction records associated with this address in descending order by blocktime.
Get Confirmed 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", //deprecated
"datetime": "2019-02-25 12:04:54 UTC",
"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 Confirmed 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.
Get Confirmed Transactions For Address By Range
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions-by-range/1551095270/1551096294' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/address/mtFYoSowT3i649wnBDYjCjewenh8AuofQb/transactions-by-range/1551095270/1551096294 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-by-range/1551095270/1551096294').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-by-range/1551095270/1551096294",
"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-by-range/1551095270/1551096294');
$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-by-range/1551095270/1551096294")
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-by-range/1551095270/1551096294'
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-by-range/1551095270/1551096294")
.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-by-range/1551095270/1551096294"")
}
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 Confirmed Transactions By Range 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-by-range/${FROM_TIMESTAMP}/${TO_TIMESTAMP}?index=0&limit=50/
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
ADDRESS | ------- | Address in blockchain |
FROM_TIMESTAMP | ------- | From timestamp of desired txs |
TO_TIMESTAMP | ------- | To timestamp of desired txs |
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.
FROM_TIMESTAMP
and TO_TIMESTAMP
must be provided to get transactions with date range.
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.
Get Unconfirmed Transactions By Address
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/testnet/address/XeBZBM6V6KKgPGcuqJThPbohU8DjY823Mm/unconfirmed-transactions' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/address/XeBZBM6V6KKgPGcuqJThPbohU8DjY823Mm/unconfirmed-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/XeBZBM6V6KKgPGcuqJThPbohU8DjY823Mm/unconfirmed-transactions').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/address/XeBZBM6V6KKgPGcuqJThPbohU8DjY823Mm/unconfirmed-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/XeBZBM6V6KKgPGcuqJThPbohU8DjY823Mm/unconfirmed-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/XeBZBM6V6KKgPGcuqJThPbohU8DjY823Mm/unconfirmed-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/XeBZBM6V6KKgPGcuqJThPbohU8DjY823Mm/unconfirmed-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/XeBZBM6V6KKgPGcuqJThPbohU8DjY823Mm/unconfirmed-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/XeBZBM6V6KKgPGcuqJThPbohU8DjY823Mm/unconfirmed-transactions")
}
Response Body
{
"payload": [
{
"txid": "882e1c1e072fa06d1010f778ca4fd5e422fb549d92a98d29079756dd37d89810",
"hash": "7bd2b91409fbf412a691e31364b255f7092e4a2ded27e7bdd1f65484048944c5",
"version": 2,
"size": 418,
"vsize": 256,
"locktime": 1664453,
"time": "2020-01-31 08:04:11 UTC",
"datetime": "2020-01-31 08:04:11 UTC",
"timestamp": 1580457851,
"txins": [
{
"txout": "77ee9aabd52e846e11540549e053207f72ad86012c04805bf6a8feb789fc6edd",
"vout": 1,
"amount": "0.01199502",
"addresses": [
"2N5WueKVbqmVY2csn3RduofvkFpQRJkE9JJ"
],
"script": {
"asm": "001461240d9cf12baa3319bd9a8e63afbb08d5a28712",
"hex": "16001461240d9cf12baa3319bd9a8e63afbb08d5a28712"
},
"votype": "scripthash"
},
{
"txout": "4c6ce106a3f9bda81c10447b46de1cc9fc312f58063f29405996a6c35ebdebfd",
"vout": 1,
"amount": "0.01099515",
"addresses": [
"2MzNdMDsDVaDYhvcVJetFarNJ5epA53nGrK"
],
"script": {
"asm": "001430f59295b7d699a1f15d81b6686817102ca295a0",
"hex": "16001430f59295b7d699a1f15d81b6686817102ca295a0"
},
"votype": "scripthash"
}
],
"txouts": [
{
"amount": "0.01298761",
"type": "scripthash",
"spent": false,
"addresses": [
"2NFAxXg23VHV9cuSNhAfLR8ebesDxeaY3wT"
],
"script": {
"asm": "OP_HASH160 f08432f43efd8b80b3cbcf8e976bdd8cc7c99943 OP_EQUAL",
"hex": "a914f08432f43efd8b80b3cbcf8e976bdd8cc7c9994387",
"reqsigs": 1
}
},
{
"amount": "0.01",
"type": "scripthash",
"spent": false,
"addresses": [
"2NBMEXNEWwemEeSpqh5hLddUgTVAcxdEVey"
],
"script": {
"asm": "OP_HASH160 c695350d70c80b59ab85be75bdf7e8c879a09b8f OP_EQUAL",
"hex": "a914c695350d70c80b59ab85be75bdf7e8c879a09b8f87",
"reqsigs": 1
}
}
]
},
...
{
"txid": "c1e41924798fb406cae10a0dfe8b609bea320387b02c80078026e2631e4c5409",
"hash": "185e5157ce97a8ebee2b9844c7d4ef73e06c1c697d9eac466002e599dd43077c",
"version": 2,
"size": 247,
"vsize": 166,
"locktime": 1664453,
"time": "2020-01-31 08:02:19 UTC",
"datetime": "2020-01-31 08:02:19 UTC",
"timestamp": 1580457739,
"txins": [
{
"txout": "7ca0653fa177e6f0aef383d997bb06f18e75a4a8e827fd913e66ee6e0484690c",
"vout": 0,
"amount": "71.82084979",
"addresses": [
"2NB3q5jrZkEFPCk8essUxNS3fkXTt9BVa7x"
],
"script": {
"asm": "0014fd1d415acd19fac72292de5750787a6ec834313e",
"hex": "160014fd1d415acd19fac72292de5750787a6ec834313e"
},
"votype": "scripthash"
}
],
"txouts": [
{
"amount": "0.00368989",
"type": "scripthash",
"spent": false,
"addresses": [
"2NBMEXNEWwemEeSpqh5hLddUgTVAcxdEVey"
],
"script": {
"asm": "OP_HASH160 c695350d70c80b59ab85be75bdf7e8c879a09b8f OP_EQUAL",
"hex": "a914c695350d70c80b59ab85be75bdf7e8c879a09b8f87",
"reqsigs": 1
}
},
{
"amount": "71.81632946",
"type": "scripthash",
"spent": false,
"addresses": [
"2NAnBM2u6jQjRdLKej9RQwmdfNL46xMd6KE"
],
"script": {
"asm": "OP_HASH160 c054d3d7286ca37346bdbcd3caa04f952e580f94 OP_EQUAL",
"hex": "a914c054d3d7286ca37346bdbcd3caa04f952e580f9487",
"reqsigs": 1
}
}
]
}
],
"meta": {
"totalCount": 4,
"index": 0,
"limit": 50,
"results": 4
}
}
Info
The Address Unconfirmed Transactions Endpoint returns all information available about a particular address, including an array of unconfirmed transactions.
HTTP Request
GET /v1/bc/btc/${NETWORK}/address/${ADDRESS}/unconfirmed-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:
XeBZBM6V6KKgPGcuqJThPbohU8DjY823Mm
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 Details
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 Details Endpoint strikes a general information about the given addresses in the array.
HTTP Request
POST /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.
Get Basic Transaction Details By Transaction ID (Txid)
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/testnet/txs/basic/txid/87f765dcf8af14d481587e03cbb3758deb6b73c6fff346f0be783e3cba8b402a' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/txs/basic/txid/87f765dcf8af14d481587e03cbb3758deb6b73c6fff346f0be783e3cba8b402a 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/txs/basic/txid/87f765dcf8af14d481587e03cbb3758deb6b73c6fff346f0be783e3cba8b402a').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/txs/basic/txid/87f765dcf8af14d481587e03cbb3758deb6b73c6fff346f0be783e3cba8b402a",
"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/txs/basic/txid/87f765dcf8af14d481587e03cbb3758deb6b73c6fff346f0be783e3cba8b402a');
$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/txs/basic/txid/87f765dcf8af14d481587e03cbb3758deb6b73c6fff346f0be783e3cba8b402a")
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/txs/basic/txid/87f765dcf8af14d481587e03cbb3758deb6b73c6fff346f0be783e3cba8b402a'
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/txs/basic/txid/87f765dcf8af14d481587e03cbb3758deb6b73c6fff346f0be783e3cba8b402a")
.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/txs/basic/txid/87f765dcf8af14d481587e03cbb3758deb6b73c6fff346f0be783e3cba8b402a")
}
Response Body
{
"payload": {
"amount": 0.00952623,
"fee": 0.00001648,
"unit": "btc",
"datetime": "2020-03-04 11:25:57 UTC",
"timestamp": 1583321157,
"confirmations": 288,
"sent": {
"2N2QvYKC9EShfRvo1YP9A7cZhRSNcQTxWfH": 0.00954271
},
"received": {
"2N7kT5pwbxUbUiY5Lvz9WowYrXkzeFNchQL": 0.0001365,
"2N2QvYKC9EShfRvo1YP9A7cZhRSNcQTxWfH": 0.00938973
}
}
}
Info
The Basic Transaction By Txid Endpoint returns basic information about a given transaction based on its id.
HTTP Request
GET /v1/bc/btc/${NETWORK}/txs/basic/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 transaction you’re interested in querying, for example:
87f765dcf8af14d481587e03cbb3758deb6b73c6fff346f0be783e3cba8b402a
The returned object contains information about the transaction in JSON format, including the total amount transacted, sent, received and more.
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 Unconfirmed Transaction Details By Transaction ID (Txid)
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/testnet/txs/unconfirmed/txid/3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/txs/unconfirmed/txid/3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9 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/txs/unconfirmed/txid/3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/txs/unconfirmed/txid/3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9",
"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/txs/unconfirmed/txid/3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9');
$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/txs/unconfirmed/txid/3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9")
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/txs/unconfirmed/txid/3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9'
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/txs/unconfirmed/txid/3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9")
.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/txs/unconfirmed/txid/3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9")
}
Response Body
{
"payload": {
"txid": "3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9",
"hash": "0a11c2ddd51842d74f7427235dfa24be3a78ce8aebcaa3750aab0c224213af30",
"version": 1,
"size": 234,
"vsize": 153,
"locktime": 1781965,
"time": "2020-07-30 17:49:58 UTC",
"datetime": "2020-07-30 17:49:58 UTC",
"timestamp": 1596131398,
"txins": [
{
"txout": "5bcdbb01606e2a999995e2350243efc32f75ccd9926980313c2be4fa38bb5c7e",
"vout": 0,
"amount": "0.07074795",
"addresses": [
"tb1qzd2rr5zfkgmqeumtyqru4xcjvx44vxp3ntcreq"
],
"script": {
"asm": "",
"hex": ""
},
"votype": "witness_v0_keyhash",
"witness": [
"304402205c9960c49804bd7be6bde28815e6a77103783e72dc020b7460e82914e2a2d9f602206c3aa02c5f4c569a4ed98d2b3a8183c3a9448ffefe17f37bc4c70e700a18f68301",
"0249613aa5aef8986a7c2df5ba58d336e17d082ac94c300b16f4bffcbf2a42c11a"
]
}
],
"txouts": [
{
"amount": "0.07074613",
"type": "witness_v0_keyhash",
"spent": false,
"addresses": [
"tb1qvruspq7e2hc46dd0rywczwfcmvd8dcgs5uqeak"
],
"script": {
"asm": "0 60f90083d955f15d35af191d813938db1a76e110",
"hex": "001460f90083d955f15d35af191d813938db1a76e110",
"reqsigs": 1
}
},
{
"amount": "0",
"type": "nulldata",
"spent": false,
"addresses": [],
"script": {
"asm": "OP_RETURN ed030eb22459262967857dcde26985ba1e4906f76f0c67d7f040b016863ce45d",
"hex": "6a20ed030eb22459262967857dcde26985ba1e4906f76f0c67d7f040b016863ce45d"
}
}
]
}
}
Info
The Unconfirmed Transaction By Txid Endpoint returns detailed information about a given transaction based on its id.
HTTP Request
GET /v1/bc/btc/${NETWORK}/txs/unconfirmed/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:
3614f0b48c28c299ac927df6f883131e3c8f5534471115944eaa529c7eb89fd9
The returned object contains information about the transaction in JSON format, 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 GET '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).
Get Raw Transaction Hex By Transaction ID (Txid)
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/testnet/txs/raw/txid/0092e56ef024f79c76cbd9a55efb6e28a7ff22c950f65521e3b380f889c28d64' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/txs/raw/txid/0092e56ef024f79c76cbd9a55efb6e28a7ff22c950f65521e3b380f889c28d64 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/txs/raw/txid/0092e56ef024f79c76cbd9a55efb6e28a7ff22c950f65521e3b380f889c28d64').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/txs/raw/txid/0092e56ef024f79c76cbd9a55efb6e28a7ff22c950f65521e3b380f889c28d64",
"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/txs/raw/txid/0092e56ef024f79c76cbd9a55efb6e28a7ff22c950f65521e3b380f889c28d64');
$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/txs/raw/txid/0092e56ef024f79c76cbd9a55efb6e28a7ff22c950f65521e3b380f889c28d64")
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/txs/raw/txid/0092e56ef024f79c76cbd9a55efb6e28a7ff22c950f65521e3b380f889c28d64'
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/txs/raw/txid/0092e56ef024f79c76cbd9a55efb6e28a7ff22c950f65521e3b380f889c28d64")
.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/txs/raw/txid/0092e56ef024f79c76cbd9a55efb6e28a7ff22c950f65521e3b380f889c28d64")
}
Response Body
{
"payload": {
"hex": "020000000001013be1fe34782f24a2acbacc6adce44e67c70faefba59f122b3c6324d534bd45330100000000fdffffff02f4010000000000002200209f2f1060a8d7ddf0019b4fae87d022ff257e74b9db40d592a29ca0b1d0e7d07aa8430500000000001600149cbc415d3060254333441c1535cad0a34490c81f02473044022069746a36e369cdda9f4dcd9791c061a1e37236334316ebd040729844a9645d55022071fb6aa70467bf7856175033d82bcc63721c122cfcdb8cdfcc41d333035940be012102a4643b893615487f60f20a8197a3f448691c73415357c4173e35ed3acc8cb6f80e6e1900"
}
}
Info
The Get Raw Transaction Endpoint returns raw transaction hex about a given transaction based on its id.
HTTP Request
GET /v1/bc/btc/${NETWORK}/txs/raw/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 transaction you’re interested in querying, for example:
0092e56ef024f79c76cbd9a55efb6e28a7ff22c950f65521e3b380f889c28d64
The returned object contains information about the transaction in JSON format, including its raw transaction hex.
Get Unspent Transaction Outputs By Address
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/testnet/address/mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo/unspent-transactions' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/address/mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo/unspent-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/mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo/unspent-transactions').then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/address/mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo/unspent-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/mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo/unspent-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/mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo/unspent-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/mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo/unspent-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/mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo/unspent-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/mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo/unspent-transactions")
}
Response Body
{
"payload": [
{
"txid": "abb8903848e1c7a0d7ada6444f451f280b87f3450e42cf379ed92adfa19e3c3d",
"vout": 0,
"amount": 0.002925
},
{
"txid": "0bd409be4916ea24642d749509611c45704742906fefb6d2a957486fac26adc0",
"vout": 0,
"amount": 0.00292773
},
{
"txid": "2f15bbeff68ecc5d33c5b42e04f5b5f2cc18ed945f7e4d32ad24406fc7591e00",
"vout": 0,
"amount": 0.001
},
{
"txid": "bf008b1c4317c526d46c5a89f6f13421fc1a962aa264d233a04a368139ca6d53",
"vout": 0,
"amount": 0.001
},
{
"txid": "6426a41ad7e48d78567da159ddbef8a9bf539dcbae93849dd4027a2b4c5b35cd",
"vout": 0,
"amount": 0.001
},
{
"txid": "a58e3d46349c8d37d863c8b471035af231d71c15d82467a1e927e0febaca01eb",
"vout": 1,
"amount": 0.001
},
{
"txid": "e473f3c69134c22679c45ddc3e1fcb637967e5108ae211272f0e0fc3654fcdef",
"vout": 0,
"amount": 0.001
},
{
"txid": "e6bbca493d97b8d48875106a179d471b07ba73f113fac34919ae14f76cbedc29",
"vout": 0,
"amount": 0.001
},
{
"txid": "56df2dd6d8b99d3b39cc2c69917cd976338eb888e945186d04f326fba824313c",
"vout": 1,
"amount": 0.001
},
{
"txid": "a07afba79cc29ca9ace37c43ce5c1e90b202f9b89c64634ab290f1fe483bc83f",
"vout": 1,
"amount": 1.0E-5
},
{
"txid": "4364a9a8c56359429e4bf2f1728a98ec00cc4cfaf40ea413d3010531095fa44d",
"vout": 1,
"amount": 0.001
},
{
"txid": "d99ff14ba5502486e79c69604e8236248aefca7dadd2793b4fed38e51afcb24d",
"vout": 1,
"amount": 1.0E-5
},
{
"txid": "6b24d30c0c5473a90a03f54c2e150e2128bf37d2d521d25778646c8e3fa01899",
"vout": 0,
"amount": 1.0E-4
},
{
"txid": "0318e31acb94eae54084d8a61dd13eeedfa3b78961958380c5200204a82809b9",
"vout": 1,
"amount": 0.001
},
{
"txid": "dde36b56b2f5d19b1c60754dba9a5aaece648f8665372a56ae6153841623fee4",
"vout": 0,
"amount": 1.0E-4
},
{
"txid": "4a86b7ecb5aca288eca4ce92891044d3f6854244a7044a5ebdf7c810db9186f6",
"vout": 0,
"amount": 0.001
}
],
"meta": {
"totalCount": 16,
"results": 16
}
}
Info
The Unspent Transaction Outputs Endpoint returns the needed information of the previous unspent transaction outputs (also known as UTXOs) to build new transaction.
HTTP Request
GET /v1/bc/btc/${NETWORK}/address/${ADDRESS}/unspent-transactions
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
ADDRESS | ------- | Address in blockchain |
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 you’re interested in querying, for example:
mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo
The returned object contains the needed information about the unspent transaction outputs of an address to build a transaction.
HD 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 Hierarchical Deterministic (HD) Wallets
HD 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
Create HD Wallet
Sample Data
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"
}'
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"
}
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);
});
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
$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;
}
?>
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
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"))
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();
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
{
"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
POST /v1/bc/btc/${NETWORK}/wallets/hd
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
HD_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 HD Wallet Object
{
"walletName" : ${HD_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 HD wallets, you must include HD_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 HD Wallets
Sample Data
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'
GET /v1/bc/btc/testnet/wallets/hd 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/wallets/hd",
"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/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
$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;
}
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
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"))
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();
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
{
"payload": [
"newhdwallet",
"specialhdwallet"
],
"meta": {
"totalCount": 2,
"results": 2
}
}
HTTP Request
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 HD Wallets names under the token you queried. You can then query detailed information on individual wallets (via their names) by leveraging the Get HD Wallet Endpoint.
Get HD Wallet Details
Sample Data
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'
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
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);
});
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
$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;
}
?>
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
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"))
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();
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
{
"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
GET /v1/bc/btc/${NETWORK}/wallets/hd/${HD_WALLET_NAME}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
HD_WALLET_NAME | ------- | Wallet name |
This endpoint returns a Wallet or HDWallet based on its HD_WALLET_NAME.
Get HD Wallet Transactions
Sample Data
curl -X GET \
https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/stuno_wallet/transactions \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/testnet/wallets/hd/stuno_wallet/transactions 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/wallets/hd/stuno_wallet/transactions",
"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/wallets/hd/stuno_wallet/transactions",
"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/wallets/hd/stuno_wallet/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/wallets/hd/stuno_wallet/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 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/stuno_wallet/transactions", 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/wallets/hd/stuno_wallet/transactions")
.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/wallets/hd/stuno_wallet/transactions"
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": [
{
"txid": "e2461f7f4738d06a16dffd761af461cf6738004964a37591dc4743bf89f6f42b",
"hash": "e2461f7f4738d06a16dffd761af461cf6738004964a37591dc4743bf89f6f42b",
"index": 3,
"version": 2,
"size": 372,
"vsize": 372,
"locktime": 0,
"datetime": "2020-06-11 12:49:40 UTC",
"time": "2020-06-11 12:49:40 UTC",
"blockhash": "0000000000000f6ddf81a8e45af77eab6f126b42dbea4e26fb75e902720a81e1",
"blockheight": 1769009,
"blocktime": "2020-06-11 12:49:40 UTC",
"timestamp": 1591879780,
"txins": [
{
"txout": "179887c98a392801ecb28843ca80fc25284065188d5250287fb41c0b33aec168",
"vout": 1,
"amount": "0.00002",
"addresses": [
"mwJVTgWP5Rpw8bFt38SUrAoBxiyBvqkkyc"
],
"script": {
"asm": "304402200434368834e4b690c0defd958142279476739f4996fce49de9bd6029db975b6f0220631d878b2f247389f58d06c820b6cc51244d85aa186d28a2bc20f3f51f81621e[ALL] 0306da7c01b31093131f650a7281888e8d714ba26e68026b44c97fa4e059c8d816",
"hex": "47304402200434368834e4b690c0defd958142279476739f4996fce49de9bd6029db975b6f0220631d878b2f247389f58d06c820b6cc51244d85aa186d28a2bc20f3f51f81621e01210306da7c01b31093131f650a7281888e8d714ba26e68026b44c97fa4e059c8d816"
},
"votype": "pubkeyhash"
},
{
"txout": "91602c62b10ebd182b25209c00d7163ffc6bd3a80e70b01c20455fa0601ede28",
"vout": 1,
"amount": "0.00009999",
"addresses": [
"mwJVTgWP5Rpw8bFt38SUrAoBxiyBvqkkyc"
],
"script": {
"asm": "30440220383473aa6aa2b36a60768d58b53b36068ad55cc7ac96e3f07d9b43b8cbc8b1ee02205d388ba12e9f02a913f2aebfc10edcef0662c59a7cb83a26ae5b88986eeca8c5[ALL] 0306da7c01b31093131f650a7281888e8d714ba26e68026b44c97fa4e059c8d816",
"hex": "4730440220383473aa6aa2b36a60768d58b53b36068ad55cc7ac96e3f07d9b43b8cbc8b1ee02205d388ba12e9f02a913f2aebfc10edcef0662c59a7cb83a26ae5b88986eeca8c501210306da7c01b31093131f650a7281888e8d714ba26e68026b44c97fa4e059c8d816"
},
"votype": "pubkeyhash"
}
],
"txouts": [
{
"amount": "0.00009",
"type": "pubkeyhash",
"spent": true,
"addresses": [
"mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo"
],
"script": {
"asm": "OP_DUP OP_HASH160 1c83401f626bd655e980f8a98a01b035349e9c98 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a9141c83401f626bd655e980f8a98a01b035349e9c9888ac",
"reqsigs": 1
}
},
{
"amount": "0.00002",
"type": "pubkeyhash",
"spent": true,
"addresses": [
"mwJVTgWP5Rpw8bFt38SUrAoBxiyBvqkkyc"
],
"script": {
"asm": "OP_DUP OP_HASH160 ad269f009b455e157d40bdea038d15b3322e2d5f OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914ad269f009b455e157d40bdea038d15b3322e2d5f88ac",
"reqsigs": 1
}
}
]
},
...
{
"txid": "e0a7100c5f1d9dc20b7cc3290afcb5a03184caab45da790cfaafb91ea3af523d",
"hash": "e0a7100c5f1d9dc20b7cc3290afcb5a03184caab45da790cfaafb91ea3af523d",
"index": 1,
"version": 2,
"size": 225,
"vsize": 225,
"locktime": 0,
"datetime": "2020-06-11 11:11:33 UTC",
"time": "2020-06-11 11:11:33 UTC",
"blockhash": "0000000000000f41e33383dd7c59ec90f29851adaf60782c333b8c6da4697973",
"blockheight": 1768938,
"blocktime": "2020-06-11 11:11:33 UTC",
"timestamp": 1591873893,
"txins": [
{
"txout": "50d9a028983e981a16825a6d72ad3c4cb91759339f06cc7136b9478e22e99397",
"vout": 0,
"amount": "0.00019762",
"addresses": [
"mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo"
],
"script": {
"asm": "304402205aecd8a7ac2829e91866c786eb2d44846b155fa53d9ae6c91727d5ea4c7906a4022001886995f1c61e4cb18aeebda0c5448bff6ade7fca174c96db25d6310380fe2d[ALL] 0379b68be3079ad43e4bbe27a35b78a435f482045b39bd3771b6e307dd8b63e50a",
"hex": "47304402205aecd8a7ac2829e91866c786eb2d44846b155fa53d9ae6c91727d5ea4c7906a4022001886995f1c61e4cb18aeebda0c5448bff6ade7fca174c96db25d6310380fe2d01210379b68be3079ad43e4bbe27a35b78a435f482045b39bd3771b6e307dd8b63e50a"
},
"votype": "pubkeyhash"
}
],
"txouts": [
{
"amount": "0.00018524",
"type": "pubkeyhash",
"spent": true,
"addresses": [
"mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo"
],
"script": {
"asm": "OP_DUP OP_HASH160 1c83401f626bd655e980f8a98a01b035349e9c98 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a9141c83401f626bd655e980f8a98a01b035349e9c9888ac",
"reqsigs": 1
}
},
{
"amount": "0.00001",
"type": "pubkeyhash",
"spent": true,
"addresses": [
"mwJVTgWP5Rpw8bFt38SUrAoBxiyBvqkkyc"
],
"script": {
"asm": "OP_DUP OP_HASH160 ad269f009b455e157d40bdea038d15b3322e2d5f OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914ad269f009b455e157d40bdea038d15b3322e2d5f88ac",
"reqsigs": 1
}
}
]
}
],
"meta": {
"totalCount": 302,
"index": 10,
"limit": 20,
"results": 20
}
}
HTTP Request
GET /v1/bc/btc/${NETWORK}/wallets/hd/${HD_WALLET_NAME}/transactions
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
HD_WALLET_NAME | ------- | Wallet name |
This endpoint returns array of the Transactions associated with the HDWallet based on its HD_WALLET_NAME.
Generate Address in HD Wallet
Sample Data
#### 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"
}'
#### 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"
}
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);
});
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
$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;
}
?>
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
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"))
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();
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
{
"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
POST /v1/bc/btc/${NETWORK}/wallets/hd/${HD_WALLET_NAME}/addresses/generate
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
HD_WALLET_NAME | ------- | HD Wallet name |
Request HD Wallet Object
{
"addressCount" : ${ADDRESS_COUNT},
"password" : ${ENCRYPTED_PASSWORD}
}
This endpoint allows you to generate a new address associated with the HD_WALLET_NAME wallet, similar to the Generate Address Endpoint. If successful, it will return the newly created addresses.
Delete 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'
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
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);
});
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
$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;
}
?>
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
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"))
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();
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 demohdwallet was successfully deleted!"
}
}
HTTP Request
DELETE /v1/bc/btc/${NETWORK}/wallets/hd/${HD_WALLET_NAME}
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
HD_WALLET_NAME | ------- | Wallet name |
This endpoint deletes HD Wallet with HD_WALLET_NAME.
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
HD_WALLET_NAME | ------- | Wallet name |
Import Address as an HD 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);
});
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": ${HD_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 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).
Prepare a Transaction
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.0008
}],
"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.0008
}],
"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.0008\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.0008 } ],
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.0008
}],
"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.0008\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.0008\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.0008\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.0008\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. testnet 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 a Transaction
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 a Transaction 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 Broadcast a Signed Transaction Endpoint in order to broadcast the transaction into the Bitcoin blockchain.
Broadcast a Signed Transaction
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.
Prepare, Sign and Broadcast a 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 Prepare, Sign and Broadcast a 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) |
Prepare, Sign and Broadcast a 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"
}
}
Prepare, Sign and Broadcast a 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. testnet 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
}
Prepare, Sign and Broadcast a Transaction Using Non-Custodial-Wallet
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/testnet/txs/non-custodial-wallet \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"walletId": "5f106c02de262d00011d2a59",
"password": "mypassword",
"outputs": [
{
"address": "mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo",
"value": 0.004
}
],
"fee": {
"value": 0.00000225
}
}'
POST /v1/bc/btc/testnet/txs/non-custodial-wallet HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"walletId": "5f106c02de262d00011d2a59",
"password" : "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32",
"outputs": [{
"address": "mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo",
"value": 0.004
}],
"fee": {
"value": 0.00000225
},
"locktime": 0
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/txs/non-custodial-wallet",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"walletId\": \"5f106c02de262d00011d2a59\",\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\t\"outputs\": [{\n\t\t\"address\": \"mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo\",\n\t\t\"value\": 0.004\n\t}],\n\t\n\t\"fee\": {\n\t\t\"value\": 0.00000225\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/testnet/txs/non-custodial-wallet",
"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({ walletId: '5f106c02de262d00011d2a59',
password: '8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32',
outputs: [ { address: 'mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo', value: 0.004 } ],
fee: { value: 0.00000225 },
locktime: 0 }));
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/txs/non-custodial-wallet');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"walletId": "5f106c02de262d00011d2a59",
"password" : "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32",
"outputs": [{
"address": "mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo",
"value": 0.004
}],
"fee": {
"value": 0.00000225
},
"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/testnet/txs/non-custodial-wallet")
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\"walletId\": \"5f106c02de262d00011d2a59\",\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\t\"outputs\": [{\n\t\t\"address\": \"mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo\",\n\t\t\"value\": 0.004\n\t}],\n\t\n\t\"fee\": {\n\t\t\"value\": 0.00000225\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\"walletId\": \"5f106c02de262d00011d2a59\",\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\t\"outputs\": [{\n\t\t\"address\": \"mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo\",\n\t\t\"value\": 0.004\n\t}],\n\t\n\t\"fee\": {\n\t\t\"value\": 0.00000225\n\t},\n\t\"locktime\": 0\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/testnet/txs/non-custodial-wallet", 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\"walletId\": \"5f106c02de262d00011d2a59\",\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\t\"outputs\": [{\n\t\t\"address\": \"mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo\",\n\t\t\"value\": 0.004\n\t}],\n\t\n\t\"fee\": {\n\t\t\"value\": 0.00000225\n\t},\n\t\"locktime\": 0\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/txs/non-custodial-wallet")
.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/non-custodial-wallet"
payload := strings.NewReader("{\n\t\"walletId\": \"5f106c02de262d00011d2a59\",\n\t\"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\t\"outputs\": [{\n\t\t\"address\": \"mi7iSsKcvyFYNsiYdDZqJmH75RmoHomwmo\",\n\t\t\"value\": 0.004\n\t}],\n\t\n\t\"fee\": {\n\t\t\"value\": 0.00000225\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": "c52c8b4fcbb04fe01b9dc351d020c8a6037b57435da4e4da20cf286fa1f30964",
"view_in_explorer": "https://blockexplorer.one/btc/testnet/tx/c52c8b4fcbb04fe01b9dc351d020c8a6037b57435da4e4da20cf286fa1f30964?utm_source=cryptoapis.io"
}
}
Prepare, Sign and Broadcast a Transaction Using Non-Custodial Wallet Endpoint provides the possibility to create, sign and send new transactions using your Non-Custodial Wallet. The mandatory fields are: walletId, password, outputs and fee (see example).
HTTP Request
POST /v1/bc/btc/${NETWORK}/txs/non-custodial-wallet
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
See the example where the complete JSON object request is shown.
The complete JSON object request:
{
"walletId": "string",
"password": "string",
"outputs": [
{
"address": "string",
"value": "double"
}
],
"fee": {
"value": "double"
}
}
Decode a Raw Transaction
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. testnet 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.
Refund a 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 a 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) |
Transactions Fees
Every transaction on Blockchain has fee, the fee is not a fixed amount or % of the amount. The fee depends mainly on how much the network is overloaded. The higher fee you pay, the faster your transaction will be mined. You can use our different endpoints to get information all the time about fees and decide what fee you would set for your transactions.
Transaction Size
Info
Using Crypto APIs, you can calculate the approximate size of a standard transaction.
Required fields are:
{
"inputs": [{
"address": "...",
"value": ...
},
...],
"outputs": [{
"address": "...",
"value": ...
},
...],
"fee": {
"address": "...",
"value": ...
}
}
Optional fields include:
{
"locktime": ...,
"data": "...",
"replaceable": false/true
}
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/testnet/txs/size \
-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.0008
}],
"fee": {
"address" : "mtFYoSowT3i649wnBDYjCjewenh8AuofQb",
"value": 0.00023141
},
"data": "CRYPTOAPISROCKS",
"replaceable": true
}'
POST /v1/bc/btc/testnet/txs/size 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.0008
}],
"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/size",
"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.0008\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/size",
"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.0008 } ],
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/size');
$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.0008
}],
"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/size")
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.0008\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.0008\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/size, 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.0008\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/size")
.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/size"
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.0008\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": {
"tx_size_bytes": 220
}
}
HTTP Request
POST /v1/bc/btc/${NETWORK}/txs/size
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
Transaction Size for HD Wallet
Info
Using this endpoint you can get the approximate size of a transaction in HD wallet.
Required fields are:
{
"walletName": "......",
"password" : "......",
"outputs": [{
"address": "......",
"value": ........
}]
}
Optional fields include:
{
"locktime": ...,
"data": "...",
"fee": {
"address" : ............,
"value": ..............
}
}
Sample Data
curl -X POST \
https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/txs/size \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key' \
-d '{
"walletName": "demohdwallet",
"password": "8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32",
"outputs": [
{
"address": "mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1",
"value": 0.007
}
]
}'
POST /v1/bc/btc/testnet/wallets/hd/txs/size 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.007
}]
}
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/txs/size",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n \"walletName\": \"demohdwallet\",\n \"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\"outputs\": [{\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.007\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/testnet/wallets/hd/txs/size",
"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("{\n \"walletName\": \"demohdwallet\",\n \"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\"outputs\": [{\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.007\n }],\n}");
req.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/txs/size');
$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.007
}]}');
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/txs/size")
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 \"walletName\": \"demohdwallet\",\n \"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\"outputs\": [{\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.007\n }],\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPConnection("https://api.cryptoapis.io")
payload = "{\n \"walletName\": \"demohdwallet\",\n \"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\"outputs\": [{\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.007\n }],\n}"
headers = {
'Content-Type': "application/json",
'X-API-Key': "my-api-key"
}
conn.request("POST", "/v1/bc/btc/testnet/wallets/hd/txs/size, 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\": \"demohdwallet\",\n \"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\"outputs\": [{\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.007\n }],\n}"");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/txs/size")
.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/wallets/hd/txs/size"
payload := strings.NewReader("{\n \"walletName\": \"demohdwallet\",\n \"password\" : \"8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\",\n\"outputs\": [{\n \"address\": \"mn6GtNFRPwXtW7xJqH8Afck7FbVoRi6NF1\",\n \"value\": 0.007\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": {
"tx_size_bytes": 238
}
}
HTTP Request
POST /v1/bc/btc/${NETWORK}/wallets/hd/txs/size
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
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.00000113",
"max": "0.05992189",
"average": "0.00014718",
"min_fee_per_byte": "0.00000001",
"average_fee_per_byte": "0.00000027",
"max_fee_per_byte": "0.00011151",
"average_bytes": "545", //deprecated
"recommended": "0.00012508", //deprecated
"slow_fee_per_byte": "0.00000078",
"standard_fee_per_byte": "0.00000157",
"fast_fee_per_byte": "0.00000264",
"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.
min_fee_per_byte
, average_fee_per_byte
and max_fee_per_byte
represent the lowest, average and highest values per byte.
slow_fee_per_byte
, standard_fee_per_byte
and fast_fee_per_byte
represent the slowest, standard and fastest values per byte for a transaction fee.
Crypto APIs provides an endpoint where you can get the size of your transaction in bytes. Using the provided data you can easily calculate and set your fee.
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) |
Estimate Smart Fee
Sample Data
curl -X GET 'https://api.cryptoapis.io/v1/bc/btc/mainnet/txs/estimate-fee' \
-H 'ContentType: application/json' \
-H 'X-API-Key: my-api-key'
GET /v1/bc/btc/mainnet/txs/estimate-fee 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/estimate-fee').then(function(d) {console.log(d)});mainnet/txsbtc
const https = require('https');
var options = {
"method": "GET",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/mainnet/txs/estimate-fee",
"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/estimate-fee');
$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/estimate-fee")
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/estimate-fee'
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/estimate-fee")
.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/estimate-fee")
}
Response Body
{
"payload": {
"feeRate": "0.00012290",
"blocks": "2",
"unit" : "btc"
}
}
Info
Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within confTarget
blocks if possible and return the number of blocks for which the estimate is valid.
HTTP Request
GET /v1/bc/btc/${NETWORK}/txs/estimate-fee
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. testnet or mainnet) |
estimateMode | CONSERVATIVE | The fee estimate mode. (“UNSET” “ECONOMICAL” “CONSERVATIVE”) |
confTarget | 1 | Confirmation target in blocks (1 - 1008) |
The returned object contains information about the estimated fee rate in BTC/kB and the block number where estimated fee value was found.
xPub, yPub, zPub
What is Xpub?
Every child key pair can define an xPub (Extended Public Key). As the name suggests, an Xpub doesn’t contain information about private keys, but only public ones. This means that an xPub will not give you access to the funds in a wallet, but the user can also view the child wallet’s addresses, transactions, and balances. You can think of it as a read-only view of a wallet.
What are Ypub and Zpub?
After the adoption of SegWit, theBIP49 standard gave origin to the yPub. A yPub key is the same as an xPub key. However, it follows the new standard and has an address type P2SH-P2WPKH. yPub is for backward-compatible SegWit Wallets.
After the xPub and yPub, the newest Public Extended Key is zPub. Just as its predecessor the zPub follows the BIP49 standard, but the address type is P2WPKH. zPub is for native compatible SegWit wallets.
Create Public Extended Key (xPub, yPub, zPub)
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 Public Extended Key (xPub, yPub, zPub) 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 Public Extended Key Addresses (xPub, yPub, zPub)
Sample Data
curl -X POST 'https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses?limit=3' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
-d '{
"xpub":"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk"
}'
POST /v1/bc/btc/mainnet/wallets/hd/xpub/addresses?limit=3 HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"xpub":"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk"
}
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\"\n}"
});
$.post('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses?limit=3')
.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?limit=3",
"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'
}));
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses?limit=3');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"xpub":"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk"
}');
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?limit=3")
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}"
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses?limit=3'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
payload = "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\"\n}"
response = requests.post(url, payload, headers)
OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create(mediaType, "{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\"\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/mainnet/wallets/hd/xpub/addresses?limit=3")
.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?limit=3"
payload := strings.NewReader("{\n\t\"xpub\":\"xpub68MP6APrnq8Pp5wpL77MWevxkTE62PLnhM9u71xxHxJMrnKvLKaXWfoGNhyUEr7LmwPf4k872fbL2yeimSae3JBQUnD5uaMnuzuEsjkz6Zk\"\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,
"index": 0,
"limit": 3,
"results": 3
}
}
Info
Get Pub Addresses Endpoint allows you to get addresses associated with the specified extended public key. Supported BIP formats are: bip39, bip44, bip49 and bip84.
Since addresses are hierarchically ordered we provide the query params index
and limit
, in order to be able to get the addresses in specific positions. Default values are: 0 and 100, accordingly. The default values will return the first one hundred receive addresses.
If you want to get the change addresses of the extended public key you should set type
to be equal to "change" as a query parameter.
If you want to get addresses in P2PKH
(P2PKH which begin with the number 1, eg: 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2)
address format type you should set address_type
to be equal to P2PKH
.
If you want to get addresses in P2SH
(P2SH which begin with the number 3, eg: 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy)
address format type you should set address_type
to be equal to P2SH
.
If you want to get addresses in Bech32
(Bech32 which begin with bc1, eg: bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq)
address format type you should set address_type
to be equal to Bech32
.
HTTP Request
POST /v1/bc/btc/${NETWORK}/wallets/hd/xpub/addresses
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
index | 0 | starting point (integer) |
limit | 100 | result count (integer) |
type | receive | address type (string) |
address_type | P2PKH | address format type (string) (Allowed types are: P2PKH , P2SH , Bech32 ) |
Get Public Extended Key Transactions (xPub, yPub, zPub)
Sample Data
curl -X POST 'https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/xpub/addresses/transactions' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
-d '{
"xpub":"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w"
}'
POST /v1/bc/btc/testnet/wallets/hd/xpub/addresses/transactions HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"xpub":"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w"
}
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"xpub\":\"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w\"\n}"
});
$.post('https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/xpub/addresses/transactions')
.then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/wallets/hd/xpub/addresses/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);
});
});
req.write(JSON.stringify({ xpub: 'tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w' }));
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/xpub/addresses/transactions');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"xpub":"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w"
}');
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/xpub/addresses/transactions")
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\":\"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w\"\n}"
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/xpub/addresses/transactions'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
payload = "{\n\t\"xpub\":\"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w\"\n}"
response = requests.post(url, payload, headers)
OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create(mediaType, "{\n\t\"xpub\":\"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w\"\n}");
Request request = new Request.Builder()
.url("https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/xpub/addresses/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").
url := "https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/xpub/addresses/transactions"
payload := strings.NewReader("{\n\t\"xpub\":\"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w\"\n}")
req, _ := http.NewRequest("POST", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
}
Response Body
{
"payload": [
{
"address": "muRDqTkswqGrZ55HMYqtdm96RQRkfGVcDM",
"transactions": [
{
"txid": "f7679a1b272c0fda6338294b4b7e24364090ee86e15f38599d757313555c0d7f",
"hash": "b7f0215a98475c5cc62f7cd093fb5d0e3e9d1710630e088cc9d30cf84b7b1480",
"index": 301,
"version": 2,
"size": 420,
"vsize": 258,
"locktime": 1610277,
"datetime": "2019-11-29 12:37:59 UTC",
"time": "2019-11-29 12:37:59 UTC",
"blockhash": "00000000c59d5a76d8566860f50f996a8109cda5b3e28f39a2befb486d91b7ae",
"blockheight": 1610278,
"blocktime": "2019-11-29 12:37:59 UTC",
"timestamp": 1575031079,
"txins": [
{
"txout": "faecc547363bba171dc665c1752e027d0ef5e1078eb21fecbfa69a114642f12c",
"vout": 1,
"amount": "0.01197137",
"addresses": [
"2N61UpBStVekzUiQi2MeJX13rWxvANZxB1n"
],
"script": {
"asm": "0014d9dd40344f1ca7ce0e0ca507efb238d987909931",
"hex": "160014d9dd40344f1ca7ce0e0ca507efb238d987909931"
},
"votype": "scripthash"
},
{
"txout": "2d6d4cd15fcf215b77f214a9651a1883bc69de861574e45955287c747f44dfb8",
"vout": 1,
"amount": "0.01298794",
"addresses": [
"2NAV3t8PWbKR4q73umkrGDTBsVBCzJW8NKw"
],
"script": {
"asm": "001439ce1d2265364559d3ce51fcca6bf3e32f1e7c2a",
"hex": "16001439ce1d2265364559d3ce51fcca6bf3e32f1e7c2a"
},
"votype": "scripthash"
}
],
"txouts": [
{
"amount": "0.01495673",
"type": "scripthash",
"spent": true,
"addresses": [
"2N5zAb2cGcFYiH6YfbYp1W1q8ZuPHwwahPv"
],
"script": {
"asm": "OP_HASH160 8bc08e89a3cfef2009c49de8431b0e4013d987a0 OP_EQUAL",
"hex": "a9148bc08e89a3cfef2009c49de8431b0e4013d987a087",
"reqsigs": 1
}
},
{
"amount": "0.01",
"type": "pubkeyhash",
"spent": false,
"addresses": [
"muRDqTkswqGrZ55HMYqtdm96RQRkfGVcDM"
],
"script": {
"asm": "OP_DUP OP_HASH160 987c3d157bcb14be27dc76dc583ca6e94e78cb9e OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914987c3d157bcb14be27dc76dc583ca6e94e78cb9e88ac",
"reqsigs": 1
}
}
]
}
]
},
...
{
"address": "migKHiN2651seZVTGwkkQMqXefVsjHJhGf",
"transactions": [
{
"txid": "84cf9f79cb957b0c0c64c7ce3ec1850063c1d889e11f5c771536e8d42abb94ad",
"hash": "63bdd807f64eb1b1793941ac002e73a8595b16388f2ad5ad4c59239e12c17d6a",
"index": 126,
"version": 2,
"size": 249,
"vsize": 168,
"locktime": 1610279,
"datetime": "2019-11-29 13:02:22 UTC",
"time": "2019-11-29 13:02:22 UTC",
"blockhash": "000000003e9b3aa4b4461e0b6444f5cd400b6625f682ceacde19e25d691f8ea8",
"blockheight": 1610280,
"blocktime": "2019-11-29 13:02:22 UTC",
"timestamp": 1575032542,
"txins": [
{
"txout": "3f72598d9c8d1869dbd8add6989fa5a5c068b4dc4ea61534a575bddf606df4f7",
"vout": 6,
"amount": "0.042",
"addresses": [
"2N62xSz56QSUbJeQNME6jpkPFQHditMAGcy"
],
"script": {
"asm": "001423494ac4d10970f3f62d00ddde9264b1f4c4636d",
"hex": "16001423494ac4d10970f3f62d00ddde9264b1f4c4636d"
},
"votype": "scripthash"
}
],
"txouts": [
{
"amount": "0.01",
"type": "pubkeyhash",
"spent": false,
"addresses": [
"migKHiN2651seZVTGwkkQMqXefVsjHJhGf"
],
"script": {
"asm": "OP_DUP OP_HASH160 22ada5623f07c707e51e58e16f62272e9c1ec357 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a91422ada5623f07c707e51e58e16f62272e9c1ec35788ac",
"reqsigs": 1
}
},
{
"amount": "0.03199832",
"type": "scripthash",
"spent": true,
"addresses": [
"2NG1Ec1f1phzjQiCs9z1524FzufMioFSHoz"
],
"script": {
"asm": "OP_HASH160 f9a59572491c55dc1c9de21ad877e0797681d9c7 OP_EQUAL",
"hex": "a914f9a59572491c55dc1c9de21ad877e0797681d9c787",
"reqsigs": 1
}
}
]
}
]
}
],
"meta": {
"totalCount": 3,
"index": 0,
"limit": 3,
"results": 3
}
}
Info
Get Pub Addresses Endpoint allows you to get transactions associated with the specified extended public key. Supported BIP formats are: bip39, bip44, bip49 and bip84.
Since addresses are hierarchically ordered we provide the query params index
and limit
, in order to be able to get the addresses and their transactions in specific positions. Default values are: 0 and 100, accordingly. The default values will return the transactions for the first one hundred receive addresses.
If you want to get the change addresses of the extended public key you should set type
to be equal to "change" as a query parameter.
If the transactions you are looking for are transactions from addresses in P2PKH
(P2PKH which begin with the number 1, eg: 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2)
address format type you should set address_type
to be equal to P2PKH
.
If the transactions you are looking for are transactions from addresses in P2SH
(P2SH which begin with the number 3, eg: 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy)
address format type you should set address_type
to be equal to P2SH
.
If the transactions you are looking for are transactions from addresses in Bech32
(Bech32 which begin with bc1, eg: bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq)
address format type you should set address_type
to be equal to Bech32
.
If the transactions you are looking for are transactions from addresses in ALL
(P2PKH
, P2SH
, Bech32
) formats type you should set address_type
to be equal to ALL
.
results
property in the response shows the number of addresses that have transactions for the specified query.
HTTP Request
POST /v1/bc/btc/${NETWORK}/wallets/hd/xpub/addresses/transactions
Query Parameters
Parameter | Default | Description |
---|---|---|
NETWORK | ------- | Network name (e.g. mainnet or testnet) |
index | 0 | starting point (integer) |
limit | 100 | result count (integer) |
type | receive | address type (string) |
address_type | P2PKH | address format type (string) (Allowed types are: P2PKH , P2SH , Bech32 , ALL ) |
Get Public Extended Key Details (xPub, yPub, zPub)
Sample Data
curl -X POST 'https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/xpub/details' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: my-api-key'
-d '{
"xpub":"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w"
}'
POST /v1/bc/btc/testnet/wallets/hd/xpub/details HTTP/1.1
Host: api.cryptoapis.io
Content-Type: application/json
X-API-Key: my-api-key
{
"xpub":"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w"
}
$.ajaxSetup({
headers:{
"Content-Type": "application/json" ,
"X-API-Key": "my-api-key"
},
"processData": false,
"data": "{\n\t\"xpub\":\"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w\"\n}"
});
$.post('https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/xpub/details')
.then(function(d) {console.log(d)});
const https = require('https');
var options = {
"method": "POST",
"hostname": "api.cryptoapis.io",
"path": "/v1/bc/btc/testnet/wallets/hd/xpub/details",
"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: 'tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w' }));
request.end();
<?php
$request = new HttpRequest();
$request->setUrl('https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/xpub/details');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-Key' => 'my-api-key'
));
$request->setBody('{
"xpub":"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w"
}');
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/xpub/details")
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\":\"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w\"\n}"
response = http.request(request)
puts response.read_body
import requests
url = 'https://api.cryptoapis.io/v1/bc/btc/testnet/wallets/hd/xpub/details'
headers = {
"Content-Type": "application/json",
"X-API-Key": "my-api-key"
}
payload = "{\n\t\"xpub\":\"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w\"\n}"
response = requests.post(url, payload, headers)
OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create(mediaType, "{\n\t\"xpub\":\"tpubD9GMECjiZHCaF9NHSMAeMbQMXnM7CviEJZsYBuztVwsUjPHWjxewWAUXWV2UExaAtoEvQGXDBmVWo6ZHGtj6TsH6Pop7D9DskQwGHA1gu1w\"\n}");
Request request = new Request.Builder()
.