Records

The records route provides a flexible and powerful way to create, retrieve, update, and delete records within your app. The route is designed to be resource-oriented and follows standard HTTP verbs.

Create

Create a record.

POST https://api.myjson.online/v1/records

Headers

Request Body

{
    data: JSON,
    id: String
}
// Javascript example
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var urlencoded = new URLSearchParams();
urlencoded.append("jsonData", `{"firstName": "Tim", "lastName": "Cook"}`);
urlencoded.append("collectionId", "YOUR_COLLECTION_ID");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Get

Get a record

GET https://api.myjson.online/v1/records/:recordId

Path Parameters

Headers

{
    data: JSON,
    id: String
}
// Javascript example
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records/YOUR_RECORD_ID", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));

Get by version

GET https://api.myjson.online/v1/records/:recordId/versions/:version

Get a record version

Path Parameters

Headers

// Javascript example
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records/YOUR_RECORD_ID/versions/VERSION_NUMBER", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));

Update

Update a record

PUT https://api.myjson.online/v1/records/:recordId

Path Parameters

Headers

Request Body

{
    data: JSON,
    id: String
}
// Javascript example
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var urlencoded = new URLSearchParams();
urlencoded.append("jsonData", `{"firstName": "Charles", "lastName": "Cook"}`);

var requestOptions = {
  method: 'PUT',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records/YOUR_RECORD_ID", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Patch

Update specific property of the record

PATCH https://api.myjson.online/v1/records/:recordId

Path Parameters

Headers

Request Body

{
    data: JSON,
    id: String
}
// Javascript example
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var urlencoded = new URLSearchParams();
urlencoded.append("jsonData", `{"firstName": "Antoine"`);

var requestOptions = {
  method: 'PATCH',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records/YOUR_RECORD_ID", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Delete

Delete a record

DELETE https://api.myjson.online/v1/records/:recordId

Path Parameters

Headers

{
    message: String
}
// Javascript example
var myHeaders = new Headers();
myHeaders.append("x-collection-access-token", "YOUR_COLLECTION_ACCESS_TOKEN");

var urlencoded = new URLSearchParams();

var requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://api.myjson.online/v1/records/YOUR_RECORD_ID", requestOptions)
  .then(response => response.jsont())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Last updated