https://github.com/botify-labs/botify-sdk-js
https://github.com/botify-labs/botify-sdk-js
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/botify-labs/botify-sdk-js
- Owner: botify-labs
- Created: 2016-01-08T16:05:16.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-03T17:42:27.000Z (almost 10 years ago)
- Last Synced: 2025-09-14T11:50:30.323Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 72.3 KB
- Stars: 4
- Watchers: 14
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# botify-sdk
[](https://www.npmjs.com/package/botify-sdk)
[](https://travis-ci.org/botify-labs/botify-sdk-js)
This package contains the Javascript SDK for Botify API.
API documentation can be found at [https://developers.botify.com/api/](https://developers.botify.com/api/).
**SDK Demo:** [link](https://jsfiddle.net/8k20pbua/12/)
## Installation
### Node.js, Webpack, Browserify
```SH
npm install --save botify-sdk@1.0.0-beta5
```
```JS
var BotifySDK = require('botify-sdk');
BotifySDK.authToken(token);
BotifySDK.AnalysisController.getAnalysisSummary({
username: 'foo',
projectSlug: 'bar',
analysisSlug: 'koo',
}, function (err, response) {
// Handle response
});
```
### Vanilla javascript
```HTML
BotifySDK.authToken(token);
BotifySDK.AnalysisController.getAnalysisSummary({
username: 'foo',
projectSlug: 'bar',
analysisSlug: 'koo',
}, function (err, response) {
// Handle response
});
```
### Require.JS (AMD)
```HTML
define(["BotifySDK"], function(BotifySDK) {
BotifySDK.authToken(token);
BotifySDK.AnalysisController.getAnalysisSummary({
username: 'foo',
projectSlug: 'bar',
analysisSlug: 'koo',
}, function (err, response) {
// Handle response
});
});
```
**Note:** If you'd like to host the lib yourself, the bundle is available at `dist/botify-sdk.min.js` in the npm module.
## Usage
### Authentication
```JS
BotifySDK.authToken(token);
```
**How to get your token:** [https://developers.botify.com/api/authentication/](https://developers.botify.com/api/authentication/)
### Request API
The SDK exposes a function for each operation. They comply with the following signature:
```JS
BotifySDK.Controller.operation(params, callback);
```
- `params` (object): params are documented both in the SDK code or in the API documentation (becareful that in the JS SDK params are **camelcased**).
- `callback` (function): [NodeJS compliant callback](http://fredkschott.com/post/2014/03/understanding-error-first-callbacks-in-node-js/).
Full list of operations at [https://developers.botify.com/api/reference](https://developers.botify.com/api/reference)
### Example
```JS
BotifySDK.AnalysisController.getAnalysisSummary({
username: 'foo',
projectSlug: 'bar',
analysisSlug: 'koo',
}, function(error, result) {
// Handle response
});
```
### getUrlsAggs
SDK exposes `Query` and `QueryAggregate` models that can be used as input for `Analysis.getUrlsAggs` to make this complex endpoint a lot easier to deal with. [More information](https://github.com/botify-labs/botify-sdk-js-middlewares/blob/master/docs/middlewares/queryMiddleware.md)
Example of Query usage in the [demo](https://jsfiddle.net/8k20pbua/11/)
## Optimization
Middlewares are avalaible in the package [botify-sdk-middlewares](https://github.com/botify-labs/botify-sdk-js-middlewares). Consider using them for optimization and rate limit leverage. Some have been included by default in this package.