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

swapi-ts-sdk

v2.1.0

Published

TypeScript SDK for the Star Wars API

Readme

███████╗████████╗ █████╗ ██████╗     ██╗    ██╗ █████╗ ██████╗ ███████╗     █████╗ ██████╗ ██╗
██╔════╝╚══██╔══╝██╔══██╗██╔══██╗    ██║    ██║██╔══██╗██╔══██╗██╔════╝    ██╔══██╗██╔══██╗██║
███████╗   ██║   ███████║██████╔╝    ██║ █╗ ██║███████║██████╔╝███████╗    ███████║██████╔╝██║
╚════██║   ██║   ██╔══██║██╔══██╗    ██║███╗██║██╔══██║██╔══██╗╚════██║    ██╔══██║██╔═══╝ ██║
███████║   ██║   ██║  ██║██║  ██║    ╚███╔███╔╝██║  ██║██║  ██║███████║    ██║  ██║██║     ██║
╚══════╝   ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝     ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝    ╚═╝  ╚═╝╚═╝     ╚═╝
                                   ███████╗██████╗ ██╗  ██╗
                                   ██╔════╝██╔══██╗██║ ██╔╝
                                   ███████╗██║  ██║█████╔╝ 
                                   ╚════██║██║  ██║██╔═██╗ 
                                   ███████║██████╔╝██║  ██╗
                                   ╚══════╝╚═════╝ ╚═╝  ╚═╝
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄

TypeScript npm Node.js licence

A TypeScript SDK for the Star Wars API — fully typed, with support for pagination, filtering, and cross-resource search.

📦 npm: https://www.npmjs.com/package/swapi-ts-sdk
🚀 API: https://star-wars-api-9o3y.onrender.com
📖 API Docs: https://star-wars-api-9o3y.onrender.com/docs


✨ Features

  • 🎬 Films — Episodes I–IX, Rogue One & Solo
  • 👤 Characters — from Luke Skywalker to Grogu
  • 🪐 Planets — Tatooine to Exegol
  • 🧬 Species — Human to Ewok to Dathomirian
  • 🚀 Starships — Millennium Falcon to the Supremacy
  • 🚗 Vehicles — AT-AT to Podracer
  • 🔍 Cross-resource search — query across all resources at once
  • 📄 Pagination & filtering on every endpoint
  • 🔷 Fully typed — complete TypeScript interfaces for all resources

📦 Installation

npm install swapi-ts-sdk

🚀 Quick Start

import { ApiClient } from 'swapi-ts-sdk'

const client = ApiClient.getInstance()

// List characters
const characters = await client.characters.list()

// Get a single film
const film = await client.films.read(4)

// Search across all resources
const results = await client.search.search({ q: 'Skywalker' })

💡 Usage Examples

Pagination

// Page 1, 10 results (default)
const page1 = await client.characters.list()

// Page 2, 20 results per page
const page2 = await client.characters.list({ page: 2, limit: 20 })

// First 5 films
const films = await client.films.list({ page: 1, limit: 5 })

Filtering

// Search characters by name
const luke = await client.characters.list({ name: 'Luke' })

// Filter by gender and paginate
const chars = await client.characters.list({ gender: 'female', page: 1, limit: 10 })

// Filter planets by climate
const deserts = await client.planets.list({ climate: 'arid' })

// Filter starships by class and manufacturer
const destroyers = await client.starships.list({ starshipClass: 'Star Destroyer' })

// Filter films by director
const lucasFilms = await client.films.list({ director: 'George Lucas' })

Single Resource

// Get a character by ID (with relations)
const character = await client.characters.read(1)

// Get a film with full cast & relations
const film = await client.films.read(4)

// Get a planet
const planet = await client.planets.read(1)

Cross-resource Search

// Search across all resources
const all = await client.search.search({ q: 'Skywalker' })

// Search within a specific resource type
const ships = await client.search.search({ q: 'Falcon', type: 'starships' })

Response Format

List endpoints return:

{
  "data": [...],
  "meta": {
    "total": 101,
    "page": 1,
    "limit": 10,
    "totalPages": 11
  }
}

🌐 Available Endpoints

| Property | Methods | Description | |----------|---------|-------------| | client.characters | list(params?), read(id) | Star Wars characters | | client.films | list(params?), read(id) | Star Wars films | | client.planets | list(params?), read(id) | Planets | | client.species | list(params?), read(id) | Species | | client.starships | list(params?), read(id) | Starships | | client.vehicles | list(params?), read(id) | Vehicles | | client.search | search({ q, type? }) | Cross-resource search | | client.status | get() | API and database health check |

Query Parameters

All list() methods support:

| Param | Type | Description | |-------|------|-------------| | page | number | Page number (default: 1) | | limit | number | Results per page (default: 10, max: 100) |

Additional filters per endpoint:

| Endpoint | Filter Params | |----------|---------------| | characters | name, gender, homeworldId, speciesId | | films | title, director | | planets | name, climate, terrain | | species | name, classification | | starships | name, starshipClass, manufacturer | | vehicles | name, vehicleClass, manufacturer | | search | q (required), type (optional) |


⚙️ Configuration

By default the SDK points to the live API. To use a local or custom instance, set the HOST_API environment variable:

HOST_API=http://localhost:3000

Or pass the host directly when constructing the client:

const client = new ApiClient('http://localhost:3000')

🏗️ Tech Stack

| Layer | Technology | |-------|------------| | Language | TypeScript | | HTTP Client | Fetch API (native) | | Package Manager | npm | | Backed by | Star Wars API |


📜 License

MIT