API Documentation

We made it easy for developers to integrate our service into their existing application.

In order to send notifications you must send a POST request to our API endpoint: https://api.pusha.io/v1/notifications

All requests must contain an API key, recipients (user tokens) and a message. User tokens will be provided by the users who are using your application. An API Key is required to identify your application. Messages have a limit of 1024 characters.

NPM package for Node.js

https://www.npmjs.com/package/pusha

Integration Examples

JavaScript


  var req = require('request');

  req.post({
      url: 'https://api.pusha.io/v1/notifications',
      form: { 
        recipients: ['tkn_0001', 'tkn_0002'],
        message: 'hello world'
      },
      headers: { 
        apikey: 'ak_0000'
      },
      method: 'POST'
    },
    function (e, r, body) {
        console.log(body);
    }
  );
    

Ruby


  require 'net/https'
  require 'uri'
  require 'json'

  uri = URI('https://api.pusha.io/v1/notifications')

  req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
  req['apikey'] = 'ak_0000'
  req.body = {
    recipients: ['tkn_0001', 'tkn_0002'],
    message: 'hello world'
  }.to_json
  res = Net::HTTP.start(uri.hostname, uri.port) do |http|
    http.request(req)
  end
    

PHP


  $ch = curl_init();
  curl_setopt_array($ch, array(
    CURLOPT_URL => "https://api.pusha.io/v1/notifications",
    CURLOPT_POSTFIELDS => http_build_query(array(
      'recipients' => array('tkn_0001', 'tkn_0002'),
      'message' => 'hello world'
    )),
    CURLOPT_HTTPHEADER => array(
      'apikey: ak_0000'
    ),
    CURLOPT_SAFE_UPLOAD => true,
    CURLOPT_RETURNTRANSFER => true,
  ));
  curl_exec($ch);
  curl_close($ch);
    

Perl


  use LWP::UserAgent;
  use Mozilla::CA;

  LWP::UserAgent->new()->post(
    'https://api.pusha.io/v1/notifications', [
    'recipients' => ('tkn_0001', 'tkn_0002'),
    'message' => 'hello world'
  ], 'apikey' => 'ak_0000');