API Documentation

v2

This is the API you will use to send notifications through PushNotifier.

Authorization is done using Basic Auth. You have to supply your app's package name as the username and your API token as the password and encode it as base64, like so (shown without base64 encoding):
Authorization: Basic some.app.package:YOURAPITOKENHERE

If you don't have an API token or an app package, yet, visit pushnotifier.de/account/api to get started.

When logging in on behalf of a user, you also have to apply a header X-AppToken with your issued app token for the user:
X-AppToken: SOMEAPPTOKENOFAUSERHERE

SSL is enforced. This API cannot be used over HTTP. CORS is supported.

Official SDKs

User

Login

Log in on behalf of a user. Logging in means to obtain a so-called "App Token" which is used to identify your requests.

Body must be a JSON object in this format:

{
  "username": "aUser",
  "password": "aPassword"
}

POST https://api.pushnotifier.de/v2/user/login

Requests

HTTP/1.1 POST /v2/user/login
Authorization: Basic Y29tLmdpZGl4LM214LaSMQsh==
{
	"username": "aUser",
	"password": "somePassword"
}

Responses

HTTP/1.1 200 OK
{
	"username": "aUser",
	"avatar": "https://www.gravatar.com/avatar/00000000000000000000000000000000",
	"app_token": "ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKSVV6STFOaUo5LmV5SnBZWFFpT2pFMU1EVTROakUwTXpFc0ltcDBhU0k2TnpRNE1EWXNJbWx6Y3lJNklqVkxUV0ZqTG1aeWFYUjZMbUp2ZUNJc0ltNWlaaUk2TVRVeE16WXpOelF6TVN3aVpYaHdJam94TlRFek5qTTNORE15TENKa1lYUWlPbnNpWVhCd1gzUnZhMlZ1SWpvaU0ySTJPR001TldZNE5UTTBNV0pqT1RWaE0yUTBNVEU0TXpNd01UUTFabU5sTXpneE1qUm1ORGhrWm1FeFlqQmhJaXdpY0dGamEyRm5aU0k2SW1OdmJTNW5hV1JwZUM1dFlXZHVkWE1pZlgwLmpXOEVaczh1cHZWLWg2V3lvdkhkQ0dnTU5ndVNHQ0RuZ3ZPX09SdnBmY28",
	"expires_at": 1513637432
}
HTTP/1.1 404 Not Found
When user couldn't be found
HTTP/1.1 403 Forbidden
When credentials are incorrect

Refresh Token

Refresh your obtained App Token. Same output as /v2/user/login, except for the username.

GET https://api.pushnotifier.de/v2/user/refresh

Refresh a token from API v1

Exchange a token you have obtained from API v1 for a token valid for use with API v2. Same output as /v2/user/refresh.

appToken * string Example: 3b28ca5f85341be95a1d4118330145fcef8124f43dfa1b0c

API v1 appToken

GET https://api.pushnotifier.de/v2/user/refreshv1

Requests

HTTP/1.1 GET /v2/user/refreshv1
Authorization: Basic Y29tLmdpZGl4LM214LaSMQsh==

Devices

Get Devices

Get all devices a user has registered and that are available for sending.

GET https://api.pushnotifier.de/v2/devices

Responses

HTTP/1.1 200 OK
[
    {
        "id": "ABC",
        "title": "example@example.org",
        "model": "E-Mail",
        "image": "https:\/\/devices.pushnotifier.de\/virtual\/E-Mail.png"
    },
    {
        "id": "xYz",
        "title": "iPhone X",
        "model": "iPhone10,6",
        "image": "https:\/\/devices.pushnotifier.de\/apple\/iPhoneX.png"
    }
]

Notifications

Send text

Body must be a JSON object in this format:

{
  "devices": […],
  "content": "Your Text Here"
}
devices has to be an array containing device IDs obtained by /v2/devices.

This endpoint will return a JSON object in this format:
{
  "success": [...],
  "error": [...]
}
success and error are arrays containing the device IDs that the notification has been sent or not sent to.

PUT https://api.pushnotifier.de/v2/notifications/text

Requests

HTTP/1.1 PUT /v2/notifications/text
Authorization: Basic Y29tLmdpZGl4LM214LaSMQsh==
X-AppToken: ZXlKYQWl…9SY28
{
	"devices": ["aXz"],
	"content": "This is an example!",
	"silent": false
}

Responses

HTTP/1.1 200 OK
{
	"success": ["aXz"],
	"error": []
}
HTTP/1.1 400 Bad Request
When the request is malformatted, i.e. missing content
HTTP/1.1 404 Not Found
When a device couldn't be found

Send a URL

Body must be a JSON object in this format:

{
  "devices": […],
  "url": "https://example.org"
}
devices has to be an array containing device IDs obtained by /v2/devices.

Same output as /v2/notifications/text

PUT https://api.pushnotifier.de/v2/notifications/url

Requests

HTTP/1.1 PUT /v2/notifications/url
Authorization: Basic Y29tLmdpZGl4LM214LaSMQsh==
X-AppToken: ZXlKYQWl…9SY28
{
	"devices": ["aXz"],
	"url": "https://pushnotifier.de",
	"silent": false
}

Responses

HTTP/1.1 200 OK
{
	"success": ["aXz"],
	"error": []
}
HTTP/1.1 400 Bad Request
When the request is malformatted, i.e. missing url
HTTP/1.1 404 Not Found
When a device couldn't be found

Send a notification

A notification includes some text and a link the user is taking to upon tapping the notification.

Body must be a JSON object in this format:

{
  "devices": […],
  "content": "Your Text Here",
  "url": "https://example.org"
}
devices has to be an array containing device IDs obtained by /v2/devices.

Same output as /v2/notifications/text

PUT https://api.pushnotifier.de/v2/notifications/notification

Requests

HTTP/1.1 PUT /v2/notifications/notification
Authorization: Basic Y29tLmdpZGl4LM214LaSMQsh==
X-AppToken: ZXlKYQWl…9SY28
{
	"devices": ["aXz"],
	"content": "This is an example!",
	"url": "https://pushnotifier.de",
	"silent": false
}

Responses

HTTP/1.1 200 OK
{
	"success": ["aXz"],
	"error": []
}
HTTP/1.1 400 Bad Request
When the request is malformatted, i.e. missing content or url
HTTP/1.1 404 Not Found
When a device couldn't be found

Send an image

Body must be a JSON object in this format:

{
  "devices": […],
  "content": "base64_encoded_image",
  "filename": "filename.jpg"
}
devices has to be an array containing device IDs obtained by /v2/devices.
content must be the image in base64, without data-prefix. 5 MB max.

Same output as /v2/notifications/text

PUT https://api.pushnotifier.de/v2/notifications/image

Requests

HTTP/1.1 PUT /v2/notifications/image
Authorization: Basic Y29tLmdpZGl4LM214LaSMQsh==
X-AppToken: ZXlKYQWl…9SY28
{
	"devices": ["aXz"],
	"content": "/9j/4AAQSkZJRgABAgAAAQABAAD/7Q…",
	"filename": "me_at_the_zoo.png",
	"silent": false
}

Responses

HTTP/1.1 200 OK
{
	"success": ["aXz"],
	"error": []
}
HTTP/1.1 400 Bad Request
When the request is malformatted, i.e. missing content or filename
HTTP/1.1 413 Payload Too Large
When the image is too big (> 5 MB).
HTTP/1.1 404 Not Found
When a device couldn't be found