Skip to content

Introduction

A Short-Lived Disposable Settings API

Sometimes we just need a quick way to persist some data without getting into creating a dedicated data store. Or maybe we just don't want to pollute an existing storage with temporary data that is ephermal in nature and we only need for a short little while. Demo apps, mock ups, proofs of concept... are all use cases for this service.

Well, say hello to prefs.us!

  • No accounts. No logins.
  • No backend: save and retrieve data straight from the client.
  • No databases to create and maintain.
  • Secured with password-based encryption processes.
  • Data life-cycle controlled with TTL.

The idea is to be able to quickly store and retrieve some data with minimum fuss. With that goal in mind, the API was designed to be as frictionless as possible. The service does not require a login or accounts on your part.

How does it work?

Let's say you you build a frontend and need to preserve some user-specific data, like user preferences, settings, config, etc. When saving to locatStorage is often a choice, it has two fundamental flaws:

  1. the data gets wiped when user cleans the browser data
  2. the data does not persist across devices.

This is where prefs.us shines. It can be used like local storage but it will survive device resests, data wipes, and user will be able to resume on different devices.

Data encryption

The API utilizes Password-Based Encryption process to generate a unique API token which will govern the use of your data. All communication and traffic (data in motion) between the client (your app) and the server server is secured with industry standard HTTPS protocols. And finally, all data is stored encrypted secured by AES-256 encryption algorythm (data-at-rest).

As of now prefs.us handles data stored as key=value pairs or lists.

Key-Value pairs

prefs_us.key("user")
        .write('{"score":"200", "level":"3" }');

Lists and collections

prefs_us.list("signups")
        .add("jane.doe@somewhere.com");
// uses a callback 
prefs_us.list("signups")
        .read( (data) => {
            console.log(data.values);
        });

Organized and grouped data

Each API token can organize and store your data under any number of projects, domains, or subdomains.

var gameJson = {...};

prefs_us.domain("ultimafaux")
        .key("user")
        .write(gameJson);

Callbacks and Promises

Retrieve data using callback functions or handle Promise directly, whatever fits your style.

// uses a callback 
prefs_us.domain("ultimafaux")
        .key("user")
        .read( (data) => {
            gameJson = data.value;
        });

// uses Promise
prefs_us.key("user").read()
    .then( (response) => response.json())
    .then( (data) => {
        console.log(data.values);
    })
    .catch( (error) => {
        console.log(error.name);
    });

Time-To-Live

You can set an arbirary time-to-live constraint on any piece of data. Inactive data will be purged from the system when TTL has been reached. Inactive means it was not read nor written to (updated) within TTL time window.

var stuff = {...};

// store game state for 90 days
prefs_us.domain("demostuff")
        .project("myclient")
        .ttl(10)
        .key("proposal123")
        .write(stuff);