Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

REST API HTTP INTERFACE

The table below describes the routes that the HTTP interface provides. This HTTP interface is available for all models in Learning Locker.

GET http://www.example.org/api/v2/MODEL_NAME

For example, to get a count of stores via this API, you’d use the following route.

GET http://www.example.org/api/v2/lrs

To access this interface, you must additionally supply your Basic Auth details with each request in the Authorization header. Your Basic Auth details can be found under Settings > Clients.

Method

Description

GET /count

Gets a count of the models.

GET /

Gets a subset of the models.

POST /

Creates a model.

GET /:id

Gets a single model.

PUT /:id

Creates or overwrites a model.

POST /:id

Creates or overwrites a model.

PATCH /:id

Patches a model.

DELETE /:id

Deletes a model.

MODELS

The table below lists the models supported by this interface, you can view the model schemas by clicking the model names.

Name

API Model Name

Description

Activity

activity

Activity with many identifiers.

Client

client

Credentials that access HTTP Interfaces.

Dashboard

dashboard

Customisable grid of visualisations.

Download

download

Record of downloaded exports.

Export

export

Template for exporting statements.

Journey

journey

Journeys visualisation.

Journey Progress

journeyprogress

Journey progress.

Organisation

organisation

Container of clients and stores that a subset of users can access.

Persona

persona

Person with many identifiers and attributes across systems.

Persona Identifier

personaidentifier

Unique xAPI identifier for a persona.

Persona Attribute

personaattribute

Attribute of a persona.

Query

query

Saved filter for statements.

Role

role

Group of permissions for accessing organisation data via users.

Store

store

Container for xAPI data (statements, documents, and attachments).

User

user

Login details for accessing the UI.

Visualisation

visualisation

Graphical view of statements.

ROUTES

GET /COUNT

This route returns a count of the models. A request to this route would look something like the request below.

GET http://www.example.org/api/v2/lrs/count
Authorization: Basic YOUR_BASIC_AUTH

A request like the one above, will respond with a 200 response like the one below containing a count of the models in the body.

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
    "count": 3
}

For more information about the acceptable URL query parameters, view the Restify documentation. Note that the limit parameter will default to 10 if not given and cannot exceed 1,000 if it is given.

Important: In case of User route, query parameter will be ignored and search parameter should be used instead (only available in Enterprise). search query parameter is a simple string and will be transformed into filter shown below.

{
  "$or": [
    { "name": { "$regex": "exampleSearchString", "$options": "i" } },
    { "email": { "$regex": "exampleSearchString", "$options": "i" } }
  ]
}

GET /

This route returns an array of models. A request to this route would look something like the request below.

GET http://www.example.org/api/v2/lrs
Authorization: Basic YOUR_BASIC_AUTH

A request like the one above, will respond with a 200 response like the one below containing the models as JSON in the body. Different models will respond with a different schema, you can view the schemas by clicking the model names in the model table above.

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[
  {
    "createdAt": "2017-08-08T14:35:18.400Z",
    "organisation": "111aaa1111a111111aa11111",
    "statementCount": 987,
    "title": "Example Store",
    "__v": 0,
    "updatedAt": "2017-08-08T14:35:33.721Z",
    "_id": "111aaa1111a111111aa11112"
  }
]

For more information about the acceptable URL query parameters, view the Restify documentation.

Important: In case of User route, query parameter will be ignored and search parameter should be used instead. search query parameter is a simple string and will be transformed into filter shown below.

{
  "$or": [
    { "name": { "$regex": "exampleSearchString", "$options": "i" } },
    { "email": { "$regex": "exampleSearchString", "$options": "i" } }
  ]
}

POST /

This route creates a model. A request to this route would look something like the request below. Different models will require and respond with a different schema, you can view the schemas by clicking the model names in the model table above.

POST http://www.example.org/api/v2/lrs
Authorization: Basic YOUR_BASIC_AUTH
Content-Type: application/json; charset=utf-8

{
  "title": "Example Store"
}

A request like the one above, will respond with a 201 response like the one below containing the created model in the JSON body.

HTTP/1.1 201 CREATED
Content-Type: application/json; charset=utf-8

{
  "createdAt": "2017-08-08T14:35:18.400Z",
  "organisation": "111aaa1111a111111aa11111",
  "statementCount": 0,
  "title": "Example Store",
  "updatedAt": "2017-08-08T14:35:33.721Z",
  "_id": "111aaa1111a111111aa11112",
  "__v": 0
}

GET /:ID

This route returns a single model that has the specified identifier from the URL. A request to this route would look something like the request below.

GET http://www.example.org/api/v2/lrs/111aaa1111a111111aa11112
Authorization: Basic YOUR_BASIC_AUTH

A request like the one above, will respond with a 200 response like the one below containing the model as JSON in the body. Different models will respond with a different schema, you can view the schemas by clicking the model names in the model table above. Note that the request will return a 404 response if the model doesn’t exist.

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "createdAt": "2017-08-08T14:35:18.400Z",
  "organisation": "111aaa1111a111111aa11111",
  "statementCount": 987,
  "title": "Example Store",
  "__v": 0,
  "updatedAt": "2017-08-08T14:35:33.721Z",
  "_id": "111aaa1111a111111aa11112"
}

For more information about the acceptable URL query parameters, view the Restify documentation.

PUT OR POST /:ID

This route creates or updates a single model that has the specified identifier from the URL. A request to this route would look something like the request below. Different models will require and respond with a different schema, you can view the schemas by clicking the model names in the model table above.

PUT http://www.example.org/api/v2/lrs/111aaa1111a111111aa11112
Authorization: Basic YOUR_BASIC_AUTH
Content-Type: application/json; charset=utf-8

{
  "createdAt": "2017-08-08T14:35:18.400Z",
  "organisation": "111aaa1111a111111aa11111",
  "statementCount": 987,
  "title": "Updated Title",
  "updatedAt": "2017-08-08T14:35:33.721Z",
  "_id": "111aaa1111a111111aa11112"
}

A request like the one above, will respond with a 200 response like the one below containing the model as JSON in the body.

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "createdAt": "2017-08-08T14:35:18.400Z",
  "organisation": "111aaa1111a111111aa11111",
  "statementCount": 987,
  "title": "Updated Title",
  "__v": 0,
  "updatedAt": "2017-08-08T14:35:33.721Z",
  "_id": "111aaa1111a111111aa11112"
}

PATCH /:ID

This route patches a single model that has the specified identifier from the URL. A request to this route would look something like the request below. Different models will require and respond with a different schema, you can view the schemas by clicking the model names in the model table above.

PATCH http://www.example.org/api/v2/lrs/111aaa1111a111111aa11112
Authorization: Basic YOUR_BASIC_AUTH
Content-Type: application/json; charset=utf-8

{
  "title": "Patched Title"
}

A request like the one above, will respond with a 200 response like the one below containing the model as JSON in the body.

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "createdAt": "2017-08-08T14:35:18.400Z",
  "organisation": "111aaa1111a111111aa11111",
  "statementCount": 987,
  "title": "Patched Title",
  "__v": 0,
  "updatedAt": "2017-08-08T14:35:33.721Z",
  "_id": "111aaa1111a111111aa11112"
}

DELETE /:ID

This route deletes a single model that has the specified identifier from the URL. A request to this route would look something like the request below.

DELETE http://www.example.org/api/v2/lrs/111aaa1111a111111aa11112
Authorization: Basic YOUR_BASIC_AUTH

A request like the one above, will respond with a 204 response like the one below.

HTTP/1.1 204 NO CONTENT

  • No labels