Quick start
Quickly get up and running with Everest
Everest.js can be used as a global variable or an AMD module. Either way you first need to install the library in your page.
Installation
Manual install
Download Everest.min.js if, it's not already done, and reference it with jQuery in your page
<script src="/path/to/jquery.min.js"></script>
<script src="/path/to/everest.min.js"></script>
Bower install
Alternatively you can use Bower to download Everest.js
$bower install everest
And then you reference jQuery and Everest from your bower_components path.
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/everest/dist/everest.min.js"></script>
Usage
Once loaded in your page, Everest exports itself as a global variable :
window.everest
or the cooler shortcut window.ê
REST Client
To start querying REST APIs, you need to create a REST client :
// Create a new RestClient. See below for options.
var restClient = ê.createRestClient({
host: "api.github.com", // required
useSSL: true
});
Once the REST client is created, you can start using it :
// Fetch releases from Everest.js github repository
restClient.read("/repos/PulsarBlow/everest.js/releases")
.done(function(response) {
console.log("REST call succeeded", response);
})
.fail(function() {
console.log("REST call failed", arguments);
});
Or update your REST resource :
// To update github api releases, you must be authenticated
// Add authorization header for every requests.
restClient.withHeader("Authorization", "token OAUTH-TOKEN");
// Execute a partial update (PATCH) as required by GitHub API to update releases
restClient.partialUpdate("/repos/PulsarBlow/releases/504659", {
name: "New name for my release tag"
})
.done(function(response) {
console.log("REST call succeeded", response);
})
.fail(function() {
console.log("REST call failed", arguments);
});
And so on... The REST client supports :
- Resource read (GET) :
restClient.read(...)
- Resource read (POST) :
restClient.create(...)
- Resource read (PUT) :
restClient.update(...)
- Resource read (PATCH) :
restClient.partialUpdate(...)
- Resource read (DELETE) :
restClient.remove(...)
REST Client options
Name | Type | Required | Default | Allowed | Description |
---|---|---|---|---|---|
host | string | x | Host for your API. eg. api.github.com | ||
dataFormat | string | json | json, xml, atom, | Data exchange format (content-type) | |
dataEncoding | string | utf-8 | Any encoding | Data exchange encoding | |
useCache | bool | true | true|false | Activate/Deactivate cache for GET/HEAD requests | |
useSSL | bool | false | true|false | Use HTTP or HTTPS |
And much more...
Everest provides much more useful REST and HTTP features.
Read the documentation for a complete features overview.
Everest.min.js
Compiled and minified JavaScript. No docs or original source files are included.