Xpace Get Documents
Query ID
To query a document by ID. It supports querying multible IDs by adding a comma ( , ) between requested IDs.
URL
https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/
Methods & Params
This method is to query a collection by a single document ID or multible IDs.
Request Method:
GET
Required Params:
id
key can accept one value or multible values seperated by a comma ( , ).appid
key must be presented to access your data. Each project has it's own unique id for different platforms such as "web", "iOS", etc... You must provide the platform key after the appid by seperate them by a colon (:). You can get theappid
from your account's control panel. You can reset one or all keys but you have to update your requests by the new generated keys.type
key must be provided to determain what type of data is needed. Current values aredata
for requesting text data andmedia
for requesting files and images.request
key must be provided to query a specific collection.
headers: { ...
'Content-Type': 'application/json'
... }
body: { ...
id=[string]
appid=[string:string]
type=[string]
request=[string]
... }Optional Params:
- Authorization header is need if the data needed is restricted. Read more about authorization by clicking here
- Groupby key is useful to query multible documents by IDs that have specific key exists regardless of its value.
headers: { ...
'Authorization': 'Bearer <...token...>'
... }
body: { ...
groupby=[string]
... }Success Response:
If the request was accepted and there were results for your query, you'll be getting an array of ojects.
Response Code: 200
Content:{
"success": true
"data": [
{ "key : value" },
{ "key : value" },
...
]
}Error Response:
In case of error response, you'll get a response error code, internal error code and a message explianing the error type.
Response Code: 400, 401 or 406
Content:{
"success": false
"data": {
"Code: [XBGRL0000]"
"Message: ...."
}
}JavaScript Example using jQuery :
// Object in databse { _id: "...", user: { profile: { name: "user name", email: "user email" }, settings: { ... } ... } } function send() { var url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/" var parameters = { id: 'abd123,ce345,...', appid: 'abs23...3cb:web', type: 'data', request: 'settings' } $.ajax({ url: url, type: 'get', dataType: 'json', success: function (data) { console.log(data) }, data: parameters }); } // Result { "success": true, "data": [ { _id: "abd123", "user": { "profile": { name: "user name", email: "user email" }, settings: { ... } ... } }, { _id: "ce345", "user": { "profile": { name: "user name", email: "user email" }, settings: { ... } ... } } ] }
iOS Example using Almofire :
// Object in databse { _id: "...", user: { profile: { name: "user name", email: "user email" }, settings: { ... } ... } } let url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/signup" let parameters: Parameters = [ "id": "abd123,ce345,...", "appid": "abs23...3cb:apple", "type": "data", "request": "settings" ] Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default)
Android Example:
... soon ...
Query Record
To query a document by object key. It supports querying multible records by adding a comma ( , ) between requested keys. It also accepts nested object keys by adding a dash ( - ) between keys.
URL
https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/
Methods & Params
This method is to query a collection by single object key or multible object keys by adding a comma ( , ) between requested keys. You may also query a collection by nested object keys by adding a dash ( - ) between nested keys.
Request Method:
GET
Required Params:
record
key can accept one value or multible values seperated by a comma ( , ). It can also accepts nested values seperated by a dash ( - )appid
key must be presented to access your data. Each project has it's own unique id for different platforms such as "web", "iOS", etc... You must provide the platform key after the appid by seperate them by a colon (:). You can get theappid
from your account's control panel. You can reset one or all keys but you have to update your requests by the new generated keys.type
key must be provided to determain what type of data is needed. Current values aredata
for requesting text data andmedia
for requesting files and images.request
key must be provided to query a specific collection.
headers: { ...
'Content-Type': 'application/json'
... }
body: { ...
record=[string]
appid=[string:string]
type=[string]
request=[string]
... }Optional Params:
- Authorization header is need if the data needed is restricted. Read more about authorization by clicking here
- Groupby key is useful to query multible documents by IDs that have specific key exists regardless of its value.
headers: { ...
'Authorization': 'Bearer <...token...>'
... }
body: { ...
groupby=[string]
... }Success Response:
If the request was accepted and there were results for your query, you'll be getting an array of ojects.
Response Code: 200
Content:{
"success": true
"data": [
{ "key : value" },
{ "key : value" },
...
]
}Error Response:
In case of error response, you'll get a response error code, internal error code and a message explianing the error type.
Response Code: 400, 401 or 406
Content:{
"success": false
"data": {
"Code: [XBGRL0000]"
"Message: ...."
}
}JavaScript Example using jQuery :
// Object in databse { _id: "...", user: { profile: { name: "user name", email: "user email" }, settings: { ... } ... } } function send() { var url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/" var parameters = { record: 'user-profile', appid: 'abs23...3cb:web', type: 'data', request: 'settings' } $.ajax({ url: url, type: 'get', dataType: 'json', success: function (data) { console.log(data) }, data: parameters }); } // Result { "success": true, "data": [ { _id: "abd123", "user": { "profile": { name: "user name", email: "user email" }, settings: { ... } ... } }, { _id: "ce345", "user": { "profile": { name: "user name", email: "user email" }, settings: { ... } ... } } ] }
iOS Example using Almofire :
// Object in databse { _id: "", user: { profile: { name: "user name", email: "user email" } } } let url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/signup" let parameters: Parameters = [ "record": "user-profile", "appid": "abs23...3cb:apple", "type": "data", "request": "settings" ] Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default)
Android Example:
... soon ...
Query Options
To search inside a collection without providing specific ID or object key plus retrieving limited results or in smaller chunks.
URL
https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/
Methods & Params
This method is to query databse based on collection name. If not other options provided, you'll get all results found in that collection. If you want to narrow your query you can use key value pair and retrieve the results matches your query. Results can be retrived in chunks as well as reciving only a limited amount.
Request Method:
GET
Required Params:
appid
key must be presented to access your data. Each project has it's own unique id for different platforms such as "web", "iOS", etc... You must provide the platform key after the appid by seperate them by a colon (:). You can get theappid
from your account's control panel. You can reset one or all keys but you have to update your requests by the new generated keys.type
key must be provided to determain what type of data is needed. Current values aredata
for requesting text data andmedia
for requesting files and images.request
key must be provided to query a specific collection.
headers: { ...
'Content-Type': 'application/json'
... }
body: { ...
appid=[string:string]
type=[string]
request=[string]
... }Optional Params:
Authorization
header is need if the data needed is restricted. Read more about authorization by clicking heregetby
key is useful to query multible documents by key value pair. You can provide one or more key value pairs. Seperate multiblegetby
pairs by commas ( , ).offset
key is useful to divide the result into chunks. This is the best way to retrieve huge ammout of data. This won't work ifmax
key was provided.max
key is useful to get limited amount of documents that matches your query. This won't work ifoffset
key was provided.
headers: { ...
'Authorization': 'Bearer <...token...>'
... }
body: { ...
getby=[string:string]
offset=[number]
... }Success Response:
If the request was accepted and there were results for your query, you'll be getting an array of ojects.
Response Code: 200
Content:{
"success": true
"data": [
{ "key : value" },
{ "key : value" },
...
]
}Error Response:
In case of error response, you'll get a response error code, internal error code and a message explianing the error type.
Response Code: 400, 401 or 406
Content:{
"success": false
"data": {
"Code: [XBGRL0000]"
"Message: ...."
}
}JavaScript Example of all documents in a collection using jQuery :
// Object in databse { _id: "...", user: { profile: { name: "user name", email: "user email" }, settings: { ... } ... } } function send() { var url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/" var parameters = { appid: 'abs23...3cb:web', type: 'data', request: 'settings' } $.ajax({ url: url, type: 'get', dataType: 'json', success: function (data) { console.log(data) }, data: parameters }); } // Result { "success": true, "data": [ { _id: "abd123", "user": { "profile": { name: "user name", email: "user email" }, settings: { ... } ... } }, { _id: "ce345", "user": { "profile": { name: "user name", email: "user email" }, settings: { ... } ... } } ] }
JavaScript Example of querying a collection with
getby
key using jQuery :// Object in databse { _id: "...", user: "First User", email: "email@domain.com" }, { _id: "...", user: "Second User", email: "another@domain.com" } function send() { var url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/" var parameters = { appid: 'abs23...3cb:web', type: 'data', request: 'settings', getby: 'user:First User,email:email@domain.com' } $.ajax({ url: url, type: 'get', dataType: 'json', success: function (data) { console.log(data) }, data: parameters }); } // Result { "success": true, "data": [ { _id: "...", user: "First User", email: "email@domain.com" } ] }
JavaScript Example of all documents in a collection with
offset
key using jQuery :// Object in databse { _id: "...", user: { profile: { name: "user one", email: "email one" }, settings: { ... } ... } }, { _id: "...", user: { profile: { name: "user two", email: "email two" }, settings: { ... } ... } } function send() { var url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/" var parameters = { appid: 'abs23...3cb:web', type: 'data', request: 'settings', offset: 2 } $.ajax({ url: url, type: 'get', dataType: 'json', success: function (data) { console.log(data) }, data: parameters }); } // Result { "success": true, "data": [ { _id: "...", user: { profile: { name: "user two", email: "email two" }, settings: { ... } ... } } ] }
iOS Example using Almofire :
// Object in databse { _id: "", user: { profile: { name: "user name", email: "user email" } } } let url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/signup" let parameters: Parameters = [ "appid": "abs23...3cb:apple", "type": "data", "request": "settings" ] Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default)
Android Example:
... soon ...
Query Media
To request a file or an image.
URL
https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/
Methods & Params
This method is to request a file or an image. If the file requested is an image, you can pass another parameter to get specific size if the image was resized during upload. Size parameter will be ignored if the file type is not an image.
Request Method:
GET
Required Params:
appid
key must be presented to access your data. Each project has it's own unique id for different platforms such as "web", "iOS", etc... You must provide the platform key after the appid by seperate them by acolon (:). You can get theappid
from your account's control panel. You can reset one or all keys but you have to update your requests by the new generated keys.type
key must be provided to determain what type of data is needed. Current values aredata
for requesting text data andmedia
for requesting files and images.request
key must be provided to request a file.
headers: { ...
'Content-Type': 'application/json'
... }
body: { ...
appid=[string:string]
type=[string]
request=[string]
... }Optional Params:
- Authorization header is need if the data needed is restricted. Read more about authorization by clicking here
size
key is useful to download smaller image files as a thumbnail before requesting the full image size.
headers: { ...
'Authorization': 'Bearer <...token...>'
... }
body: { ...
size=[string]
... }Success Response:
If the request was accepted and there were results for your request, you'll be getting a binary streat of the requested file with it's meta type in the response header.
Response Code: 200
Content:Binary data of the requested file.
Error Response:
In case of error response, you'll get a response error code, internal error code and a message explianing the error type.
Response Code: 400, 401 or 406
Content:{
"success": false
"data": {
"Code: [XBGRL0000]"
"Message: ...."
}
}HTML Example using
img
tag// File in storage "folder/file.jpg" // Result ... <img src="https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/?appid=abs23...3cb:web&type=media&request=folder/file.jpg&size=small" /> ...