API v3 (candidate)
I'm posting this now, as a WIP, so it's at least out there, rather than sitting on my machine. Feel free to ignore, or dig in and tell me it's all wrong before it gets too late!
Introduction
This documentation describes a candidate for the Open Badger API (OBr), version 3. This version of the API takes lessons learned from both previous versions, uniting them into into a more rounded, general purpose suite.
Security Model
[TO DO]
Data
Issuers
[TO DO] This is not complete.
name
- the name of the issuer. Required when creating new issuers. Will be present in all relevant requests.
shortname
- the issuer's slug, as used in API requests. Not allowed when creating new issuers (inferred from URL).
url
- the issuer's URL.
image
- a URL pointing at a graphical representation of the issuer.
strapline
- a short, one-line description of the issuer.
description
- a longer description of the issuer. Required when creating new issuers. May contain HTML.
location
- the canonical location of the issuer in the API. Not allowed when creating new issuers (inferred). Will be present in all relevant requests.
meta
- a meta object.
Examples
Creating
POST /v3/data/example-issuer
{
"name": "Example Issuer",
"strapline": "The best issuer in the world!",
"description": "Example Issuer is strategically involved in issuing cutting edge badges, using the badging paradigm to think outside the box for a win-win situation."
}
Retrieving
GET /v3/data/example-issuer
{
"name": "Example Issuer",
"shortname": "example-issuer",
"url": "http://example.org",
"image": "http://example.org/media/images/logo.png",
"strapline": "The best issuer in the world!",
"description": "Example Issuer is strategically involved in issuing cutting edge badges, using the badging paradigm to think outside the box for a win-win situation.",
"location": "/v3/data/example-issuer"
}
Programs
[TO DO] This is probably not complete.
name
- the name of the program. Required when creating new programs. Will be present in all relevant requests.
shortname
- the program's slug, as used in API requests. Not allowed when creating new programs.
url
- the program's URL.
image
- a URL pointing at a graphical representation of the program.
strapline
- a short, one-line description of the program.
description
- a longer description of the program. Required when creating new programs. May contain HTML.
location
- the canonical location of the program in the API. Not allowed when creating new programs. Will be present in all relevant requests.
issuer
- an abbreviated Issuer object, describing the issuer associated with this program. Not allowed when creating new programs.
meta
- a Meta object.
Examples
Creating
POST /v3/data/example-issuer/example-program
{
"name": "Example Program",
"strapline": "The best program ever!",
"description": "Example Issuer is running the Example Program to disrupt the core competencies of the badging space.",
}
Retrieving
GET /v3/data/example-issuer/example-program
{
"name": "Example Program",
"shortname": "example-program",
"url": "http://example.org/programs/example",
"image": "http://example.org/media/images/programs/example.png",
"strapline": "The best program ever!",
"description": "Example Issuer is running the Example Program to disrupt the core competencies of the badging space.",
"location": "/v3/data/example-issuer/example-program",
"issuer": {
"name": "Example Issuer",
"location": "/v3/data/example-issuer"
}
}
Badges
[TO DO] This is probably not complete.
name
- the name of the badge. Required when creating new programs. Will be present in all relevant requests.
shortname
- the badge's slug, as used in API requests. Not allowed when creating new badges.
url
- the badge's URL.
image
- a URL pointing at a graphical representation of the badge. Required when creating new badges. Must be a PNG.
strapline
- a short, one-line description of the badge.
description
- a longer description of the badge. Required when creating new badges. May contain HTML.
criteria
- a description of what an earner should be able to do having been awarded this badge. May contain HTML.
location
- the canonical location of the badge in the API. Not allowed when creating new badges. Will be present in all relevant requests.
issuer
- an abbreviated Issuer object, describing the issuer associated with this badge. Not allowed when creating new badges.
program
- an abbreviated Program object, describing the program associated with this badge. Not allowed when creating new badges.
meta
- a Meta object.
Examples
Creating
POST /v3/data/example-issuer/example-program/example-badge
{
"name": "Example Badge",
"url": "http://example.org/programs/example/badges/example",
"image": "http://example.org/media/images/badges/example.png",
"strapline": "A truly awesome badge",
"description": "Ensuring deferred success to take it to the next level."
}
Retrieving
GET /v3/data/example-issuer/example-program/example-badge
{
"name": "Example Badge",
"shortname": "example-badge",
"url": "http://example.org/programs/example/badges/example",
"image": "http://example.org/media/images/badges/example.png",
"strapline": "A truly awesome badge",
"description": "Ensuring deferred success to take it to the next level."
"criteria": "",
"location": "/v3/data/example-issuer/example-program/example-badge",
"issuer": {
"name": "Example Issuer",
"location": "/v3/data/example-issuer"
},
"program": {
"name": "Example Program",
"location": "/v3/data/example-issuer/example-program"
},
"meta": {...}
}
Meta
A namespaced JSON data blob, with optional schemas.
{
"csol": {
"tags": ["13-18", "S", "T", "online"],
"ageRange": ["0-13", "13-18"],
"type": "skill",
"activityType": "online"
},
"geo": {
"$schema": "http://json-schema.org/geo",
"latitude": 51.507222,
"longitude": -0.1275
}
}
Global Response Information
Parameters
Every API request will have the following response parameters in common:
status
- Status of the request. If the request is good, contains the literal string "ok". If the request is bad for any reason, contains the literal string "error".
error
- If the request is bad for any reason, contains details of the error:
message
- A human readable message describing the error.
code
- A code representing the type of error.
For paginatable requests, the following response parameters are also shared:
page
- The page being returned.
pages
- The number of available pages.
pageSize
- The number of results being returned per page.
total
- The total number of results available.
previous
- URL pointing to previous page of results, if that page exists.
next
- URL pointing to next page of results, if that page exists.
Headers
For paginatable requests, the following response headers are provided:
Link: <URL>; rel=previous
(where a previous page exists).
Link: <URL>; rel=next
(where a next page exists).
Endpoints
/v3/data/:issuer
-
GET
Get information about an issuer.
-
Response Statuses:
200: OK
- If the issuer is found.
404: Not Found
- If the issuer is not found.
-
Response Parameters:
-
Example:
{
"status": "ok",
"issuer": {
"name": "Example Issuer",
"shortname": "example-issuer",
"url": "http://example.org",
"image": "http://example.org/media/images/logo.png",
"strapline": "The best issuer in the world!",
"description": "Example Issuer is strategically involved in issuing cutting edge badges, using the badging paradigm to think outside the box for a win-win situation.",
"location": "/v3/data/example-issuer"
}
}
-
POST
Create a new issuer.
- Response Statuses:
201: Created
- If the issuer was successfully created.
400: Bad Request
- If the request body does not contain a valid Issuer object.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to create an issuer.
409: Conflict
- If the issuer already exists.
- Response Parameters:
- Example:
-
PUT
Create or replace an issuer.
- Response Statuses:
200: OK
- If the issuer was successfully updated.
201: Created
- If the issuer was successfully created.
400: Bad Request
- If the request body does not contain a valid Issuer object.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to create an issuer.
- Response Parameters:
-
PATCH
Update an issuer.
- Response Statuses:
200: OK
- If the issuer was successfully updated.
400: Bad Request
- If the request body does not contain a valid Issuer patch.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to update this issuer.
404: Not Found
- If the requested issuer does not exist.
- Response Parameters:
-
DELETE
Delete an issuer.
- Response Statuses:
200: OK
- If the issuer was successfully deleted.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to delete this issuer.
404: Not Found
- If the requested issuer does not exist.
- Response Parameters:
/v3/data/:issuer/:program
-
GET
Get information about a program.
-
Response Statuses:
200: OK
- If the program is found.
404: Not Found
- If the program is not found.
-
Response Parameters:
program
- Program object.
-
Example:
{
"status": "ok",
"program": {
"name": "Example Program",
"shortname": "example-program",
"url": "http://example.org/programs/example",
"image": "http://example.org/media/images/programs/example.png",
"strapline": "The best program ever!",
"description": "Example Issuer is running the Example Program to disrupt the core competencies of the badging space.",
"location": "/v3/data/example-issuer/example-program",
"issuer": {
"name": "Example Issuer",
"location": "/v3/data/example-issuer"
}
}
}
-
POST
Create a new program.
- Response Statuses:
201: Created
- If the program was successfully created.
400: Bad Request
- If the request body does not contain a valid Program object.
401: Unauthorized
** - If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to create an program for this issuer.
409: Conflict
- If the program already exists.
- Response Parameters:
-
PUT
Create or replace a program.
- Response Statuses:
200: OK
- If the program was successfully updated.
201: Created
- If the program was successfully created.
400: Bad Request
- If the request body does not contain a valid Program object.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
** - If the requesting client is not authorised to create an program for this issuer.
- Response Parameters:
-
PATCH
Update a program.
- Response Statuses:
200: OK
- If the program was successfully updated.
400: Bad Request
- If the request body does not contain a valid Program patch.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to update this program.
404: Not Found
- If the requested program does not exist.
- Response Parameters:
-
DELETE
Delete an program.
- Response Statuses:
200: OK
- If the program was successfully deleted.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to delete this program.
404: Not Found
- If the requested program does not exist.
- Response Parameters:
/v3/data/:issuer/:program/:badge
-
GET
Get information about a badge.
-
Response Statuses:
200: OK
- If the badge is found.
404: Not Found
- If the badge is not found.
-
Response Parameters:
-
Example:
{
"status": "ok",
"badge": {
"name": "Example Badge",
"shortname": "example-badge",
"url": "http://example.org/programs/example/badges/example",
"image": "http://example.org/media/images/badges/example.png",
"strapline": "A truly awesome badge",
"description": "Ensuring deferred success to take it to the next level.",
"criteria": "",
"location": "/v3/data/example-issuer/example-program/example-badge",
"issuer": {
"name": "Example Issuer",
"location": "/v3/data/example-issuer"
},
"program": {
"name": "Example Program",
"location": "/v3/data/example-issuer/example-program"
},
"meta": {...}
}
}
-
POST
Create a new badge.
- Response Statuses:
201: Created
- If the badge was successfully created.
400: Bad Request
- If the request body does not contain a valid Badge object.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to create a badge for this program.
409: Conflict
- If the badge already exists.
- Response Parameters:
-
PUT
Create or replace a badge.
- Response Statuses:
200: OK
- If the badge was successfully updated.
201: Created
- If the badge was successfully created.
400: Bad Request
- If the request body does not contain a valid Badge object.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to create a badge for this program.
- Response Parameters:
-
PATCH
Update a badge.
- Response Statuses:
200: OK
- If the badge was successfully updated.
400: Bad Request
- If the request body does not contain a valid Badge patch.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to update this badge.
404: Not Found
- If the requested badge does not exist.
- Response Parameters:
-
DELETE
Delete an issuer.
- Response Statuses:
200: OK
- If the issuer was successfully deleted.
401: Unauthorized
- If the requesting client is not authenticated.
403: Forbidden
- If the requesting client is not authorised to delete this badge.
404: Not Found
- If the requested badge does not exist.
- Response Parameters:
/v3/data/:issuer/:program/:badge/recommendations
-
GET
Get a list of recommended "next badges" based on the categories of another badge
/v3/data/:issuer/:program/:badge/claimcodes
-
GET
Get a list of claim codes available for this badge
-
POST
Create new claim codes for this badge
/v3/data/:issuer/:program/:badge/claimcodes/random
/v3/data/:issuer/:program/:badge/user
/v3/claim
/v3/user
/v3/user/recommendations
/v3/issuers
-
GET (Paginatable)
Get information about existing issuers.
-
Request Parameters:
search
- A query string to filter the returned results. "Likeness" is determined by generating a case-insensitive, unbounded regexp, and is compared against issuer name and description.
limit
- The number of issuers to return per page. Defaults to 10
. Pass 0
to get all issuers.
page
- The page to return, based on limit
. Defaults to 1
.
-
Response Statuses:
200: OK
- If the request is good.
404: Not Found
- If the requested page is not available, due to being out of bounds.
-
Response Parameters:
issuers
- List of abbreviated (?) Issuer objects.
[TO DO] How extensive to we want these results to be?
-
Example:
{
"status": "ok",
"issuers": [
{
"name": "Example Issuer",
"location": "/v3/data/example-issuer"
}
],
"page": 1,
"pages": 1,
"pageSize": 10,
"total": 1
}
/v3/issuers/:issuer
-
GET
Get canonical URL for an issuer. Somewhat redundant, but serves as a parallel to equivalent program and badge options.
-
Response Statuses:
303: See Other
- Redirect to /v3/data/:issuer
, if the issuer exists.
404: Not Found
- If the issuer does not exist.
-
Response Parameters:
location
- If the issuer exists, the canonical URL for that issuer.
-
Example:
{
"status": "ok",
"location": "/v3/data/example-issuer"
}
/v3/programs
-
GET (Paginatable)
Get information about existing programs.
-
Request Parameters:
search
- A query string to filter the returned results. "Likeness" is determined by generating a case-insensitive, unbounded regexp, and is compared against program name and description
issuer
- An issuer shortname to filter the returned results.
limit
- The number of programs to return per page. Defaults to 10
. Pass 0
to get all badges.
page
- The page to return, based on limit
.
-
Response Statuses:
200: OK
- If the request is good.
404: Not Found
- If the requested page is not available, either due to being out of bounds, or because the issuer does not exist.
-
Response Parameters:
programs
- List of abbreviated (?) Program objects.
[TO DO] How extensive to we want these results to be?
-
Example:
{
"status": "ok",
"programs": [
{
"name": "Example Program",
"location": "/v3/data/example-issuer/example-program"
}
],
"page": 1,
"pages": 1,
"pageSize": 10,
"total": 1
}
/v3/programs/:program
-
GET
Get canonical URL for a program.
-
Response Statuses:
300: Multiple Choices
- If multiple programs matching the program are found.
303: See Other
- Redirect to /v3/data/:issuer/:program
, if the program exists.
404: Not Found
- If the program does not exist.
-
Response Parameters:
location
- If the program exists and is unique, the canonical URL for that program.
options
- If the program exists but is not unique, an array of potential matches.
[TO DO] - what do these options look like?
-
Example:
{
"status": "ok",
"location": "/v3/data/example-issuer/example-program"
}
/v3/badges
-
GET (Paginatable)
Get information about existing badges.
-
Request Parameters:
search
- A query string to filter the returned results. "Likeness" is determined by generating a case-insensitive, unbounded regexp, and is compared against badge name and description.
issuer
- An issuer shortname to filter the returned results.
program
- A program shortname to filter the returned results.
limit
- The number of badges to return per page. Defaults to 10
. Pass 0
to get all badges.
page
- The page to return, based on limit
.
-
Response Statuses:
200: OK
- If the request is good.
404: Not Found
- If the requested page is not available, either due to being out of bounds, or because the issuer
or program
does not exist.
-
Response Parameters:
badges
- List of abbreviated (?) Badge objects.
[TO DO] How extensive to we want these results to be?
-
Example:
{
"status": "ok",
"badges": [
{
"name": "Example Badge",
"location": "/v3/data/example-issuer/example-program/example-badge"
}
],
"page": 1,
"pages": 1,
"pageSize": 10,
"total": 1
}
/v3/badges/:badge
-
GET
Get canonical URL for a badge.
-
Response Statuses:
300: Multiple Choices
- If multiple badges are found.
303: See Other
- Redirect to /v3/data/:issuer/:program/:badge
, if the badge exists.
404: Not Found
- If the badge does not exist.
-
Response Parameters:
location
- If the badge exists and is unique, the canonical URL for that badge.
options
- If the badge exists and is not unique, an array of potential matches.
[TO DO] - what do these options look like?
-
Example:
{
"status": "ok",
"location": "/v3/data/example-issuer/example-program/example-badge"
}