API Examples

API Examples

Collection of JavaScript/Node.js scripts demonstrating Oh Dear API usage for automation.

Oh Dear API Examples & Scripts #

This repository contains examples and quick scripts to help you get started with the Oh Dear API. It includes a mini JavaScript SDK and helper functions you can copy into your own projects.

Use Cases #

The Oh Dear API can be used in many workflows:

Installation #

git clone https://github.com/ohdearapp/ohdear-api-examples.git
cd ohdear-api-examples
cp .env.example .env
npm install

Add your API key to the .env file:

OH_DEAR_API_KEY=your-api-key

Example: Create Site From Template #

import { create_site_from_existing } from './examples.js';

// Create a new site using site ID 5746 as template for team 17
create_site_from_existing(17, 5746);

Example: Sync Status Pages #

import { sync_status_pages_with_tagged_sites } from './examples.js';

// Sync status pages with sites tagged 'production'
sync_status_pages_with_tagged_sites('production');

Almost everything you can do in the Oh Dear application can also be done via the API. Check the API documentation for more details.