Talk:Sugar Network/API

From Sugar Labs
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Some basic examples for beginning the implementation of basic client

Browsing a list of contexts

Get the list:

http://localhost/context?offset=0&limit=2&properties=title,description,guid&order_by=-mtime

Default order is by modification time.

This would output an array of dictionaries:

[[{key: value}], total]

For example:

[[{'title':'Actividad Navegar',
   'description':'La actividad navegar...',
   'guid':'SOMEHASH'},
  {'title':'Actividad Escribir',
   'description':'La actividad escribir...',
   'guid':'SOMEOTHERHASH'}], 10]

Browsing questions associated with resources

Get:

http://localhost/question?request=context:SOMEHASH&offset=0&limit=20&properties=title,content,rating,vote,guid&order_by=-mtime

In this example there's only one question associated with this context:

[[{'title':'Se puede añadir un buscador?',
   'content':'Otros navegadores incluyen un buscador...',
   'rating': 0,
   'guid' : 'OTHERHASH',
   'vote': False}], 1]

Modifying a property

Put:

http://localhost/question/OTHERHASH

With sending a dictionary. For instance for voting: {vote: True} (Voting consists only of a boolean, as in +1, or Star)