Persist JSON API Documentation

Follow along with our interactive demo to see how the Persist JSON API can be integrated into your web applications.

How to use

1. Load the JavaScript API file

import PersistJsonAPI from 'https://persist-json-api.wonderwhy-er.com/persist-json-api.js';
const api = new PersistJsonAPI();

Namespace Requirement

The namespace parameter is required to differentiate between different applications using the same API. It ensures that the data stored is organized and isolated per application, preventing conflicts and enabling better data management.

In the following examples, we will use a hardcoded namespace "documentation-demo" to illustrate how to use the API.

2. Use API to save JSON and get IDs back; it will ask the user to login or register if not logged in

const response = await api.save({"Hello":"world"}, "documentation-demo");

3. You can ask for a list of user JSONs

const response = await api.list("documentation-demo");

4. You can load JSON by ID. One user can't load other users' JSONs unless shared.

const response = await api.load(id, "documentation-demo");

5. You can also make a public link to any private JSON by using the share method

const response = await api.share(id, "documentation-demo");

6. After you get the share code, you can use it in the load method to get JSON content even if it's not yours

const response = await api.load(response.token, "documentation-demo");

Overwrite an Existing JSON File

You can overwrite an existing JSON file by providing its ID. This will replace the content of the file with the new data.

const response = await api.save({"NewContent":"Updated"}, "documentation-demo", existingId);