Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including instapush with all npm packages installed. Try it out:

var instapush = require("instapush")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

instapush v0.0.7

Instapush API client for Node.js

Instapush

Instapush API client for Node.js

Installation

npm install instapush

Basic Use

var instapush = require('instapush');
//authorize
instapush.settings({
    token: '5295f58f12e23cf5',
    id:'52eed96ea2a8f0f',
    secret:'9a96794fec44481de5',
});

instapush.request('GET','/apps/list' ,function (err, response){
    console.log(response);
});

Helper Methods

The instapush module also includes methods that make working with common API resources a bit simpler:

<tr>
    <td>listEvents</td>
    <td><pre lang="javascript"><code>instapush.listEvents(callback);</code></pre></td>
    <td><a href="https://instapush.im/developer/rest#listevents">Link</a></td>
</tr>
<tr>
    <td>listApps</td>
    <td><pre lang="javascript"><code>instapush.listApps(callback);</code></pre></td>
    <td><a href="http://instapush.im/developer/rest#listapps">Link</a></td>
</tr>
<tr>
    <td>addApp</td>
    <td><pre lang="javascript"><code>instapush.addApp(data,callback);</code></pre></td>
    <td><a href="http://instapush.im/developer/rest#addapp">Link</a></td>
</tr>
<tr>
    <td>addEvent</td>
    <td><pre lang="javascript"><code>instapush.addEvent(data, callback);</code></pre></td>
    <td><a href="http://instapush.im/developer/rest#stats">Link</a></td>
</tr>
Method Example
notify
instapush.notify(data,callback);
Link

Full Use


var instapush = require('instapush');
//authorize
instapush.settings({
    ssl : true,
    token:'5295f58e23cf5',
    id:'52a221ab1284567',
    secret:'ad50d9eda8fdbc4b9a6',
});

//send a push notification triggered with the search event
instapush.notify({"event":"search","trackers":{"term":"api"}} ,function (err, response){
    console.log(response);
});

//list all events for the app, using the id and secret
instapush.listEvents(function (err, response){
    console.log(response);
});
//list all apps for a user using user token
instapush.listApps(function (err, response){
    console.log(response);
});


//adding a new event to an application
data = {"title":"nodejsEvent2",
        "trackers":["name","country"],
        "message":"{name} from {country} sucked."
        };
instapush.addEvent(data,function (err, response){
    console.log(response);
});

instapush.addApp({"title":"NodeJSAPP"},function (err, response){
    console.log(response);
});
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free