Follow along with our interactive demo to see how the Persist JSON API can be integrated into your web applications.
import PersistJsonAPI from 'https://persist-json-api.wonderwhy-er.com/persist-json-api.js';
const api = new PersistJsonAPI();
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.
const response = await api.save({"Hello":"world"}, "documentation-demo");
const response = await api.list("documentation-demo");
const response = await api.load(id, "documentation-demo");
const response = await api.share(id, "documentation-demo");
const response = await api.load(response.token, "documentation-demo");
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);