Skip to content

Getting started

The idea is to be able to quickly store and retrieve data with minimum fuss. With that goal in mind, the API was designed to be as frictionless as possible. Basically obtain an API key and use read and write endpoint with that key. No logins, no sign ups - just you and your data that will delete itself when you forget about it.

Step 1: Get Your API token.

Any read or write operation requires a valid API token (a.k.a. API Key). /getkey function takes two parameters:

  1. the key-id: a plain string identifying the API token, and
  2. a string array containing seed phrases.

A new API key will be generated if one does not exist.

<script src="https://prefs.us/prefs.us.min.js"></script>

prefs_us.getkey("key_id", [ "seed_phrase", "phrase2" ], (reply)=>{
  console.log("API token: %s", reply.token);
});

See also: Generate API Key ahead of time

Step 2: API Endpoints

Use .read() and .write() methods to save and retrieve your data.

First, include prefs.us library in your project

<script src="https://prefs.us/prefs.us.js"></script>

To save data:

prefs_us.key("dataKey").write("dataValue");

To read data:

prefs_us.key("dataKey").read( (reply)=>{
    // do something with your data
});

Quick notes

  1. Keep and use the same key for all subsequent queries to keep your items grouped together, whether saving or retrieving them.

  2. Use grouping parameters such as 'project', 'domain', 'subdomain', or 'list' to help with organizing your data attached to your API key.

  3. Create as many keys as you need but traffic may be a subject to rate limiting.

  4. All timestamps are UTC