Skip to content

Get API Key

You will need an API key to read or write data. Each request to prefs.is API requires a valid API Key (API Token).

Generate Key via API

All data will be retrievable with the generated key. Function .getkey() takes a string which serves as a key identifier plus an array of string values of which are used to build the API key token. The array should contain any combination of secret and public data elements.

    prefs_us.getkey('key-id', ['val1', 'val2',...]);

Generate a key with a callback

    prefs_us.getkey('key-id', ['val1', 'val2',...], (response) => {
        console.log("API Key: %s", response.token);
    });

Generate a key with a Promise

    prefs_us.getkey('key-id', ['val1', 'val2',...])
        .then((response) => response.json())
        .then((data) => { 
            console.log("API Key: %s", data.token); 
        });

Look up the generated key (once ready and if needed). Generated keys should be captured via a callback or a Promise.

    const apikey = prefs_us.key();

Re-use a previously generated API key.

    prefs_us.using(apikey);
<script src="https://prefs.us/prefs.us.min.js"></script>

prefs_us.getkey("key-id", [ 'secret-value', 'public-value' ], (R)=>{
  console.log("%o",R);
});
import com.gorny.prefsus;

PrefsUs.getkey("key_id", ["seed_phrase"], (R)->{
  System.out.println(R);
});
import prefus

def callback(R):
    print("Received: ", R)

String api_key = prefsus.getkey("key_id", ["seed_phrase"], callback);

Response:

{
  "status" : "success",
  "token"  : "38c26...7cb1",
  "ts"     : "2025-10-29 12:58:52",
  "message" : "New key generated."
}

The token is your API key. The response will include a hint whether it is a new or an existing token (message field).

HINT: For security reasons, generated keys could be stored as a system variable on the server side.

IMPORTANT!

Remember to safely store away your secret key-id and seed-phrase as there is no way to retrieve them if a key is lost. You may loose ability to recover your data should the key be lost. All data will then be purged after a period of inactivity.

Generate Key via Form

Choose your own key-id and a seed-phrase below. Store those credentials somewhere securely as there is no way to retrieve them at a later time once a key is generated.

Key id:  

Seed phrase: