Get derived Bitcoin addresses from an xpub
curl --request GET \
--url https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses \
--header 'X-Api-Key: <api-key>'import requests
url = "https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses"
headers = {"X-Api-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-Api-Key': '<api-key>'}};
fetch('https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-Api-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses")
.header("X-Api-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-Api-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"addresses": [
{
"address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"path": "m/44'/0'/0'/0/0",
"transfers": 3
}
],
"meta": {
"syncedAt": {
"bitcoin": "latest"
}
}
}Xpub Utility
Addresses From Xpub
Returns every derived address along with its transfer count for a given Bitcoin xpub key.
GET
/
v1
/
chains
/
{chainAlias}
/
wallets
/
{publicKey}
/
addresses
Get derived Bitcoin addresses from an xpub
curl --request GET \
--url https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses \
--header 'X-Api-Key: <api-key>'import requests
url = "https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses"
headers = {"X-Api-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-Api-Key': '<api-key>'}};
fetch('https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-Api-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses")
.header("X-Api-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moralis.com/v1/chains/{chainAlias}/wallets/{publicKey}/addresses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-Api-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"addresses": [
{
"address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"path": "m/44'/0'/0'/0/0",
"transfers": 3
}
],
"meta": {
"syncedAt": {
"bitcoin": "latest"
}
}
}Pass
bitcoin (or bitcoin-mainnet) as chainAlias and your Bitcoin extended public key as publicKey. The response lists every derived address along with its transfer count, so you can show only the addresses that have actually been used.Authorizations
Path Parameters
A Bitcoin extended public key (xpub).
Bitcoin chain alias. Pass bitcoin or bitcoin-mainnet.
Available options:
bitcoin, bitcoin-mainnet 
