NAV Navbar
json python javascript go php

Before start

Welcome to the official WestWallet API documentation.

Change docs language: RU EN

Authorize to get an API-key in the profile settings.

Libraries for programming languages: Python JavaScript Golang PHP

Authorization

import json
import hashlib
import hmac
import time
import requests

# Get transaction info
api_key = "your_public_key"
secret_key = "your_private_key"
data = {"id": 435}
timestamp = int(time.time())
if data:
    dumped = json.dumps(data, ensure_ascii=False)
else:
    dumped = ""
sign = hmac.new(secret_key.encode('utf-8'),
                "{}{}".format(timestamp, dumped)
                .encode('utf-8'), hashlib.sha256).hexdigest()
headers = {
    "Content-Type": "application/json",
    "X-API-KEY": api_key,
    "X-ACCESS-SIGN": sign,
    "X-ACCESS-TIMESTAMP": str(timestamp)
}
resp = requests.post("https://api.westwallet.io/wallet/transaction", 
                     data=json.dumps(data),
                     headers=headers)
print(resp.json())                     

WestWallet API expects to receive X-API-KEY, X-ACCESS-SIGN and X-ACCESS-TIMESTAMP in the header of each of your request.

X-API-KEY - your public key;

X-ACCESS-TIMESTAMP - timestamp (use unix timestamp);

X-ACCESS-SIGN - HMAC-sha256 request body signature (composed of lines, comprising the timestamp and JSON-representation of the request body data) signed by your private key. For GET requests it should be made with JSON-dump of query parameters.

See an example how to form a string for generating signature at Python examples

Wallet

Withdrawals

POST https://api.westwallet.io/wallet/create_withdrawal

{
  "id": 123123,
  "amount": 0.1,
  "address": "35NjwZg8T4F12ESdEo3rQeYQ8ZiTyDYoTJ",
  "dest_tag": "",
  "currency": "BTC",
  "status": "pending",
  "blockchain_hash": "72648cefcc47b4371f28dc3328bc863918913eebf81b40d4a97d577b96c1ce53",
  "fee": "0.0001",
  "error": "ok"
}
# Send 0.1 ETH to 0x57689002367b407f031f1BB5Ef2923F103015A32
from westwallet_api import WestWalletAPI
from westwallet_api.exceptions import InsufficientFundsException, BadAddressException

client = WestWalletAPI("your_public_key", "your_private_key")
try:
    sent_transaction = client.create_withdrawal(
        "ETH", "0.1", "0x57689002367b407f031f1BB5Ef2923F103015A32"
    )
except InsufficientFundsException:
    # handle this case
    pass
except BadAddressException:
    # handle also this case
    pass
else:
    print(sent_transaction.__dict__)
const westwallet = require('westwallet-api');
const westwalletErrors = require('westwallet-api/lib/errors');

const publicKey = "yourPublicKey";
const privateKey = "yourPrivateKey";

let client = new westwallet.WestWalletAPI(
    publicKey, 
    privateKey
);

client.createWithdrawal("ETH", "0.1", "0x57689002367b407f031f1BB5Ef2923F103015A32")
.then((data) => {
    console.log(data);
}).catch((error) => {
    if (error instanceof westwalletErrors.InsufficientFundsError) {
        console.log("Insufficient funds");
    } else if (error instanceof westwalletErrors.BadAddressError) {
        console.log("Bad address regex");
    } else {
        console.log(error);
    }
});
package main

import (
    "fmt"
    westwallet "github.com/westwallet/westwallet-golang-api"
)

// Sending 0.1 ETH to 0x57689002367b407f031f1BB5Ef2923F103015A32
client := westwallet.APIClient{
    Key:      "your_public_key",
    Secret:   "your_private_key",
}

transaction, err := client.CreateWithdrawal(
    "ETH", "0.1", "0x57689002367b407f031f1BB5Ef2923F103015A32", "", ""
)

fmt.Println(err)
if err != nil {
    panic(err)
}
fmt.Println(transaction)
<?php
require_once 'vendor/autoload.php';

use WestWallet\WestWallet\Client;
use WestWallet\WestWallet\InsufficientFundsException;

$client = new Client("your_public_key", "your_private_key");

// Send 0.1 ETH to 0x57689002367b407f031f1BB5Ef2923F103015A32
try {
    $tx = $client->createWithdrawal("ETH", "0.1", "0x57689002367b407f031f1BB5Ef2923F103015A32");
    print(implode("|", $tx)."\n");
} catch(InsufficientFundsException $e) {
    print("You don't have enough funds to make this withdrawal"."\n");
}

Withdraw funds from desired wallet.

HTTP request

POST /wallet/create_withdrawal

Post params

Argument Example Required Description
currency BTC yes Currency to be sent
amount 0.1 yes Amount to be sent
address 35NjwZg8T4F12ESdEo3rQeYQ8ZiTyDYoTJ да Receive address
dest_tag 1390985919 no Destination tag (required for some currencies)
description no Label for further identification in dashboard
priority medium no Transaction's priority - low, medium or high (only for BTC). Default value - medium.

