ClearRoad API
Install
$ npm install @clearroad/api
Usage
If you want to include the files directly in your page, you can include via our CDN:
<script src="https://clearroadlab.azureedge.net/lib/rsvp.js"></script>
<script src="https://clearroadlab.azureedge.net/lib/jio.js"></script>
<script src="https://clearroadlab.azureedge.net/api/clearroad.js"></script>
Using with es6
import { ClearRoad } from '@clearroad/api';
const cr = new ClearRoad('apiUrl', 'accessToken');
Using with CommonJS
const ClearRoad = require('@clearroad/api').ClearRoad;
const cr = new ClearRoad('apiUrl', 'accessToken');
Using with Node
const ClearRoad = require('@clearroad/api/node').ClearRoad;
const cr = new ClearRoad('apiUrl', 'accessToken');
Using a different local storage
By default, the api will use indexeddb
as local storage. If you want to change the storage (or if you are using node and you need to), you can use:
const cr = new ClearRoad('apiUrl', 'accessToken', {
type: 'dropbox',
accessToken: 'accessToken'
});
The options are:
Type | Description | Options | Support | Need access token |
---|
indexeddb | Native Browser IndexedDB storage | type: string | Browser only | No |
dropbox | Storage data in a dropbox account | type: string, accessToken: string | Browser and Node | Yes |
gdrive | Storage data in a google drive account | type: string, accessToken: string | Browser and Node | Yes |