Sugar Network/API
This page describes the API that Sugar Network clients use to interact with Sugar Network server. See also a guide to basic Sugar Network concepts and its twin page from technical point of view. Besides, visit the introduction page.
Overview
To better understand this API, see technical explanation of the conceptual level and objects model in particular.
The API operates with resources that are collections of objects. All objects are identified by global unique identifiers, GUIDs. Resources might support common actions. While processing requests, server might generate events. There are common events that all resources might generate.
The API is RESTful and being served via HTTP(S) using JSON notation. The common RESTful request url format is:
http[s]://<SERVER>/<RESOURCE>[/<GUID|ACTION>[/<ACTION>]]?<AUTH-TOKEN>=<>[&<ARG>=<>]..]
When:
- RESOURCE value is one of existing resources;
- GUID, the RESOURCE's particular object;
- ACTION and a set of ARGs depend on particular RESOURCE.
Besides, particular request can send and receive data in JSON notation. If request processing was failed, the reply is a JSON directory that contains error
key with error message.
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 off-line schools.
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.
Commons
Actions
Actions might be restricted for particular resource, see the corresponding section for detailed information.
POST /<RESOURCE>
Create new RESOURCE object.
Sends:
- Resource properties.
Receives:
guid
, str
globally unique identifier that specifies created object;
PUT /<RESOURCE>/<GUID>
Modify the specified RESOURCE object. By default, might be called only by RESOURCE creator.
Sends:
- Keys that need to be modified.
DELETE /<RESOURCE>/<GUID>
Delete the specified RESOURCE object. The real destroying won't happen, the object will be hidden. The garbage collection of hidden objects will be processed by Network administrators. By default, might be called only by RESOURCE creator.
GET /<RESOURCE>?offset=<>&limit=<>[&request=<PROP>:<VALUE][,...][&query=<>][&properties=<PROP>[,..]][&order_by=[+|-]<PROP>]
Find RESOURCE objects.
Where:
offset
, int
start index to return entries from;limit
, int
do not return more then specified value;request
, dict
search request in key-value pairs;query
, str
search request in Xapian notation with the following additions:- if property is boolean, integer or datetime, it supports searching by ranges:
<PROP>:[<START>]..[<END>]
; - the statement
<PROP>:=["]<VALUE>["]
means(<THE-REST_QUERY>) AND <EXACT-PROP-SEARCH>
with searchingPROP
for exactVALUE
; it is different to regular<PROP>:<VALUE>
whereVALUE
might be a substring of exactPROP
value;
- if property is boolean, integer or datetime, it supports searching by ranges:
properties
, str
coma separated list of RESOURCE properties to return; by default, return onlyguid
property;order_by
, str
property to sort the resulting list by; if starts with the-
, the order is descending, otherwise it is ascending.
Sends:
- A dictionary with RESOURCE's properties to restrict the resulting list.
Receives:
- An array of dictionaries with RESOURCE properties, dictionaries contain at least
guid
property.
- An array of dictionaries with RESOURCE properties, dictionaries contain at least
GET /<RESOURCE>/<GUID>[?properties=<PROP>[,..]]
Return RESOURCE properties the of particular object.
Where:
properties
, str
coma separated list of RESOURCE properties to return; by default, return all properties.
Receives:
- A dictionary with RESOURCE properties that contains at least
guid
property.
- A dictionary with RESOURCE properties that contains at least
Wiki actions
Some of resources have Wiki pages associated. The following actions can be used to manage these Wiki pages.
GET /<RESOURCE>/<GUID>/wikitext
Get the Wiki sources.
Receives:
- Wiki sources with text/plain MIME type.
GET /<RESOURCE>/<GUID>/rendered_wikitext
Get the Wiki rendered to HTML.
Receives:
- Rendered Wiki with text/html MIME type.
PUT /<RESOURCE>/<GUID>/wikitext
Put new content for Wiki page. Only object creator can use it.
Sends:
- Wiki sources with text/plain MIME type.
Events:
type: update
Resources
player
Actions:
- player cannot be created or destroyed;
- player can be updated only by a user who is associated with it.
POST /player/<GUID>/message
Send private message to the player.
Sends:
- A dictionary with event properties.
Events:
- Direct event to the player:
type: message
.
context
Actions:
- right after creation, the creator will be the only team member;
- update and delete actions are allowed only for team members;
- Wiki related actions to manage object description.
POST /project/<GUID/add_member?member=<PLAYER>
Make a PLAYER the team member. Only team members can call this action.
Events:
type: add_member
;memeber: GUID
.
POST /project/GUID/remove_member?member=<PLAYER>
Remove PLAYER from the to the team. Only team member can call this action if he is not the PLAYER and PLAYER is not the same as creator.
Events:
type: remove_member
;memeber: GUID
.
question
Actions:
- Wiki related actions to manage object description.
idea
Actions:
- Wiki related actions to manage object description.
problem
Actions:
- Wiki related actions to manage object description.
review
Actions:
- Wiki related actions to manage object description.
wiki
Actions:
- Wiki related actions to manage Wiki page.
gallery
Actions:
- Wiki related actions to manage object description.
GET /gallery/<GUID>/exhibit
Get the attached object.
Receives:
- Attached object content with application/octet-stream MIME type.
PUT /gallery/<GUID>/exhibit
Put new attached object. Only object creator can use it.
Sends:
- Attached object content with application/octet-stream MIME type.
Events:
type: update
version
Actions:
- Wiki related actions to manage release notes.
report
Actions:
- Only read-only common actions.
PUT /report/<GUID>/logs
Attach logs to the report.
Sends:
- Attached logs with application/octet-stream MIME type.
Events:
type: update
GET /report/<GUID>/logs
Get report attached logs.
Receives:
- Attached logs with application/octet-stream MIME type.
solution
The solution for question/idea/problem objects.
Actions:
- Wiki related actions to manage object description.
comment
event
Actions:
- Only read-only common actions.
Getting involved
- Submit your bug report or feature request.
- Browse our implementation discussions, and post your feedback. (You should join this discussion list in order to avoid having your messages postponed for moderation.)
Changelog
This section shows how API is evolving. The API state is being described by a version. The major number is being changed only if backwards compatibility was broken.
1.0
- Not yet released API.