Transaction status

Possible statuses:

POST https://api.westwallet.io/wallet/transaction

{
  "id": 123123,
  "type": "send",
  "amount": 0.1,
  "address": "rw2ciyaNshpHe7bCHo4bRWq6pqqynnWKQg",
  "dest_tag": "755785168",
  "label": "your_label",
  "currency": "XRP",
  "status": "completed",
  "blockchain_confirmations": 1,
  "blockchain_hash": "BC07C0937F2B12D8DF8F90B5A421957DC690DC8512F97925217726E6A28F0A93",
  "fee": "0.0001",
  "error": "ok"
}
from westwallet_api import WestWalletAPI

client = WestWalletAPI("your_public_key", "your_private_key")
transaction = client.transaction_info(19)
print(transaction.__dict__)
const westwallet = require('westwallet-api');
const westwalletErrors = require('westwallet-api/lib/errors');

const publicKey = "yourPublicKey";
const privateKey = "yourPrivateKey";

let client = new westwallet.WestWalletAPI(
    publicKey, 
    privateKey
);

client.transactionInfo(1284).then((data) => {
    console.log(data);
}).catch((error) => {
    if (error instanceof westwalletErrors.TransactionNotFoundError) {
        console.log("Transaction not found");
    }
});
package main

import (
    "fmt"
    westwallet "github.com/westwallet/westwallet-golang-api"
)

client := westwallet.APIClient{
    Key:      "your_public_key",
    Secret:   "your_private_key",
}

transaction, err := client.TransactionInfo(145);
fmt.Println(err)
if err != nil {
    panic(err)
}
fmt.Println(transaction)
<?php
require_once 'vendor/autoload.php';

use WestWallet\WestWallet\Client;
use WestWallet\WestWallet\TransactionNotFoundException;

$client = new Client("your_public_key", "your_private_key");

try {
    $tx = $client->transactionInfo(134);
    print(implode("|", $tx)."\n");
} catch(TransactionNotFoundException $e) {
    print("Transaction not found"."\n");
}

Find out the status of the transaction.

HTTP request

POST /wallet/transaction

Post params

Arguments Examples Required Description
id 123123 yes Transaction ID within WestWallet service

Transactions history

POST https://api.westwallet.io/wallet/transactions

{
  "error": "ok",
  "result": [{
    "id": 123123,
    "created_at": "2019-12-29 15:07:13",
    "updated_at": "2019-12-29 15:12:43",
    "type": "send",
    "amount": 0.1,
    "address": "rw2ciyaNshpHe7bCHo4bRWq6pqqynnWKQg",
    "dest_tag": "755785168",
    "label": "your_label",
    "currency": "XRP",
    "status": "completed",
    "description": "your custom description",
    "blockchain_confirmations": 1,
    "blockchain_hash": "BC07C0937F2B12D8DF8F90B5A421957DC690DC8512F97925217726E6A28F0A93",
    "fee": "0.0001"
  }]
}

Check transactions' history.

HTTP request

POST /wallet/transactions

Post params

Argument Example Required Description
currency BTC no Currency code. If not specified - you'll get transactions for all currencies based on other request params.
limit 10 no Limit of transactions in response (max 50).
offset 20 no Offset.
type send no Transaction type - send or receive. If it's not specify - you'll get both of them.
order desc no Date-time order - descending (desc) or ascending (asc).

Wallet balance

GET https://api.westwallet.io/wallet/balance?currency=BTC

{
  "balance": 0.55,
  "currency": "BTC"
}
from westwallet_api import WestWalletAPI

client = WestWalletAPI("your_public_key", "your_private_key")
balance = client.wallet_balance("BTC")
print(balance.balance)
const westwallet = require('westwallet-api');
const westwalletErrors = require('westwallet-api/lib/errors');

const publicKey = "yourPublicKey";
const privateKey = "yourPrivateKey";

let client = new westwallet.WestWalletAPI(
    publicKey, 
    privateKey
);

client.walletBalance("BTC").then((data) => {
    console.log(data);
}).catch((error) => {
    if (error instanceof westwalletErrors.CurrencyNotFoundError) {
        console.log("No such currency");
    }
});
package main

import (
    "fmt"
    westwallet "github.com/westwallet/westwallet-golang-api"
)

client := westwallet.APIClient{
    Key:      "your_public_key",
    Secret:   "your_private_key",
}

balance, err := client.WalletBalance("BTC");
fmt.Println(err)
if err != nil {
    panic(err)
}
fmt.Println(balance)
<?php
require_once 'vendor/autoload.php';

use WestWallet\WestWallet\Client;
use WestWallet\WestWallet\CurrencyNotFoundException;

$client = new Client("your_public_key", "your_private_key");

try {
    $balance = $client->walletBalance("BTC");
    print(implode("|", $balance)."\n");
} catch(CurrencyNotFoundException $e) {
    print("No such currency"."\n");
}

Check wallet balance

HTTP request

GET /wallet/balance?currency=BTC

Query params

Argument Example Required Description
currency BTC yes Wallet currency

