Difference between revisions of "Sugar Network/API"
Line 22: | Line 22: | ||
== Objects == | == Objects == | ||
+ | |||
+ | The common ''COMMAND''s are: | ||
+ | |||
+ | /'''create''' | ||
+ | |||
+ | Create new ''OBJECT'' item. | ||
+ | Inputs: | ||
+ | :* {{Code|ctime}} ''int'', the UNIX seconds time of entry creation; optional, will be set on a server side otherwise; | ||
+ | :* {{Code|mtime}} ''int'', the UNIX seconds time of entry modification; optional, will be set on a server side otherwise; | ||
+ | Returns: | ||
+ | :* {{Code|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=<[<nowiki>[+|-]</nowiki><PROP>[,..]] | ||
+ | |||
+ | Find items. | ||
+ | Where: | ||
+ | :* {{Code|query}} ''str'', search request in [http://xapian.org/docs/queryparser.html Xapian] notation; | ||
+ | :* {{Code|offset}} ''int'', start index to return entries from; | ||
+ | :* {{Code|limit}} ''int'', do not return more then specified value; | ||
+ | :* {{Code|properties}} ''str'', coma separated list of ''OBJECT'' properties to return; by default, return all properties; | ||
+ | :* {{Code|order_by}} ''str'', coma separated list of ''OBJECT'' properties to sort the resulting list; if an property starts with the {{Code|-}}, 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 {{Code|guid}} property. | ||
+ | |||
+ | /'''get'''?guid=<>[&properties=<PROP>[,..]] | ||
+ | |||
+ | Return properties the of particular item. | ||
+ | Where: | ||
+ | :* {{Code|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 {{Code|guid}} property. | ||
=== Player === | === Player === |
Revision as of 09:51, 18 December 2011
This page describes the APi that Sugar Network clients use to interact with Sugar Network server. See also the introduction page and technical overview.
Overview
The API is RESTful and being served via HTTP(S) using JSON notation.
The common RESTful url format is:
http[s]://<SERVER>/<OBJECT>/<COMMAND>?<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 theuid
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 COMMAND
and a set of ARG
s depend on OBJECT
. Besides, particular COMMAND
can input and return data in JSON notation. If COMMAND
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