-
Notifications
You must be signed in to change notification settings - Fork 11
Every time an error occurrs, the response header will match the appropriate HTTP error code. The body of the response will contain an array of errors.
All errors are in the form of:
HTTP 500 Internal Server Error
{
"errors": [String]
}We are using Socket.IO to get live updates to/from the server. To connect from a client, use the same base64 encoded string from above:
io.connect(API_URL + '/namespace', {
query: 'authorization=ENCODED_KEY_TOKEN'
});Authorization is based on namespaces. Each module has its own namespace (e.g. Users = /users). Users that have read access to a module have access to its socket namespace, so look at the GET methods for each module to see what level of access it takes. If a module does not require authentication for read access, then its socket namespace does not require authentication.
All the routes marked with an asterisk before their title can be subscribed to with Socket.IO. Each module/namespace has the following methods: create, update, and delete.
// Listen for new messages
io.on('create', function (message) {
// A new message has been created
console.log(message);
//=> { _id: String, created: Date, text: String }
});
// Listen for updated messages
io.on('update', function (message) {
// A new message has been created
console.log(message);
//=> { _id: String, created: Date, text: String }
});
// Listen for message deletions
io.on('delete', function (message) {
// A message has been deleted
console.log(message);
//=> { _id: String }
});As you can see, the responses you get in your subscriber are exactly the same responses that you get from the standard HTTP requests. Hopefully the API docs will be just as useful for sockets as they are for the REST API :)