npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

midnight-anime-sdk

v1.1.0

Published

Official JavaScript and TypeScript client for the Midnight Anime API.

Readme

midnight-anime-sdk

A small, dependency-free JavaScript and TypeScript client for the Midnight Anime API.

Install

npm install midnight-anime-sdk

The package works in modern browsers, Node.js 18+, Deno-compatible environments, and server runtimes that provide fetch.

JavaScript

import { createMidnightAnimeClient } from 'midnight-anime-sdk'

const anime = createMidnightAnimeClient({ token: process.env.MIDNIGHT_ANIME_API_KEY })
const { data } = await anime.search('Frieren', { limit: 10 })

console.log(data[0].title.english || data[0].title.romaji)

TypeScript

Type declarations are included in the package.

import { MidnightAnimeClient, type PlaybackParams } from 'midnight-anime-sdk'

const client = new MidnightAnimeClient({ timeout: 20_000 })
const result = await client.catalogue({ view: 'trending', limit: 12 })

const request: PlaybackParams = {
  malId: 21,
  type: 'tv',
  audio: 'sub',
  season: 1,
  episode: 1,
}
const streams = await client.playback(request)

Resources

await client.search('One Piece', { page: 1, limit: 20 })
await client.catalogue({ view: 'popular', limit: 20 })
await client.anime(21)
await client.artwork({ tmdbId: 94605, type: 'tv' })
await client.playback({ malId: 21, type: 'tv', audio: 'sub', season: 1, episode: 1 })

The same methods are available through grouped helpers:

await client.titles.search('Frieren')
await client.titles.get(21)
await client.media.artwork({ tmdbId: 94605 })

Custom API address or fetch

const client = createMidnightAnimeClient({
  baseUrl: 'https://www.midnightanime.bond/api/v1',
  token: process.env.MIDNIGHT_ANIME_API_KEY,
  timeout: 10_000,
  headers: { Origin: 'https://yourwebsite.com' },
  fetch: fetch,
})

Pass your Midnight Anime API key as token. The SDK sends it as X-API-Key; requests must also use the website origin registered for that key. Never commit keys or expose them in shipped browser source.

Every request also accepts an AbortSignal and a per-request timeout:

const controller = new AbortController()
const request = client.search('Naruto', {}, { signal: controller.signal })
controller.abort()

Errors

Failed HTTP, network, timeout, and cancellation cases throw MidnightAnimeError:

import { MidnightAnimeError } from 'midnight-anime-sdk'

try {
  await client.playback({ type: 'tv', audio: 'sub', season: 1, episode: 1 })
} catch (error) {
  if (error instanceof MidnightAnimeError) {
    console.log(error.code, error.status, error.message)
  }
}

Playback guidance

Playback responses are availability data. A valid request can still return no sources for a particular title, episode, or language. Render loading, unavailable, retry, and success states. Do not expose provider URLs as your primary product interface; pass a supported source to your own player and follow the usage rules of the service.

API versioning

The default base address is:

https://www.midnightanime.bond/api/v1

Pin the SDK version in production and handle unknown response fields gracefully. The API can change media availability, limits, and response fields as the service evolves.

All episodes and anime are distributed by Midnight Anime. Distributor is Midnight Anime Channel. Use the SDK only for respectful, lawful integrations and review the full documentation at https://midnightanime.bond/api.