← Back to Home
Stephen
King

API Docs

Introduction

The Stephen King API is a free, open-source REST API providing data about Stephen King's novels, short stories, and villains. No authentication is required. All endpoints are read-only (GET requests only).

Responses are returned in JSON format. Related resources include links to their associated endpoints for easy traversal.

Base URL

https://stephen-king-api.onrender.com/api

All endpoints described below are relative to this base URL.

Pagination

All list endpoints support optional pagination via query parameters:

Parameter Type Description
page integer Page number (starts at 1)
limit integer Items per page (max 100)

Both page and limit must be provided together to enable pagination. Without them, all results are returned.

Without pagination

GET https://stephen-king-api.onrender.com/api/books
{
  "data": [ ... ]
}

With pagination

GET https://stephen-king-api.onrender.com/api/books?page=1&limit=5
{
  "data": [ ... ],
  "pagination": {
    "page": 1,
    "limit": 5,
    "total": 75,
    "totalPages": 15
  }
}

Books

GET /api/books

Returns all books. Supports pagination.

Example Request

GET https://stephen-king-api.onrender.com/api/books?page=1&limit=2

Example Response

{
  "data": [
    {
      "id": 1,
      "Year": 1974,
      "Title": "Carrie",
      "handle": "carrie",
      "Publisher": "Doubleday",
      "ISBN": "978-0-385-08695-0",
      "Pages": 199,
      "Notes": [
        "King's first published novel"
      ],
      "villains": [
        {
          "name": "Margaret White",
          "url": "https://stephen-king-api.onrender.com/api/villain/2"
        }
      ],
      "created_at": "2023-09-17T00:00:00.000Z"
    },
    {
      "id": 2,
      "Year": 1975,
      "Title": "'Salem's Lot",
      "handle": "salem-s-lot",
      "Publisher": "Doubleday",
      "ISBN": "978-0-385-00751-1",
      "Pages": 439,
      "Notes": [],
      "villains": [
        {
          "name": "Kurt Barlow",
          "url": "https://stephen-king-api.onrender.com/api/villain/1"
        }
      ],
      "created_at": "2023-09-17T00:00:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 2,
    "total": 75,
    "totalPages": 38
  }
}
GET /api/book/:id

Returns a single book by ID.

Example Request

GET https://stephen-king-api.onrender.com/api/book/3

Example Response

{
  "data": {
    "id": 3,
    "Year": 1977,
    "Title": "The Shining",
    "handle": "the-shining",
    "Publisher": "Doubleday",
    "ISBN": "978-0-385-12167-5",
    "Pages": 447,
    "Notes": [],
    "villains": [
      {
        "name": "Jack Torrance",
        "url": "https://stephen-king-api.onrender.com/api/villain/3"
      }
    ],
    "created_at": "2023-09-17T00:00:00.000Z"
  }
}

Short Stories

GET /api/shorts

Returns all short stories. Supports pagination.

Example Request

GET https://stephen-king-api.onrender.com/api/shorts?page=1&limit=1

Example Response

{
  "data": [
    {
      "id": 1,
      "title": "Jerusalem's Lot",
      "type": "Short Story",
      "handle": "jerusalems-lot",
      "originallyPublishedIn": "Night Shift",
      "collectedIn": "Night Shift",
      "notes": [],
      "year": 1978,
      "villains": [
        {
          "name": "Kurt Barlow",
          "url": "https://stephen-king-api.onrender.com/api/villain/1"
        }
      ],
      "created_at": "2023-09-17T00:00:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 1,
    "total": 200,
    "totalPages": 200
  }
}
GET /api/short/:id

Returns a single short story by ID.

Example Request

GET https://stephen-king-api.onrender.com/api/short/2

Example Response

{
  "data": {
    "id": 2,
    "title": "Graveyard Shift",
    "type": "Short Story",
    "handle": "graveyard-shift",
    "originallyPublishedIn": "Cavalier",
    "collectedIn": "Night Shift",
    "notes": [],
    "year": 1970,
    "villains": [],
    "created_at": "2023-09-17T00:00:00.000Z"
  }
}

Villains

Villain responses include books and shorts arrays (instead of a villains array) linking to the works they appear in.

GET /api/villains

Returns all villains. Supports pagination.

Example Request

GET https://stephen-king-api.onrender.com/api/villains?page=1&limit=1

Example Response

{
  "data": [
    {
      "id": 1,
      "name": "Kurt Barlow",
      "gender": "Male",
      "status": "Undead",
      "types_id": 1,
      "notes": [],
      "created_at": "2023-09-17T00:00:00.000Z",
      "books": [
        {
          "title": "'Salem's Lot",
          "url": "https://stephen-king-api.onrender.com/api/book/2"
        }
      ],
      "shorts": [
        {
          "title": "Jerusalem's Lot",
          "url": "https://stephen-king-api.onrender.com/api/short/1"
        }
      ]
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 1,
    "total": 55,
    "totalPages": 55
  }
}
GET /api/villain/:id

Returns a single villain by ID.

Example Request

GET https://stephen-king-api.onrender.com/api/villain/3

Example Response

{
  "data": {
    "id": 3,
    "name": "Jack Torrance",
    "gender": "Male",
    "status": "Deceased",
    "types_id": 2,
    "notes": [],
    "created_at": "2023-09-17T00:00:00.000Z",
    "books": [
      {
        "title": "The Shining",
        "url": "https://stephen-king-api.onrender.com/api/book/3"
      }
    ],
    "shorts": []
  }
}

Data Models

Book

Field Type Description
id integer Unique identifier
Year integer Year of publication
Title string Book title
handle string URL-friendly slug
Publisher string Publisher name
ISBN string ISBN identifier
Pages integer Page count
Notes string[] Additional notes
villains array Associated villains with name and URL
created_at datetime Record creation timestamp

Short Story

Field Type Description
id integer Unique identifier
title string Story title
type string Type of work (e.g. "Short Story")
handle string URL-friendly slug
originallyPublishedIn string Original publication
collectedIn string Collection it appears in
notes string[] Additional notes
year integer Year of publication
villains array Associated villains with name and URL
created_at datetime Record creation timestamp

Villain

Field Type Description
id integer Unique identifier
name string Villain name
gender string? Gender (nullable)
status string Status (e.g. "Deceased", "Undead")
types_id integer Villain type identifier
notes string[] Additional notes
books array Associated books with title and URL
shorts array Associated short stories with title and URL
created_at datetime Record creation timestamp