NAV Navbar
Logo
Ruby Python

NotifyNinja API v1

Base URL: https://notifyninja.com/app/api/v1

Authentication

HTTP Authentication, scheme: Bearer

Watchers

addWatcher

Code samples

require 'rest-client'
require 'json'

headers = {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' => 'Bearer {access-token}'
}

response = RestClient.post 'https://notifyninja.com/app/api/v1/watcher',
  watcher: {
    name: 'Example',
    url: 'http://example.com',
    checking_delay: 240,
    is_critical: false,
    verify_ssl_certificate: false,
    verify_domain_expiration: true,
    patterns_attributes: [
      { name: '[:load_time:]', condition: 'lt', value: '500' },
      { name: '[:page_text:]', condition: 'incl', value: 'test string' },
      { name: '[:response_code:]', condition: 'eq', value: '200' }
    ]
  },
  headers: headers

p JSON.parse(response)
import requests
import json

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer {access-token}'
}

data = {
  'watcher': {
    'name': 'Example',
    'url': 'http://example.com',
    'checking_delay': 240,
    'is_critical': False,
    'verify_ssl_certificate': False,
    'verify_domain_expiration': True,
    'patterns_attributes': [
      { 'name': '[:load_time:]', 'condition': 'lt', 'value': '500' },
      { 'name': '[:page_text:]', 'condition': 'incl', 'value': 'test string' },
      { 'name': '[:response_code:]', 'condition': 'eq', 'value': '200' }
    ]
  }
}

response = requests.post(
  'https://notifyninja.com/app/api/v1/watcher',
  data = json.dumps(data),
  headers = headers
)

print response.json()

Example response

Response 200 and 201

{
  'name': 'Example',
  'url': 'http://example.com',
  'checking_delay': 240,
  'is_critical': false,
  'verify_ssl_certificate': false,
  'verify_domain_expiration': true,
  'patterns': [
    ['[:load_time:]', 'lt', '500'],
    ['[:page_text:]', 'incl', 'test string'],
    ['[:response_code:]', 'eq', '200']
  ]
}

POST /watcher

Add watcher

Properties

Name
Type Required Description
watcher object true -
- name string true Name of the watcher
- url string true Watcher url (example: http://example.com). Non validated url will return error 400
- checking_delay integer false Checking delay for watcher
- is_critical boolean false Enable phone calls and sms (if subscription level is enough)
- verify_ssl_certificate boolean false Inform if site's certificate is expired
- verify_domain_expiration boolean false Inform if site's domain name is expired
- patterns_attributes array false Checking patterns for watcher

Patterns

Patterns description

Name
Possible conditions Possible values Description
:load_time: lt; gt any value between 0 and 5000 (ms) Used to check load time of the page
:response_code: eq; neq 200; 301; 302; 401; 404; 500; 501; 502; 503 Used to check response code of the page
:page_size: lt; gt any value between 0 and 1000 (kb) Used to check page size
:page_text: incl; nincl any text value Check if page contains (or not) selected value
:any_regexp: match any regexp value Scan page with given regexp value

Conditions explanation

Errors

Errors description

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
404 Not Found -- Check path of your request.
409 Conflict -- Something wrong with the resource you are creating.
422 Unprocessable Entity -- Parameters that you have send are not enough

Usually when deal with any of mentioned errors you can read response object and find out what cause this error.

Errors explanation list: