Difference between revisions of "Sugar Network/API"
Line 7: | Line 7: | ||
The common RESTful url format is: | The common RESTful url format is: | ||
− | http[s]://<SERVER>/<OBJECT>/< | + | http[s]://<SERVER>/<OBJECT>/<FUNCTION>?<AUTH-TOKEN>=<VALUE>[&<ARG>=<VALUE>]..] |
For the beginning, API is not secure for reasons: | For the beginning, API is not secure for reasons: | ||
Line 17: | Line 17: | ||
* API is being provided only via HTTP; | * API is being provided only via HTTP; | ||
− | * The | + | * The ''AUTH-TOKEN'' is the {{Code|uid}} which is a hashed value from Sugar profile public SSH key (the same as JID value in Sugar Shell but without the domain part) that does not require any handshake procedures. |
− | The | + | The ''OBJECT'' value is one of the [[#Objects|following]] objects. When ''FUNCTION'' and a set of ''ARG''s depend on ''OBJECT''. Besides, particular ''FUNCTION'' can input and return data in [[Wikipedia:Json|JSON]] notation. If ''FUNCTION'' was failed, it returns the JSON directory that contains {{Code|error}} key with error message. |
== Objects == | == Objects == |
Revision as of 16:03, 18 December 2011
This page describes the APi that Sugar Network clients use to interact with Sugar Network server. See also technical introduction page.
Overview
The API is RESTful and being served via HTTP(S) using JSON notation.
The common RESTful url format is:
http[s]://<SERVER>/<OBJECT>/<FUNCTION>?<AUTH-TOKEN>=<VALUE>[&<ARG>=<VALUE>]..]
For the beginning, API is not secure for reasons:
- Implement initial version in short period of time;
- The only users, for the beginning, are teachers and students from one-teacher scholls.
In particular:
- API is being provided only via HTTP;
- The AUTH-TOKEN is the
uid
which is a hashed value from Sugar profile public SSH key (the same as JID value in Sugar Shell but without the domain part) that does not require any handshake procedures.
The OBJECT value is one of the following objects. When FUNCTION and a set of ARGs depend on OBJECT. Besides, particular FUNCTION can input and return data in JSON notation. If FUNCTION was failed, it returns the JSON directory that contains error
key with error message.
Objects
The common COMMANDs are:
/create
Create new OBJECT item. Inputs:
ctime
int, the UNIX seconds time of entry creation; optional, will be set on a server side otherwise;mtime
int, the UNIX seconds time of entry modification; optional, will be set on a server side otherwise;
Returns:
guid
str, globally unique identifier that specifies created item;
/update?guid=<>
Modify the specified item.
Inputs:
- Keys that need to be modified.
/delete?guid=<>
Delete the specified item. The real destroying won't happen, the item will be hidden. The garbage collection of hidden items will be processed by Network administrators.
/find?[query=<>][&offset=<>][&limit=<>][&properties=<PROP>[,..]][&order_by=[+|-]<PROP>[,..]]
Find items. Where:
query
str, search request in Xapian notation;offset
int, start index to return entries from;limit
int, do not return more then specified value;properties
str, coma separated list of OBJECT properties to return; by default, return all properties;order_by
str, coma separated list of OBJECT properties to sort the resulting list; if an property starts with the-
, the order is descending, otherwise it is ascending;
Inputs:
- A dictionary with OBJECT's properties to restrict the resulting list.
Returns:
- An array of dictionaries with OBJECT properties, dictionaries contain at least
guid
property.
- An array of dictionaries with OBJECT properties, dictionaries contain at least
/get?guid=<>[&properties=<PROP>[,..]]
Return properties the of particular item. Where:
properties
str, coma separated list of OBJECT properties to return; by default, return all properties.
Returns:
- A dictionary with OBJECT properties that contains at least
guid
property.
- A dictionary with OBJECT properties that contains at least