๐Ÿง‘User

This documentation provides details on the API endpoints available for Whirlprivacy.io, focusing on user-related operations.

โš ๏ธ You must be logged in to use these requests.

Common Headers

For all requests that require user authentication, you must include the following headers:

Header NameValueDescription

X-API-key

base64

API token obtained after authentication.

GET /user/balance โ€“ Get User Asset Balance

Description:

Retrieves the balance of the specified asset for the authenticated user. It checks whether the asset exists and if the user has a balance greater than 0, then formats and returns the balance amount.

Parameters:

NameTypeDescription

ticker

string

The ticker symbol of the asset.

Response:

{
  "error": [],
  "result": [
    {
      "amount": "0",
      "formatted": "0"
    }
  ]
}

Error Handling:

Error NameDescription

E_INVALID_TICKER

The provided ticker is invalid.

Example Code:

const fetch = require('node-fetch');

const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_token';

const getUserAssetBalance = async () => {
  const queryParams = new URLSearchParams({
    ticker: 'asset_ticker'
  });

  try {
    const response = await fetch(`${BASE_URL}user/balance?${queryParams}`, {
      headers: {
        'X-API-Key': API_KEY
      }
    });
    const data = await response.json();

    console.log(data.result);
  } catch (error) {
    console.error('Error fetching user asset balance:', error);
  }
};

getUserAssetBalance();

GET /user/balances โ€“ Get User Balances

Description:

Retrieves all asset balances from the expected user.

Parameters:

NameTypeDescription

user

string

The user to check the balance

Response:

{
  "error": [],
  "result": [
    {
      "ticker": "string",
      "amount": "int",
      "formatted": "string"
    }
  ]
}

Error Handling:

Error NameDescription

E_UNAUTHORIZED

The user is not authorized.

Example Code:

const fetch = require('node-fetch');

const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_token';

const getUserBalances = async () => {
  const queryParams = new URLSearchParams({
    user: 'user_identifier'
  });

  try {
    const response = await fetch(`${BASE_URL}user/balances?${queryParams}`, {
      headers: {
        'X-API-Key': API_KEY
      }
    });
    const data = await response.json();

    console.log(data.result);
  } catch (error) {
    console.error('Error fetching user balances:', error);
  }
};

getUserBalances();

General Error Handling

This section covers errors that are common across multiple endpoints.

Error NameDescription

E_UNAUTHORIZED

The user is not authenticated or lacks the necessary permissions.

E_INVALID_TICKER

The specified ticker symbol does not correspond to a valid asset.

GET /user/addresses โ€“ User Withdrawal Addresses

Description:

Retrieves the active withdrawal addresses of the logged-in user.

Parameters:

NameTypeRequiredDescription

page

Query

No

The page number of the withdrawal addresses to retrieve. Defaults to 1.

Response:

{
  "error": [],
  "result": [
    {
      "address": "string",
      "name": "string"
    },
    ...
  ],
  "meta": {
    "pagination": {
      "total": "int",
      "perPage": "int",
      "currentPage": "int",
      "lastPage": "int"
    }
  }
}

Error Handling:

Error CodeDescription

E_UNAUTHORIZED

Unauthorized access to the endpoint.

Example Code:

const fetch = require('node-fetch');

const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_token';

const getUserWithdrawalAddresses = async () => {
  const queryParams = new URLSearchParams({
    page: '1' // Adjust the page number as needed
  });

  try {
    const response = await fetch(`${BASE_URL}user/addresses?${queryParams}`, {
      headers: {
        'X-API-Key': API_KEY
      }
    });
    const data = await response.json();

    console.log(data.result);
  } catch (error) {
    console.error('Error fetching user withdrawal addresses:', error);
  }
};

getUserWithdrawalAddresses();

GET /user/addresses/all โ€“ All User Withdrawal Addresses

Description:

Returns a complete list of the user's withdrawal addresses, irrespective of their status.

Parameters:

No parameters are required for this request.

Response:

{
  "error": [],
  "result": [
    {
      "address": "string",
      "name": "string"
    },
    ...
  ]
}

Error Handling:

Error CodeDescription

E_UNAUTHORIZED

Unauthorized access to the endpoint.

Example Code:

const fetch = require('node-fetch');

const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_token';

const getAllUserWithdrawalAddresses = async () => {
  try {
    const response = await fetch(`${BASE_URL}user/addresses/all`, {
      headers: {
        'X-API-Key': API_KEY
      }
    });
    const data = await response.json();

    console.log(data.result);
  } catch (error) {
    console.error('Error fetching all user withdrawal addresses:', error);
  }
};

getAllUserWithdrawalAddresses();

POST /user/addresses โ€“ Create Withdrawal Address

Description:

Allows the logged-in user to add a new withdrawal address to their account.

Parameters:

NameTypeRequiredDescription

address

Body

Yes

The withdrawal address to add. Must be a valid address format.

name

Body

Yes

A name to associate with the withdrawal address.

Response:

