Changes

541 bytes added ,  08:56, 27 September 2014
Line 24: Line 24:  
In most cases, the server replies in JSON notation. If a request fails, the replied JSON object will contain a {{Code|request}} key, with the original request, and {{Code|error}} key, with an error message.
 
In most cases, the server replies in JSON notation. If a request fails, the replied JSON object will contain a {{Code|request}} key, with the original request, and {{Code|error}} key, with an error message.
   −
== API servers ==
+
== API version ==
 +
 
 +
Sugar Network nodes might support multiple API versions at once but only one of them is default, i.e., the one which is in use if clients do not specify particular API version. To specify API versions in client request, setup the {{Code|X-API}} HTTP header with chosen version. If such header is omitted, default version will be used by the node;
 +
 
 +
Currently available API versions:
 +
 
 +
* ''0.1'' initial API implementation, should not be used;
 +
* ''0.2'' the most recent version, the rest of the document describes exactly this version.
 +
 
 +
== Nodes ==
    
These are standard Sugar Network API servers publicly available.
 
These are standard Sugar Network API servers publicly available.
   −
* [http://node-devel.sugarlabs.org/ node-devel.sugarlabs.org]<br>Development server which does not contain important data and is free for any experiments (administrative privileges for anonymous users);
+
* [http://node-devel.sugarlabs.org/ node-devel.sugarlabs.org]<br>Development server which does not contain important data and is free for any experiments (administrative privileges for anonymous users); default API version is ''0.2'';
   −
* [http://node-testing.sugarlabs.org/ node-testing.sugarlabs.org]<br>Recent stable release with regular data import from the production server; is still free for any experiments;
+
* [http://node-testing.sugarlabs.org/ node-testing.sugarlabs.org]<br>Recent stable release with regular data import from the production server; is still free for any experiments; default API version is ''0.1'';
    
* [http://node.sugarlabs.org/ node.sugarlabs.org]<br>Production server;
 
* [http://node.sugarlabs.org/ node.sugarlabs.org]<br>Production server;
   −
* [http://localhost:5001/ localhost:5001]<br>default url to get access to [[#Client_API|local proxy]] provided from user side application.
+
* [http://localhost:5001/ localhost:5001]<br>default url to get access to [[#Client_API|local proxy]] provided from user side application; ; default API version is ''0.1''.
   −
== Sugar Network resources ==
+
== Resources ==
    
{{:Sugar_Network/Resources}}
 
{{:Sugar_Network/Resources}}
Line 80: Line 89:  
* {{Code|offset}}, ''int''<br>start index to return entries from, the default value is {{Code|0}};
 
* {{Code|offset}}, ''int''<br>start index to return entries from, the default value is {{Code|0}};
 
* {{Code|limit}}, ''int''<br>do not return more then specified value, maximal and default values are being setup on server side;
 
* {{Code|limit}}, ''int''<br>do not return more then specified value, maximal and default values are being setup on server side;
* {{Code|query}}, ''str''<br>search request in [http://xapian.org/docs/queryparser.html Xapian] notation with the following additions:
+
* {{Code|query}}, ''str''<br>search request in [http://xapian.org/docs/queryparser.html Xapian] notation; if property is boolean, integer or datetime, it supports searching by ranges, i.e., {{Code|''PROP'':[''START'']..[''END'']}};
** if property is boolean, integer or datetime, it supports searching by ranges: {{Code|''PROP'':[''START'']..[''END'']}};
  −
** the statement {{Code|''PROP''<nowiki>:=</nowiki>["]''VALUE''["]}} has the same effect as {{Code|QUERY_PROP}}; it is different to regular {{Code|''PROP'':''VALUE''}} where {{Code|VALUE}} might be a substring;
   
* {{Code|PROP}}, ''str''<br>supplements {{Code|query}} with filtering by exact value of the {{Code|PROP}} property; the resulting query string will be {{Code|''PROP''<nowiki>=</nowiki>''VALUE'' AND (''QUERY'')}}; argument is multiple;
 
* {{Code|PROP}}, ''str''<br>supplements {{Code|query}} with filtering by exact value of the {{Code|PROP}} property; the resulting query string will be {{Code|''PROP''<nowiki>=</nowiki>''VALUE'' AND (''QUERY'')}}; argument is multiple;
 
* {{Code|!PROP}}, ''str''<br>supplements {{Code|query}} by excluding exact value of the {{Code|PROP}} property; the resulting query string will be {{Code|NOT ''PROP''<nowiki>=</nowiki>''VALUE'' AND (''QUERY'')}}; argument is multiple;
 
* {{Code|!PROP}}, ''str''<br>supplements {{Code|query}} by excluding exact value of the {{Code|PROP}} property; the resulting query string will be {{Code|NOT ''PROP''<nowiki>=</nowiki>''VALUE'' AND (''QUERY'')}}; argument is multiple;
Line 104: Line 111:  
JSON object keys to receive:
 
JSON object keys to receive:
 
* properties that were specified in {{Code|reply}} argument(s), at least {{Code|guid}}.
 
* properties that were specified in {{Code|reply}} argument(s), at least {{Code|guid}}.
 +
 +
<div id="PUT-property"></div>
 +
 +
'''PUT''' /''RESOURCE''/''GUID''/''PROP''
 +
 +
Modify particular resource property. By default, might be called only by {{Code|GUID}} creator.
    
<div id="GET-property"></div>
 
<div id="GET-property"></div>
Line 203: Line 216:  
   "org.laptop.TurtleArtActivity": {
 
   "org.laptop.TurtleArtActivity": {
 
     "title": "Turtle Blocks",
 
     "title": "Turtle Blocks",
     "version": [[202], 0],
+
     "version": "202",
 
     "blob": "http://download.sugarlabs.org/activities/4027/turtleblocks-202.xo",
 
     "blob": "http://download.sugarlabs.org/activities/4027/turtleblocks-202.xo",
 
     "content-type": "application/vnd.olpc-sugar",
 
     "content-type": "application/vnd.olpc-sugar",
 
     "size": 4715955,
 
     "size": 4715955,
 
     "unpack_size": 12873871,
 
     "unpack_size": 12873871,
     "command": ["activity", "sugar-activity TurtleArtActivity.TurtleArtActivity"],
+
     "command": "sugar-activity TurtleArtActivity.TurtleArtActivity",
 
   },
 
   },
 
   "sugar": {
 
   "sugar": {
     "version": [[0, 94], 0],
+
     "version": "0.94",
 
   },
 
   },
 
  }
 
  }