Skip to content

Latest commit

 

History

History
135 lines (96 loc) · 2.49 KB

api.md

File metadata and controls

135 lines (96 loc) · 2.49 KB

Codebox REST API

Codebox is based on a very simple REST API which allow clients to create boxes from any applications. You can also use a wrapper for the API in Python, Javascript or Ruby.

All the API methods use the header Authorization for authenticate the user.

Create a new box

$ curl -X POST https://api.codebox.io/api/boxes \
   -H "Authorization: <your api token>" \
   -d "name=Test" \
   -d "type=type1" \
   -d "stack=node"

Optional paramters are:

  • description: (string) default is empty
  • git: (string) default is empty
  • public: (boolean) default is false

List Boxes

$ curl -X GET https://api.codebox.io/api/boxes \
   -H "Authorization: <your api token>"

Manage collaborators (for private boxes)

Get the list of collaborators emails:

$ curl -X GET https://api.codebox.io/api/box/<box>/collaborators \
   -H "Authorization: <your api token>"

Add a collaborator by email:

$ curl -X POST https://api.codebox.io/api/box/<box>/collaborators \
   -H "Authorization: <your api token>" \
   -d "[email protected]"

Remove a collaborator by email:

$ curl -X DELETE https://api.codebox.io/api/box/<box>/collaborators \
   -H "Authorization: <your api token>" \
   -d "[email protected]"

Manage a box

Get the information about a box:

$ curl -X GET https://api.codebox.io/api/box/<box> \
   -H "Authorization: <your api token>"

Remove a box:

$ curl -X DELETE https://api.codebox.io/api/box/<box> \
   -H "Authorization: <your api token>"

Events

List events for a boxes:

$ curl -X GET https://api.codebox.io/api/box/<box>/events \
   -H "Authorization: <your api token>"

Activity data

Get box activity:

$ curl -X GET https://api.codebox.io/api/box/<box>/activity \
   -H "Authorization: <your api token>"

Using the node.js library

Create a client:

var Codebox = require("codebox-io").Client;

var client = new Codebox({
	'token': "<api token>"
});

Create a box:

client.create({
	'type': 'type1',
	'name': 'My Node Box',
   'stack': 'python'
}).then(function(box) {
	console.log(box.id," : ", box.name)
});

List boxes:

client.boxes().then(function(boxes) {
	boxes.forEach(function(box) {
		console.log(box.id," : ", box.name)
	})
});

Get a box by its id:

client.box("7546736a-621d-434f-9c10-ad7cd0773a06").then(function(box) {
	console.log(box.id," : ", box.name)
});

Others librairies