{
  "error": [],
  "result": "Created"
}

Error Handling:

Error CodeDescription

E_INVALID_PARAMS

One or more provided parameters are invalid.

E_MAX_ADDRESSES

The maximum number of addresses for the user has been reached.

E_CREATING_ADDRESS

An error occurred while creating the address, possibly because it's already registered.

E_UNAUTHORIZED

Unauthorized access to the endpoint.

Example Code:

const fetch = require('node-fetch');

const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_token';

const createWithdrawalAddress = async (address, name) => {
  try {
    const response = await fetch(`${BASE_URL}user/addresses`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'X-API-Key': API_KEY
      },
      body: JSON.stringify({ address, name })
    });
    const data = await response.json();

    console.log(data.result);
  } catch (error) {
    console.error('Error creating withdrawal address:', error);
  }
};

createWithdrawalAddress('new_address', 'address_name');

PUT /user/addresses โ€“ Disable Withdrawal Address

Description:

Allows the logged-in user to disable an existing withdrawal address.

Parameters:

NameTypeRequiredDescription

address

Body

Yes

The withdrawal address to disable.

Response:

{
  "error": [],
  "result": "Disabled"
}

Error Handling:

Error CodeDescription

E_DISABLING_ADDRESS

An error occurred while disabling the address, possibly because it's not registered or already disabled.

E_UNAUTHORIZED

Unauthorized access to the endpoint.

Example Code:

const fetch = require('node-fetch');

const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_token';

const disableWithdrawalAddress = async (address) => {
  try {
    const response = await fetch(`${BASE_URL}user/addresses`, {
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json',
        'X-API-Key': API_KEY
      },
      body: JSON.stringify({ address })
    });
    const data = await response.json();

    console.log(data.result);
  } catch (error) {
    console.error('Error disabling withdrawal address:', error);
  }
};

disableWithdrawalAddress('existing_address');

PUT /user/api/generate โ€“ Generate API Key

This request is only possible via the standard auth on our platform. Apart from these 3 routes (and the auth/register part), all other auth routes can be accessed either via the jwt (X-API-key header) after having signed the challenge, or via the X-API-key.

Description:

Generates a new API key for the authenticated user.

Parameters:

ParameterTypeDescription

request

Object

The HTTP request object.

response

Object

The HTTP response object.

Response:

{
  "error": [],
  "result": {
    "apiKey": "string"
  }
}

Error Handling:

Error CodeDescription

200

Success, but no API key generated.

401

Unauthorized access.

429

Too many requests, regeneration timeout not passed.

Example Code:

const fetch = require('node-fetch');

const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_token';

const generateAPIKey = async () => {
  try {
    const response = await fetch(`${BASE_URL}user/api/generate`, {
      method: 'PUT',
      headers: {
        'X-API-Key': API_KEY
      }
    });
    const data = await response.json();

    console.log(data.result);
  } catch (error) {
    console.error('Error generating API key:', error);
  }
};

generateAPIKey();

PUT /user/api/disable โ€“ Disable API Key

This request is only possible via the standard auth on our platform. Apart from these 3 routes (and the auth/register part), all other auth routes can be accessed either via the jwt (X-API-key header) after having signed the challenge, or via the X-API-key.

Description:

Disables the current API key for the authenticated user.

Parameters:

ParameterTypeDescription

request

Object

The HTTP request object.

auth

Object

Authentication information.

response

Object

The HTTP response object.

Response:

{
  "error": [],
  "result": "Disabled"
}

Error Handling:

Error CodeDescription

200

Success.

401

Unauthorized access.

Example Code:

const fetch = require('node-fetch');

const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_token';

const disableAPIKey = async () => {
  try {
    const response = await fetch(`${BASE_URL}user/api/disable`, {
      method: 'PUT',
      headers: {
        'X-API-Key': API_KEY
      }
    });
    const data = await response.json();

    console.log(data.result);
  } catch (error) {
    console.error('Error disabling API key:', error);
  }
};

disableAPIKey();

GET /user/api โ€“ Get API Key

This request is only possible via the standard auth on our platform. Apart from these 3 routes (and the auth/register part), all other auth routes can be accessed either via the jwt (X-API-key header) after having signed the challenge, or via the X-API-key.

Description:

Retrieves the current API key for the authenticated user.

Parameters:

ParameterTypeDescription

request

Object

The HTTP request object.

response

Object

The HTTP response object.

Response:

{
  "error": [],
  "result": {
    "apiKey": "string"
  }
}

Error Handling:

Error CodeDescription

200

Success.

401

Unauthorized access.

Example Code:

const fetch = require('node-fetch');

const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_token';

const getAPIKey = async () => {
  try {
    const response = await fetch(`${BASE_URL}user/api`, {
      method: 'GET',
      headers: {
        'X-API-Key': API_KEY
      }
    });
    const data = await response.json();

    console.log(data.result);
  } catch (error) {
    console.error('Error fetching API key:', error);
  }
};

getAPIKey();

Last updated