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

Name
Type
Description

x-collection-access-token

String

Content-Type*

x-record-metadata

true | false

default to true, return metadata

Request Body

Name
Type
Description

jsonData*

JSON

Your json data

collectionId*

String

myJson collection id

{
    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

Name
Type
Description

recordId*

String

Headers

Name
Type
Description

Content-Type*

String

x-collection-access-token

String

x-record-metadata

true | false

default to true, return metadata

{
    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

Name
Type
Description

recordId*

String

version*

Number

Headers

Name
Type
Description

x-collection-access-token

String

x-record-metadata

true|false

default to true, return metadata

// 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

Name
Type
Description

recordId*

String

Headers

Name
Type
Description

Content-Type*

String

x-collection-access-token

String

x-record-metadata

true | false

default to true, return metadata

Request Body

Name
Type
Description

jsonData*

JSON

{
    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

Name
Type
Description

recordId*

String

Headers

Name
Type
Description

Content-Type*

String

x-collection-access-token

String

x-record-metadata

true | false

default to true, return metadata

Request Body

Name
Type
Description

jsonData*

JSON

{
    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

Name
Type
Description

recordId*

String

Headers

Name
Type
Description

Content-Type*

String

x-collection-access-token

String

{
    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