๐Ÿ—๏ธAPI

This documentation covers the API endpoints related to API key management in the WhirlPrivacy project.

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

For these requests, you must firstly sign in frontend (e.g., with Web3.js), then put this signature in your Authorization header.

Common Headers

For all requests that require API key management, you must include the following headers:

Header NameValueDescription

Authorization

string

The signature obtained in frontend from your wallet.

GET /user/api - Retrieve API Key

Description:

Allows a logged-in user to retrieve their API key.

Parameters:

None.

Response:

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

Unauthorized

User is not logged in or session has expired.

Example Code:

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

const BASE_URL = 'https://api.whirlprivacy.io/';
const signature = 'your_signature';

const retrieveAPIKey = async () => {
  try {
    const response = await fetch(`${BASE_URL}user/api`, {
      headers: {
        'Authorization': `Bearer ${signature}`
      }
    });
    const data = await response.json();

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

retrieveAPIKey();

PUT /user/api/generate - Generate API Key

You can only generate 1 key per hour, to avoid too much load on our servers, but once generated your API key won't expire unless you revoke it or generate a new one.

Description:

Allows a logged-in user to generate a new API key for their account.

Parameters:

None.

Response:

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

Error Handling:

Error NameDescription

Unauthorized

User is not logged in or session has expired.

Error generating API key, regenen timeout: 1h

An error occurred during API key generation. Wait for 1 hour before trying again.

Example Code:

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

const BASE_URL = 'https://api.whirlprivacy.io/';
const signature = 'your_signature';

const generateAPIKey = async () => {
  try {
    const response = await fetch(`${BASE_URL}user/api/generate`, {
      method: 'PUT',
      headers: {
        'Authorization': `Bearer ${signature}`
      }
    });
    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

Description:

Allows a logged-in user to disable their current API key.

Parameters:

None.

Response:

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

Error Handling:

Error NameDescription

Unauthorized

User is not logged in or session has expired.

Example Code:

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

const BASE_URL = 'https://api.whirlprivacy.io/';
const signature = 'your_signature';

const disableAPIKey = async () => {
  try {
    const response = await fetch(`${BASE_URL}user/api/disable`, {
      method: 'PUT',
      headers: {
        'Authorization': `Bearer ${signature}`
      }
    });
    const data = await response.json();

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

disableAPIKey();

Last updated