API Specification Doc
(Mophil storage )
docs in Google drive
Version | Date | Author | Description |
1.0 | 30-Dec-2017 | S.Kobs (mophil.co) | Initial draft |
Index
Methods
Register and Authenticate the user with the system and obtain the token
Method | URL |
GET/POST | <url>/ |
Type | Params | Values |
string string string | method pass | register_user <login> <password> |
string | You can add any additional parameters. All the parameters will be added to the user object. |
http://api.example.com/?method=register_user&name=rokky&surname=boom&email=user@email.com&pass=123
Status | Response |
200 | { "result": [ { "Name":"rokky", "email":"user@email.com", "Cr_time":1515000164, "Internal_id":"5a4d1164ddf3b" } ], "token":"84e0d8236c58d557b7d9f0844e99d369", "ltime":1515000164 } token (string) - all further autorised API calls must include this token as a parameter |
200 | {"error":"User already register."} |
Authenticate the user with the system and obtain the token
Method | URL |
GET/POST | <url>/?method=login_user |
Type | Params | Values |
string string string | method pass | login_user <login> <password> |
Status | Response |
200 | { "result": [ { "cr_time":1515000164, "email":"user@email.com", "internal_id":"5a4d1164ddf3b", "last_login":1515000648, "name":"rokky" } ], "ltime":1515000662, "token": <token> } token (string) - all further authorised API calls must include his token as a parameter |
200 | {"error":"Invalid Login Details"} |
Add new data
Method | URL |
GET/POST | <url>/?method=save_data |
Type | Params | Values |
string string string | method collection token | save_data <collection name> <token> |
string | You can add any additional parameters. All the parameters will be added to the data object. |
token
The token that was given in response to login_user
http://api.example.com/?method=save_data&domain=1stDomain&collection=domains&token=123
Status | Response |
200 | Response will be an object containing the saved object and internal_id of the object. { "result": { "domain":"1stDomain", "Collection":"domains", "cr_time":1515010732, "internal_id":"5a4d3aac942fb" } } |
200 | {"error":"invalid token."} {"error":"method missing"} |
Select necessary data
Method | URL |
GET/POST | <url>/?method=get_data |
Type | Params | Values |
string string string | method Collection token | get_data <collection name> <token> |
string | You can add any additional parameters witch selected object should have. |
http://api.example.com/?method=get_data&domain=1stDomain&collection=domains
Simple search
http://api.example.com/?method=get_data&domain=1stDomain&collection=domains
Search with regex
http://api.example.com/?method=get_data&domain[$regex]=1st&collection=domains
Search with or
Search with in
Status | Response |
200 | An array containing objects according to the search request { "result": [ { "domain":"1stDomain", "cr_time":1515009508, "internal_id":"5a4d35e4de0ad" }, { "domain":"1stDomain", "cr_time":1515010732, "internal_id":"5a4d3aac942fb" }, ] } Or an empty array |
200 | {"error":"invalid token."} {"error":"method missing"} |
Delete data
Method | URL |
GET/POST | <url>/?method=delete_data |
Type | Params | Values |
string string string string | method Collection token internal_id | delete_data <collection name> <token> <object internal id> |
token
The token that was given in response to login_user
internal_id
The internal_id that was given in response to get_data
Status | Response |
200 | {"result":true} |
200 | {"error":"invalid token."} {"error":"error","error_message":"invalid parameters"} |
Update data
Method | URL |
GET/POST | <url>/?method=update_data |
Type | Params | Values |
string string string string | method Collection token internal_id | update_data <collection name> <token> <object internal id> |
string | You can add any additional parameters which needed to be changed or added to the object. |
token
The token that was given in response to login_user
internal_id
The internal_id that was given in response to get_data
Status | Response |
200 | {"result":true} |
200 | {"error":"invalid token."} {"error":"error","error_message":"invalid parameters"} |
Glossary
Status code 200 will be returned all the time except a cases of server error.
Please parse the response to find the error message.
2XX - Success of some kind
4XX - Error occurred in client’s part
5XX - Error occurred in server’s part