Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 1.25 KB

auth.md

File metadata and controls

31 lines (23 loc) · 1.25 KB

Auth for the Namebase API

To obtain an API key, visit the keys page on https://www.namebase.io/pro/keys and follow the instructions in the user interface.

Be careful with your API keys: they grant unrestricted access to your exchange account.

Authenticating to the API

The Namebase API expects HTTP Basic Auth with a valid pair of Namebase API keys. Use the ACCESS_KEY as the username and the SECRET_KEY as the password. To authorize your requests, send an HTTP request to one of the API endpoints with the following Authorization header:

Authorization: Basic /* base64-encoded string of ACCESS_KEY:SECRET_KEY */

Here is a code sample of API key authentication using Node.js and the node-fetch package:

const credentials = Buffer.from(`${ACCESS_KEY}:${SECRET_KEY}`);
const encodedCredentials = credentials.toString('base64');
const authorization = `Basic ${encodedCredentials}`;
fetch(/*ENDPOINT*/, {
  method: 'GET',
  headers: {
    Authorization: authorization,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
});

Note: for Node.js, you may want to use the officially supported Node.js client library linked to in the documentation homepage.