Pusher HTTP API

Pusher HTTP API

Publisher: Search Engine (Ursa)
Base URL: https://example.com/

The API is hosted at http://api.pusherapp.com, and may be accessed via HTTP or HTTPS. All requests MUST be authenticated, as described below.

## Authentication

Pusher uses a HMAC-based authentication. Once all the parameters have been added to the request, a signature is calculated - `auth_signature`, described below and appended to the query string.

### Generating authentication signatures

The signature is a HMAC SHA256 hex digest. This is generated by signing a string made up of the following components concatenated with newline characters `\n`.

* The uppercase request method (e.g. `POST`).
* The request path (e.g. `/some/resource`).
* The query parameters sorted by key, with keys converted to lowercase, then joined as in the query string.

NOTE:
> The string must not be url escaped (e.g. given the keys `auth_key`: `foo`, `Name`: `Something else`, you get `auth_key=foo&name=Something else`).

See below for a worked example.

### Worked authentication example

Assume that we wish to trigger the `foo` event on the `project-3` channel with JSON `{"some":"data"}` and that our app credentials are

app_id 3
key 278d425bdf160c739803
secret 7ad3773142a6692b25b8

The request url is

http://api.pusherapp.com/apps/3/events

Since this is a POST request, the body should contain a hash of parameters encoded as JSON where the data parameter is itself JSON encoded:

```json
{"name":"foo","channels":["project-3"],"data":"{\"some\":\"data\"}"}
```

Note that these parameters may be provided in the query string, although this is discouraged.

Authentication parameters should be added (assume that these are included in the query string, so the body is unchanged from above). Since the body is non-empty a body_md5 parameter should be added

auth_key 278d425bdf160c739803
auth_timestamp 1353088179
auth_version 1.0

The signature is generated by signing the following string

POST\n/apps/3/events\nauth_key=278d425bdf160c739803&auth_timestamp=1353088179&auth_version=1.0&body_md5=ec365a775a4cd0599faeb73354201b6f

This should be signed by generating the HMAC SHA256 hex digest with secret key `7ad3773142a6692b25b8`. This yields the following signature


da454824c97ba181a32ccc17a72625ba02771f50b50e1e7430e47a1f3f457e6c

The API request then becomes

POST /apps/3/events?auth_key=278d425bdf160c739803&auth_timestamp=1353088179&auth_version=1.0&body_md5=ec365a775a4cd0599faeb73354201b6f&auth_signature=da454824c97ba181a32ccc17a72625ba02771f50b50e1e7430e47a1f3f457e6c HTTP/1.1
Content-Type: application/json

{"name":"foo","channels":["project-3"],"data":"{\"some\":\"data\"}"}

Or using curl:

$ curl -H "Content-Type: application/json" -d '{"name":"foo","channels":["project-3"],"data":"{\"some\":\"data\"}"}' "http://api.pusherapp.com/apps/3/events?auth_key=278d425bdf160c739803&auth_timestamp=1353088179&auth_version=1.0&body_md5=ec365a775a4cd0599faeb73354201b6f&auth_signature=da454824c97ba181a32ccc17a72625ba02771f50b50e1e7430e47a1f3f457e6c"
{}

If you're having difficulty generating the correct signature in your library please take a look at this http://gist.github.com/376898[example gist].


## HTTP Keep-Alive

The Pusher API supports [HTTP Keep-Alive](https://en.wikipedia.org/wiki/HTTP_persistent_connection). HTTP client libraries that implement this feature are able to re-use a single TCP connection to send multiple HTTP requests thus avoiding the overhead of the TCP connection (typically 100-200ms) between each subsequent request.

In scenarios where many requests are sent at the same time this can improve the throughput and decrease the load on the machine that is sending those requests.

Available Platforms


DISCLAIMER: These SDKs are generated using publicly available descriptions of APIs that anyone has created. As such there are no guarantees for any of the SDKs below, or that this listing is maintained by or even related to the company it claims to be, unless explicitly specified.

C-Sharp


Portable Class Library Download Customise

A project for creating a C# class library (.dll) that can run on Windows, Silverlight and Windows Phone.

Download Documentation

Objective-C


Cocoa Touch Static Library Download Customise

A foundation framework based template for building static library in Objective-C.

Download Documentation

Java


Android Library (Gradle) Download Customise

A gradle based android library project, which can be used with Android Studio as well as command line based gradle build system.

Download Documentation

Java Library (Eclipse) Download Customise

An eclipse based java library project, which can be used with JRE7.

Download Documentation

Javascript


Angular JS Download Customise

An AngularJS library based on v1.3.0.

Download Documentation

Node.js Download Customise

A Node.js npm package based on Node.js v0.12.4

Download Documentation

PHP


PHP Library Download Customise

A php library based on PHP >= 5.3 and Composer dependency manager

Download Documentation

Python


Python Library Download Customise

A Python library based on Python 2.7, that uses PIP as the dependency manager

Download Documentation

Ruby


Ruby Gem Download Customise

A Ruby Gem based on Ruby >= 2.0.0

Download Documentation

Go


Go Library Download Customise

Go language (v1.4), client library package that is compatible with command line tools as well as the Goclipse IDE.

Download Documentation

All Reviews (0)


There are no reviews at the moment.

Users of this SDK (0)


There are no uses at the moment.

Rating

No Rating

Category

Other

Tags

No Tags