All wallet's balances

GET https://api.westwallet.io/wallet/balances

{
  "ETH": 3.22,
  "ETC": 34,
  "LTC": 40,
  "BTC": 1.11,
  "XLM": 319.11,
  "XMR": 15.12
}
from westwallet_api import WestWalletAPI

client = WestWalletAPI("your_public_key", "your_private_key")
balances = client.wallet_balances()
print(balances.__dict__)
const westwallet = require('westwallet-api');
const westwalletErrors = require('westwallet-api/lib/errors');

const publicKey = "yourPublicKey";
const privateKey = "yourPrivateKey";

let client = new westwallet.WestWalletAPI(
    publicKey, 
    privateKey
);

client.walletBalances().then((data) => {
    console.log(data);
}).catch((error) => {
    console.log(error);
});
package main

import (
    "fmt"
    westwallet "github.com/westwallet/westwallet-golang-api"
)

client := westwallet.APIClient{
    Key:      "your_public_key",
    Secret:   "your_private_key",
}

balances, err := client.WalletBalances();
fmt.Println(err)
if err != nil {
    panic(err)
}
fmt.Println(balance)
<?php
require_once 'vendor/autoload.php';

use WestWallet\WestWallet\Client;
use WestWallet\WestWallet\CurrencyNotFoundException;

$client = new Client("your_public_key", "your_private_key");

$balances = $client->walletBalances();
print(implode("|", $balances)."\n");

All wallet's balances

HTTP request

GET /wallet/balances

Addresses

Generate address

POST https://api.westwallet.io/address/generate

{
  "address": "rw2ciyaNshpHe7bCHo4bRWq6pqqynnWKQg",
  "dest_tag": "755785168",
  "currency": "XRP",
  "label": "your_label",
  "error": "ok"
}
from westwallet_api import WestWalletAPI

client = WestWalletAPI("your_public_key", "your_private_key")
address = client.generate_address("XRP", "https://yourwebsite.com/ipn_url", "your_address_label")
print(address.address, address.dest_tag)
const westwallet = require('westwallet-api');
const westwalletErrors = require('westwallet-api/lib/errors');

const publicKey = "yourPublicKey";
const privateKey = "yourPrivateKey";

let client = new westwallet.WestWalletAPI(
    publicKey, 
    privateKey
);

client.generateAddress("BTC", "https://yourwebsite.com/ipn_url", "your_address_label")
.then((data) => {
    console.log(data);
}).catch((error) => {
    if (error instanceof westwalletErrors.CurrencyNotFoundError) {
        console.log("No such currency");
    }
});

package main

import (
    "fmt"
    westwallet "github.com/westwallet/westwallet-golang-api"
)

client := westwallet.APIClient{
    Key:      "your_public_key",
    Secret:   "your_private_key",
}

address, err := client.GenerateAddress("BTC", "https://yourwebsite.com/ipn_url", "your_address_label")
if err != nil {
    panic(err)
}
fmt.Println(address.Address)
<?php
require_once 'vendor/autoload.php';

use WestWallet\WestWallet\Client;
use WestWallet\WestWallet\CurrencyNotFoundException;

$client = new Client("your_public_key", "your_private_key");

try {
    $address = $client->generateAddress("BTC");
    print(implode("|", $address)."\n");
} catch(CurrencyNotFoundException $e) {
    print("No such currency"."\n");
}

HTTP request

POST /address/generate

Post params

Arguments Example Required Description
currency BTC yes currency of address that will be generate
ipn_url https://yourwebsite.com/payment_secret_token?tx_id=123321 yes Instant Payment Notification URL. At this address you will be notified as soon as someone will send funds for this address.
label tx54543 no Select a label for the addresses for further identification (maximim 30 characters)

Notifications about payments

Examples of the payment notification

{
  "id": 123123,
  "amount": 0.1,
  "address": "35NjwZg8T4F12ESdEo3rQeYQ8ZiTyDYoTJ",
  "dest_tag": "",
  "label": "312321",
  "currency": "BTC",
  "status": "completed",
  "blockchain_confirmations": 1,
  "blockchain_hash": "72648cefcc47b4371f28dc3328bc863918913eebf81b40d4a97d577b96c1ce53"
}

Once you have generated the address with ipn_url and got payment at this address, you will get a POST-request on this url with such a data structure Possible statuses in response body: pending, completed.

We are making request with header Content-Type: application/x-www-form-urlencoded .

HTTP request

GET /webhook/example

Possible errors

Every response got field "error". If it's "ok" - just pass. Else, check your error:

Errors

WestWallet API uses the error codes for all requests:

Error Code Meaning
400 Bad Request - Incorrect request fields provided, explaination in the error field.
401 Unauthorized - API key is incorrect or not specified at all.
404 Not Found - Resource is not found. Check the documentation.
405 Method Not Allowed - You are trying to make a request using prohibited HTTP method.
429 Too Many Requests - You're making too much requests
500 Internal Server Error - The problem on the side of our server. Please notify our support.

If request was successful you will receive a status 200.