API
Introduction
The API reference documentation provides detailed information for each of the methods and endpoints of the platform.
The information can be used for reporting, reading collections, and accessing routes on the platform.
We have language bindings in NodeJs, C#, and Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
Getting Started
For application development please refer developer guide.
Platform Library
Print
This code is used to print logs.
Request (HTTP: GET,POST,PUT,DELETE)
This code is used to prepare requests to external API/Endpoints
Fetch All Sub-domains
This code is used to get all domains on the instance
Check For Top Domain
This code is used to check the .
Encryption
This code is used to encrypt text.
Decryption
This code is used to decrypt text.
Publish Via Emma
This code is used publish message to a topic.
Log message
This code is used to log text.
Get Property
This code is used to get property.
Fetch Global Properties
This code is used to fetch all global properties.
Send Email
This code is used to send email.
Send SMS
This code is used to send SMS.
Run Aggregation
This code is used to run DB Aggregation.
Run User Script
This code is used to run user script.
Check If Edu Collection
This code is used to check if the collection belong to EDU domain.
Sign Token
This code is used to sign and return user token.
Database API
Database API is accessible via the global "ob" object as "ob.db".
getCount = function (collection, query, options, _callback)
findDistinct = function (collection, key, query, options, _callback)
findAndModify = function (collection, query, sort, replacement, options, _callback)
findStream = function (tableName, query, options, _eod, _com)
agg = function (collection, agg, _eod, _com)
create = function (tableName, _data, options, _callback)
createMultiple = function (tableName, _data, options, _callback)
update = function (tableName, query, options, options2, options3, _callback)
updateMany = function (collection, query, options, options2, options3, _callback)
listCollections = function (filter, _callback)
readFile = function (fileId, res, opts)
API Query
Querying DB via HTTP Endpoints is really easy and follows a simple key value pair standard.
Example:
Consider a collection name TASK
It has following fields :
Fields
Type
Description
name
text
amount
number
created_on
datetime
manager
reference
Text Queries
Query on single field
oquery=name=Dave Smith
Query on multiple fields
oquery=name=Dave Smith,amount=0
Starts With Query
oquery=name==Dave Smith
Does Not Starts with Query
oquery=name=!=Dave
Contains Query
oquery=name=*Dave
Does Not Contain Query
oquery=name=!*Dave
Number Queries
Equals Than
oquery=amount===0
Greater Than
oquery=amount=>0
Less Than
oquery=amount=<0
Date Queries
Today
oquery=created_on=today
Yesterday
oquery=created_on=yesterday
Day Before Yesterday
oquery=created_on=daybeforeyesterday
Custom
oquery=created_on=#in2018-07
oquery=created_on=on2018-07-15
Plarform Endpoints
Authentication
To obtain an access token, use this code:
Make sure to replace
Username & Password
with your login credentials.
SOFOS uses API keys to allow access to the API. You can register a new SOFOS API key at our developer portal.
SOFOS expects a security tokem to be included in all API requests to the server in a header that looks like the following:
Authorization: Bearer
This endpoint retrieves all kittens.
HTTP Request
POST http://*.obto.co/auth
Query Parameters
Parameter
Default
Description
user_name
NA
Your user name which is used to login
password
NA
Your password which is used to login
Important
Every collection in SOFOS is accessible via a HTTP API.
Example :
https://*.obto.co/o/recs/?stream=true&project=&oquery=
Fetch API
This endpoint retrieves a data from a specified collection.
HTTP Request
GET https://*.obto.co/o/recs/?stream=true&project=&oquery=
URL Parameters
Parameter
Value
Description
stream
true
The ID of the kitten to retrieve
projection
comma seperate list of fields to show
oquery
See API Query Builder
Post API
This endpoint will create a new record in the collection specified
HTTP Request
POST https://*.obto.co/o/
POST Body
Body
Description
Json Data
Data to be posted
Errors
The SOFOS API uses the following error codes:
Error Code
Meaning
400
Bad Request -- Your request is invalid.
401
Unauthorized -- Your API key is wrong.
403
Forbidden -- The kitten requested is hidden for administrators only.
404
Not Found -- The specified kitten could not be found.
405
Method Not Allowed -- You tried to access a kitten with an invalid method.
406
Not Acceptable -- You requested a format that isn't json.
410
Gone -- The kitten requested has been removed from our servers.
418
I'm a teapot.
429
Too Many Requests -- You're requesting too many kittens! Slow down!
500
Internal Server Error -- We had a problem with our server. Try again later.
503
Service Unavailable -- We're temporarily offline for maintenance. Please try again later.
Last updated