exoplay-node-sdk
A library for interacting with the exoplay API over javscript. Works with
both node and client-side javascript.
Installation
Usage
The Exoplay API is highly RESTful, and therefore predictable.
- GET gets data based on a query. Most data fields on a resource type are
queryable (refer to exoplay.net API documentaion
for exceptions)
- POST posts new data to a resource type
- PUT replaces data at a given ID
- PATCH merges data changes at a given ID
- DELETE deletes data matching a query or ID
Basic example:
var ExoplayAPI = require('exoplay-node-sdk');
var gameId = 'myawesomegame';
function handleError(error) {
console.log(error.statusCode, error.message);
}
exoplayAPI = new ExoplayAPI('myawesomegame', {
origin: 'https://api.exoplay.net',
defaultErrorHandler: handleError
});
var token = session.get('token');
exoplayAPI.withAuth(token).scopes.get('clan', 'theAwesomeClan', {
role: ['owner', 'manager']
})
.then(function(meta, scopes) {
console.log('There are ' + scopes.length + ' owners or managers.');
})
var myAPI = exoplayAPI.withAuth(token);
myAPI.scopes.get(...);
myAPI.scopes.patch(...);
exoplayAPI.withAuth(token).scopes.put('clan', 'theAwesomeClan', 'ajacksified', 'manager')
.then(function(meta, scopes) {
console.log('Updated self, and got a new token', meta.token);
token = meta.token;
})
.catch(function(error) {
if (error.statusCode === 403) {
console.log('You do not have permissions for that!');
}
});
exoplayAPI.withAuth(token).scopes.post('clan', 'theAwesomeClan', 'ajacksified' {
scope: ['owner', 'manager']
})
.then(function(res) {})
exoplayAPI.withAuth(token).scopes.put('clan', 'theAwesomeClan', 'ajacksified' {
scope: ['owner', 'manager']
})
.then(function(res) {})
exoplayAPI.withAuth(token).scopes.del('clan', 'theAwesomeClan', 'ajacksified', 'owner')
.then(function(res) {})
exoplayAPI.withAuth(token).scopes.del('clan', 'theAwesomeClan', 'ajacksified')
.then(function(res) {})
exoplayAPI.withAuth(token).scopes.del('clan', 'theAwesomeClan', {
userId: [ 'ajacksified', 'doriangray' ]
})
.then(function(res) {})
Per-endpoint documentation is available in ./docs.
Development
- Read the contribution guide and browse existing issues
and PRs for similar changes or issues. If in doubt, create an issue before
writing code. The contribution guide contains guidelines for code standards
and git flow.
- Fork this repository
- Install node (v0.10+)
- Make changes, and add or modify tests where necessary. Run tests
using
npm test
, which runs mocha.
- Create a pull request
License
Copyright 2016 Exoplay, LLC. GPLv3 Licensed. Free for personal or commercial
use. See LICENSE for details.