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

Conventions

Status Codes


Methods

1. Register

Register and Authenticate the user with the system and obtain the token

Request

Method

URL            

GET/POST

<url>/

Type

Params

Values

string

string

string

method

email

pass

register_user

<login>

<password>

string

You can add any additional parameters. All the parameters will be added to the user object.

Example (GET):

http://api.example.com/?method=register_user&name=rokky&surname=boom&email=user@email.com&pass=123

Response

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."}

{"
error":"error","error_message":"invalid parameters"}

2. login

Authenticate the user with the system and obtain the token

Request

Method

URL            

GET/POST

<url>/?method=login_user

Type

Params

Values

string

string

string

method

email

pass

login_user

<login>

<password>

Example (GET):

http://api.example.com/?method=login_user&email=user@email.com&pass=123

Response

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"}

{"
error":"error","error_message":"invalid parameters"}

3. Save data

Add new data

Request

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

Example (GET):

http://api.example.com/?method=save_data&domain=1stDomain&collection=domains&token=123

Response

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"}

3. Get data

Select necessary data

Request

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.

Examples (GET):

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

http://api.example.com/?method=get_data&$or[][domain]=1stDomain&$or[][domain]=2ndDomain&collection=domains

Search with in

http://api.example.com/?method=get_data&domain[$in][]=1stDomain&domain[$in][]=2ndDomain&collection=domains

Response

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
{"result":[]}

200

{"error":"invalid token."}

{"error":"method missing"}

4. Delete data

Delete data

Request

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

Response

Status

Response

200

{"result":true}

200

{"error":"invalid token."}

{"error":"error","error_message":"invalid parameters"}

5. Update data

Update data

Request

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

Example (GET):
http://api.example.com/?method=update_data&domain=1!!stDomain&collection=domains&internal_id=5a4d3aac942fb&token=123

Response

Status

Response

200

{"result":true}

200

{"error":"invalid token."}

{"error":"error","error_message":"invalid parameters"}


Glossary

Conventions

Status Codes

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