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

A TypeScript SDK for the Star Wars API — fully typed, paginated & filterable.

[ NPM PACKAGE ] [ VIEW ON GITHUB ]

Installation

$ npm install swapi-ts-sdk
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' })

Data Coverage

🎬
11
FILMS
👤
101
CHARACTERS
🪐
62
PLANETS
🧬
40
SPECIES
🚀
32
STARSHIPS
🚗
30
VEHICLES

SDK Methods

Client Property Method Description
client.characters.list(params?)List characters with optional filters
client.characters.read(id)Get a character by ID
client.films.list(params?)List films with optional filters
client.films.read(id)Get a film with full cast & relations
client.planets.list(params?)List planets with optional filters
client.planets.read(id)Get a planet by ID
client.species.list(params?)List species with optional filters
client.species.read(id)Get a species by ID
client.starships.list(params?)List starships with optional filters
client.starships.read(id)Get a starship by ID
client.vehicles.list(params?)List vehicles with optional filters
client.vehicles.read(id)Get a vehicle by ID
client.search.search({ q, type? })Search across all resources
client.status.get()API and database health check

Examples

// Pagination
const page2 = await client.characters.list({ page: 2, limit: 20 })
// Filter by name, climate, class...
const luke = await client.characters.list({ name: 'Luke' })
const deserts = await client.planets.list({ climate: 'arid' })
const destroyers = await client.starships.list({ starshipClass: 'Star Destroyer' })
// Cross-resource search
const all = await client.search.search({ q: 'Skywalker' })
const ships = await client.search.search({ q: 'Falcon', type: 'starships' })
// Response format
{
  "data": [ ... ],
  "meta": {
    "total": 101,
    "page": 1,
    "limit": 10,
    "totalPages": 11
  }
}