Documents

Last updated: November 11th, 2021

Introduction

Jsonstores.com offers free, secure JSON datastore on the cloud for small and intermediate business. Enter the email on jsonstores.com to get a unique JSON store endpoint. Sending HTTP requests to communicate with your JSON datastore. Send POST requests to store data, PUT and PATCH requests to modify data, DELETE to remove data, and GET to retrieve data.

Javascript Example

Make sure to replace the URL in the example with your own endpoint, which you can get at jsonstores.com

POST

The following codes will create an object with the type of 'user'. The new user's ID will be returned.

JavaScript Code Example

let xhr = new XMLHttpRequest()

let myObj = {name:"Steve Jobs", company:"Apple"};                                            
xhr.addEventListener('load', () => {    
	if (xhr.readyState === 4 && xhr.status === 200) {
        console.log(xhr.responseText)
    }                                      
})
                                            
let url =   https://api.jsonstores.com/5679096778206781440wJqSH/user
xhr.open('POST', url, false)
                                        
xhr.send(JSON.stringify(myObj))                                           
                                        
Response

{"id":"1"}
                                        

POST with custom id

The following codes will create an object with the type of 'user' with custom id.

JavaScript Code Example

let xhr = new XMLHttpRequest()

let myObj = {name:"Steve Jobs", company:"Apple"};                                            
xhr.addEventListener('load', () => {  
	if (xhr.readyState === 4 && xhr.status === 200) {
        console.log(xhr.responseText)
    }                                         
})
                                            
let url =   https://api.jsonstores.com/5679096778206781440wJqSH/user/my-custom-id
xhr.open('POST', url, false)
                                        
xhr.send(JSON.stringify(myObj))                                           
                                        
Response

{"id":"my-custom-id"}
                                        

GET

These code snippets will retrieve the user object using the id.

JavaScript Code Example

let xhr = new XMLHttpRequest()
          
xhr.addEventListener('load', () => {
    if (xhr.readyState === 4 && xhr.status === 200) {
        console.log(xhr.responseText)
    } 
})
                                                    
let url =   https://api.jsonstores.com/5679096778206781440wJqSH/user/1
                                                    
xhr.open('GET',  url ,false)
xhr.send()
                                
Response

{name:"Steve Jobs", company:"Apple"}
                                        

PUT

The following codes will update the user object.

JavaScript Code Example

let xhr = new XMLHttpRequest()

let myObj = {name:"Steve Jobs", company:"Apple Inc"};                                            
xhr.addEventListener('load', () => {                                          
})
                                            
let url =   https://api.jsonstores.com/5679096778206781440wJqSH/user/1
xhr.open('PUT', url, false)
                                        
xhr.send(JSON.stringify(myObj))                                           
                                        

DELETE

The following codes will delete the user object.

JavaScript Code Example

let xhr = new XMLHttpRequest()
                                                    
let url =   https://api.jsonstores.com/5679096778206781440wJqSH/user/1
                                                    
xhr.open('DELETE',  url ,false)
xhr.send()
                                

PATCH

We follow the JSON PATCH standard to allow partial updates to a JSON document. It can be useful to avoid sending a whole document when only a part has changed. More details documents can be found on JSON PATCH.

Patch example

[
  { "op": "replace", "path": "/name", "value": "Jone Doe" },
  { "op": "add", "path": "/hello", "value": ["world", "!"] },
  { "op": "remove", "path": "/company" }
]