In "Developer mode" inside a database collection, you can quickly get "ready-to-run" code for your restdb.io database endpoint in the following languages: cURL, Javascript, Python, PHP, Java, C#, Objective-C and Swift (see example below).
If you just want some generic examples right now, you can select your language below and copy code for the HTTP REST method you want to use.
🚀 If you love JavaScript and the coding-parts of restdb.io, please also check out our new backend service: codehooks.io. It integrates Javascript serverless functions with a document database, a key/value database, a message queue and a CRON-like job system. A powerful CLI lets you instantly deploy new code.
curl -k -i -H "Content-Type: application/json"\
-H "x-apikey: 560bd47058e7ab1b2648f4e7"\
-X GET 'https://inventory-fac4.restdb.io/rest/motorbikes'
curl -k -i -H "Content-Type: application/json"\
-H "x-apikey: 560bd47058e7ab1b2648f4e7"\
-X GET 'https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7'
curl -k -i -H "Content-Type: application/json"\
-H "x-apikey: 560bd47058e7ab1b2648f4e7"\
-G 'https://inventory-fac4.restdb.io/rest/motorbikes' -d 'q={"field":"value"}'
curl -k -H "Content-Type: application/json"\
-H "x-apikey: 560bd47058e7ab1b2648f4e7"\
-X POST -d '{"field1":"xyz","field2":"xyz"}' 'https://inventory-fac4.restdb.io/rest/motorbikes'
curl -k -H "Content-Type: application/json"\
-H "x-apikey: 560bd47058e7ab1b2648f4e7"\
-X PUT -d '{"field2":"xyz"}' 'https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7'
curl -k -H "Content-Type: application/json"\
-H "x-apikey: 560bd47058e7ab1b2648f4e7"\
-X DELETE 'https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7'
var settings = {
"async": true,
"crossDomain": true,
"url": "https://inventory-fac4.restdb.io/rest/motorbikes",
"method": "GET",
"headers": {
"content-type": "application/json",
"x-apikey": "560bd47058e7ab1b2648f4e7",
"cache-control": "no-cache"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var jsondata = {"field1": "xyz","field2": "abc"};
var settings = {
"async": true,
"crossDomain": true,
"url": "https://inventory-fac4.restdb.io/rest/motorbikes",
"method": "POST",
"headers": {
"content-type": "application/json",
"x-apikey": "560bd47058e7ab1b2648f4e7",
"cache-control": "no-cache"
},
"processData": false,
"data": JSON.stringify(jsondata)
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var jsondata = {"field1": "new value","field2": "xxx"};
var settings = {
"async": true,
"crossDomain": true,
"url": "https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7",
"method": "PUT",
"headers": {
"content-type": "application/json",
"x-apikey": "560bd47058e7ab1b2648f4e7",
"cache-control": "no-cache"
},
"processData": false,
"data": JSON.stringify(jsondata)
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var settings = {
"async": true,
"crossDomain": true,
"url": "https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7",
"method": "DELETE",
"headers": {
"content-type": "application/json",
"x-apikey": "560bd47058e7ab1b2648f4e7",
"cache-control": "no-cache"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://inventory-fac4.restdb.io/rest/motorbikes");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("x-apikey", "560bd47058e7ab1b2648f4e7");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
var data = JSON.stringify({
"field1": "xyz",
"field2": "xyz"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://inventory-fac4.restdb.io/rest/motorbikes");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("x-apikey", "560bd47058e7ab1b2648f4e7");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
var data = JSON.stringify({
"field2": "new value"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("PUT", "https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("x-apikey", "560bd47058e7ab1b2648f4e7");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("DELETE", "https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("x-apikey", "560bd47058e7ab1b2648f4e7");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
var request = require("request");
var options = {
method: 'GET',
url: 'https://inventory-fac4.restdb.io/appdeploy/motorbikes',
headers:
{ 'cache-control': 'no-cache',
'x-apikey': '560bd47058e7ab1b2648f4e7'
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
var request = require("request");
var options = {
method: 'POST',
url: 'https://inventory-fac4.restdb.io/rest/motorbikes',
headers:
{ 'cache-control': 'no-cache',
'x-apikey': '560bd47058e7ab1b2648f4e7',
'content-type': 'application/json' },
body: { field1: 'xyz', field2: 'abc' },
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
var request = require("request");
var options = {
method: 'PUT',
url: 'https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7',
headers:
{ 'cache-control': 'no-cache',
'x-apikey': '560bd47058e7ab1b2648f4e7',
'content-type': 'application/json' },
body: { field2: 'new value' },
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
var request = require("request");
var options = {
method: 'DELETE',
url: 'https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7',
headers:
{ 'cache-control': 'no-cache',
'x-apikey': '560bd47058e7ab1b2648f4e7',
'content-type': 'application/json'
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
HttpResponse response = Unirest.get("https://inventory-fac4.restdb.io/appdeploy/motorbikes")
.header("x-apikey", "560bd47058e7ab1b2648f4e7")
.header("cache-control", "no-cache")
.asString();
HttpResponse response = Unirest.post("https://inventory-fac4.restdb.io/rest/motorbikes")
.header("content-type", "application/json")
.header("x-apikey", "560bd47058e7ab1b2648f4e7")
.header("cache-control", "no-cache")
.body("{\"field1\":\"xyz\",\"field2\":\"abc\"}")
.asString();
HttpResponse response = Unirest.put("https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7")
.header("content-type", "application/json")
.header("x-apikey", "560bd47058e7ab1b2648f4e7")
.header("cache-control", "no-cache")
.body("{\"field2\":\"new value\"}")
.asString();
HttpResponse response = Unirest.delete("https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7")
.header("content-type", "application/json")
.header("x-apikey", "560bd47058e7ab1b2648f4e7")
.header("cache-control", "no-cache")
.asString();
import requests
url = "https://inventory-fac4.restdb.io/rest/motorbikes"
headers = {
'content-type': "application/json",
'x-apikey': "560bd47058e7ab1b2648f4e7",
'cache-control': "no-cache"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
import requests
import json
url = "https://inventory-fac4.restdb.io/rest/motorbikes"
payload = json.dumps( {"field1": "xyz","field2": "abc"} )
headers = {
'content-type': "application/json",
'x-apikey': "560bd47058e7ab1b2648f4e7",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
import requests
url = "https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7"
payload = "{\"field2\":\"new value\"}"
headers = {
'content-type': "application/json",
'x-apikey': "560bd47058e7ab1b2648f4e7",
'cache-control': "no-cache"
}
response = requests.request("PUT", url, data=payload, headers=headers)
print(response.text)
import requests
url = "https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7"
headers = {
'content-type': "application/json",
'x-apikey': "560bd47058e7ab1b2648f4e7",
'cache-control': "no-cache"
}
response = requests.request("DELETE", url, headers=headers)
print(response.text)
setUrl('https://inventory-fac4.restdb.io/rest/motorbikes');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'x-apikey' => '560bd47058e7ab1b2648f4e7',
'content-type' => 'application/json'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setUrl('https://inventory-fac4.restdb.io/rest/motorbikes');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'x-apikey' => '560bd47058e7ab1b2648f4e7',
'content-type' => 'application/json'
));
$request->setBody('{"field1":"xyz","field2":"abc"}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setUrl('https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7');
$request->setMethod(HTTP_METH_PUT);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'x-apikey' => '560bd47058e7ab1b2648f4e7',
'content-type' => 'application/json'
));
$request->setBody('{"field2":"new value"}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setUrl('https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7');
$request->setMethod(HTTP_METH_DELETE);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'x-apikey' => '560bd47058e7ab1b2648f4e7',
'content-type' => 'application/json'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
var client = new RestClient("https://inventory-fac4.restdb.io/rest/motorbikes");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("x-apikey", "560bd47058e7ab1b2648f4e7");
request.AddHeader("content-type", "application/json");
IRestResponse response = client.Execute(request);
var client = new RestClient("https://inventory-fac4.restdb.io/rest/motorbikes");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("x-apikey", "560bd47058e7ab1b2648f4e7");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"field1\":\"xyz\",\"field2\":\"abc\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var client = new RestClient("https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7");
var request = new RestRequest(Method.PUT);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("x-apikey", "560bd47058e7ab1b2648f4e7");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"field2\":\"new value\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var client = new RestClient("https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7");
var request = new RestRequest(Method.DELETE);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("x-apikey", "560bd47058e7ab1b2648f4e7");
request.AddHeader("content-type", "application/json");
IRestResponse response = client.Execute(request);
#import
NSDictionary *headers = @{ @"content-type": @"application/json",
@"x-apikey": @"560bd47058e7ab1b2648f4e7",
@"cache-control": @"no-cache";
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://inventory-fac4.restdb.io/rest/motorbikes"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
#import
NSDictionary *headers = @{ @"content-type": @"application/json",
@"x-apikey": @"560bd47058e7ab1b2648f4e7",
@"cache-control": @"no-cache" };
NSDictionary *parameters = @{ @"field1": @"xyz",
@"field2": @"abc" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://inventory-fac4.restdb.io/rest/motorbikes"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
#import
NSDictionary *headers = @{ @"content-type": @"application/json",
@"x-apikey": @"560bd47058e7ab1b2648f4e7",
@"cache-control": @"no-cache" };
NSDictionary *parameters = @{ @"field2": @"new value" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https:///inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"PUT"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
#import
NSDictionary *headers = @{ @"content-type": @"application/json",
@"x-apikey": @"560bd47058e7ab1b2648f4e7",
@"cache-control": @"no-cache" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"DELETE"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
import Foundation
let headers = [
"content-type": "application/json",
"x-apikey": "560bd47058e7ab1b2648f4e7",
"cache-control": "no-cache"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://inventory-fac4.restdb.io/rest/motorbikes")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
import Foundation
let headers = [
"content-type": "application/json",
"x-apikey": "560bd47058e7ab1b2648f4e7",
"cache-control": "no-cache"
]
let parameters = [
"field1": "xyz",
"field2": "abc"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://inventory-fac4.restdb.io/rest/motorbikes")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
import Foundation
let headers = [
"content-type": "application/json",
"x-apikey": "560bd47058e7ab1b2648f4e7",
"cache-control": "no-cache"
]
let parameters = ["field2": "new value"] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https:///inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
import Foundation
let headers = [
"content-type": "application/json",
"x-apikey": "560bd47058e7ab1b2648f4e7",
"cache-control": "no-cache"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://inventory-fac4.restdb.io/rest/motorbikes/560bd66201e7ab1b2648f4e7")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()