Create
Create a record.
POST
https://api.myjson.online/v1/records
Request Body
200: OK 400: Bad Request
Copy {
data : JSON ,
id : String
}
Copy {
error : "Bad Request" ,
message : "Invalid request"
}
Copy // 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
200: OK 400: Bad Request
Copy {
data : JSON ,
id : String
}
Copy // 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
200: OK 400: Bad Request 404: Not Found
Copy // 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
Request Body
200: OK 400: Bad Request
Copy {
data : JSON ,
id : String
}
Copy // 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
Request Body
200: OK 400: Bad Request
Copy {
data : JSON ,
id : String
}
Copy // 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
Copy // 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));