CallFire API v2.0 Javascript SDK (beta)
Dependencies:
- swagger-client: 2.1.30
Getting started
Installation
Before start you should add dependency to your Javascript project:
$ npm install --save callfire-api-client-js
Also you can find the latest bundle at releases page. After these steps callfire-api-client should appear in your project dependencies.
In case you want to build it yourself:
$ git clone https://github.com/CallFire/callfire-api-client-js.git
$ cd callfire-api-client-js
$ npm install
$ gulp build
it will create the next 4 files in lib directory:
callfire-api-client-js.js - library code
callfire-api-client-js.js.map - source map
callfire-api-client-js.min.js - minified library code
callfire-api-client-js.min.js.map - source map for minified code
Overview
To create client instance just provide API login and password. API credentials should be configured on Account -> Settings -> API Access page. Client uses HTTPS connection and Basic Authentication.
The following example shows how to get an account information and send two SMS messages:
import CallfireClient from 'callfire-api-client-js';
function apiSample() {
let client = new CallfireClient('api-login', 'api-password');
// get account info
client.ready().then((client) => {
client.me.getAccount()
.then((response) => {
console.log('account', response.obj);
})
.catch((err) => {
throw Error(err + err.data);
});
});
// send 2 SMSs
client.ready().then((client) => {
client.texts.sendTexts({
body: [
{
phoneNumber: '14243876936',
message: 'test message 1'
},
{
phoneNumber: '14247006955',
message: 'test message 2'
}
]
})
.then((response) => {
console.log('texts', response.obj);
})
.catch((err) => {
throw Error(err + err.data);
});
});
}
List of API groups:
const client = new CallfireClient('api_login', 'api_password');
client.calls.
client.campaigns.
client.contacts.
client.keywords.
client.me.
client.media.
client.numbers.
client.orders.
client.texts.
client.webhooks.
Error handling
The CallFire Developers API uses standard HTTP response codes for responses. These HTTP codes indicate whether or not an API operation is successful.
Status Code 200 is the desired response code. A standard JSON response will follow.
Codes in the 400s range detail all of the errors a CallFire Developer could encounter while using the API. Bad Request, Rate Limit Reached, and Unauthorized are some of the sorts of responses in the 400s block.
Codes in the 500s range are error responses from the CallFire system. If an error has occurred anywhere in the execution of a resource that was not due to user input, a 500 response will be returned with a corresponding JSON error body. In that body will contain a message detailing what went wrong.
Debug & logging
TBA