Skip to content

itskyedo/pd-client

Repository files navigation

PD Client

MIT License Project Status Last Commit Commit Activity GitHub Stars

Important

This is an unofficial library developed independently and is not affiliated with or officially supported by PagerDuty.

👋 Introduction

PD Client is an unofficial TypeScript client for PagerDuty.

Purpose

While PagerDuty provides actively maintained client libraries in several languages, the TypeScript ecosystem remains comparatively limited. Existing solutions focus primarily on basic transport-level access with limited type safety. This exposes several underlying pain points:

  • Limited type safety leads to fragile integrations, which introduces error-prone queries and unncessary server-side processing costs
  • High cognitive overhead and reliance on implicit domain knowledge increases integration and support costs
  • Inconsistent API behavior increases friction by pushing implementation complexity onto downstream codebases
  • Modern developer expectations require a dedicated developer experience layer, not just an HTTP client

As TypeScript continues to see widespread adoption across both frontend and backend environments, the need for a dedicated library that provides a type-safe and ergonomic abstraction has become increasingly important.

Features

  • Fully type-safe API
  • Built on PagerDuty's official OpenAPI specification
  • Support for region selection (i.e. us or eu)
  • Support for multiple versions

🚀 Getting Started

Project Status

The library is in active development but due to it being in an experimental stage, production use is not recommended at this time. The goal is to finalize the API and reach 100% test coverage as part of the 1.0 release.

💡 Example

Client initialization

import { createClient } from '@itskyedo/pd-client';

export const pagerduty = createClient({
  token: 'your-api-token',

  // Optionally, you can pass in additional options:
  core: {
    version: 2,
    defaultFrom: '[email protected],
  },
  events: {
    version: 2,
  },
});

export async function builtInMethodsExample(): void {
  // Fully type-safe API
  const { data, error } = await pagerduty.createIncident({
    title: 'The server is on fire.',
    service: {
      id: 'PWIXJZS',
      type: 'service_reference',
    },
    priority: {
      id: 'P53ZZH5',
      type: 'priority_reference',
    },
    urgency: 'high',
    incident_key: 'baf7cf21b1da41b4b0221008339ff357',
    incident_type: {
      name: 'major_incident',
    },
    escalation_policy: {
      id: 'PT20YPA',
      type: 'escalation_policy_reference',
    },
  });

  if (error) {
    console.error(error);
    return;
  }

  console.log(`Incident created: ${data.incident.id}`);
}

// Alternatively, you can use the inner implementation if you need more control
// or if a built-in method has not yet been created.
export async function httpMethodsExample(): void {
  // This is also fully-typed, including the endpoint path and parameters
  const response = await pagerduty.fetchers.core.POST('/incidents', {
    headers: {...}
    body: {
      incident: {...}
    },
  });
}

📃 License

Created by Kyedo and is licensed under the MIT License. See LICENSE for more details.

About

An unofficial TypeScript client for PagerDuty.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published