Skip to content

API Documentation

armontoya edited this page Mar 13, 2012 · 33 revisions

The goal is to provide a RESTful API utilizing HTTP methods as much as possible for basic operations. This page will be updated as the API becomes further defined.

POST /api/create/content

Creates a learning content object and stores it in the LCR.

Request Body:

{
   "title": "<string>", // required
   "description" : "<string>",  //optional,
   "tags" : ["<string1>", "<string2>", ...] // optional
}

Returns:

{
   "id" : "<string>", // the unique identifier for the new object, present only on success
   "error" : "<string>", // the error message, present only if something goes wrong
}

POST /api/create/file/{id}

Adds a new file and associates it to an existing Learning Object.

Parameters:

  • id - the unique identifier for the learning content object the file is to be associated with.

Request Body: the raw file data.

Returns:

{
   "id" : "<string>", // the unique identifier for the new object, present only on success
   "error" : "<string>", // the error message, present only if something goes wrong
}

GET /api/content/{id}

Fetches the metadata associated with a learning content object.

Parameters:

  • id - the unique identifier for the learning content object the file is to be associated with.

Returns:

{
   "title": "<string>", // the title of the learning object
   "description" : "<string>",  // a short description (140 chars max) of the learning content,
   "tags" : ["<string1>", "<string2>", ...], // tags describing the object
   "resources" : ["<string1>", "<string2>", ...], // an array of resource IDs associated with this object
}

GET /api/resource/{id}?metadata={true|false}

Fetches a resource or its associated metadata.

Parameters:

  • metadata ( true|false, default false) - specifies whether the metadata is to be returned instead of the actual content

Returns:

Default behavior (metadata omitted or false) is to return the resource itself, according to the following rules:

  • If the resource is a url, then a redirect will be performed to fetch the content of the requested resource (similar to how Google handles a clickthrough on a search results page). It is yet to be determined if the server will act as a proxy to the resource or whether it will issue some 300-like status code to redirect the request, depending on the compatibility of expected consumer technologies.
  • If the resource is a file, then return the file raw file data as stored in the repository.

If metadata is set to true, then any available metadata associated with the resource will be returned as JSON. Currently, all resources have the following attributes:

{
   "id" : "<string>", // The unique identifier for this metadata object
   "name" : "<string>", // The title of the resource. Defaults to filename for files and pagename for urls if unspecified.
   "type" : "{url|file}", // The type of the resource data. Used to check for additional attributes
}

Additionally, the following parameters are specified for resources of type file:

{
   "gridFsId" : "<string>" // The id for the actual file stored in the distributed file system
}

Finally, the following parameters are provided for resources of type url:

{
   "url" : "<url>" // The original url specified by the user
}

Clone this wiki locally