βββββββββββββββββ ββββββ βββββββ βββ βββ ββββββ βββββββ ββββββββ ββββββ βββββββ βββ
βββββββββββββββββββββββββββββββββ βββ βββββββββββββββββββββββββββ βββββββββββββββββββ
ββββββββ βββ ββββββββββββββββ βββ ββ βββββββββββββββββββββββββββ βββββββββββββββββββ
ββββββββ βββ ββββββββββββββββ ββββββββββββββββββββββββββββββββββ βββββββββββββββ βββ
ββββββββ βββ βββ ββββββ βββ βββββββββββββ ββββββ βββββββββββ βββ ββββββ βββ
ββββββββ βββ βββ ββββββ βββ ββββββββ βββ ββββββ βββββββββββ βββ ββββββ βββ
βββββββββββββββ βββ βββ
βββββββββββββββββββ ββββ
βββββββββββ ββββββββββ
βββββββββββ ββββββββββ
βββββββββββββββββββ βββ
βββββββββββββββ βββ βββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
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
- π¬ 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
npm install swapi-ts-sdkimport { 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' })// 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 })// 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' })// 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)// 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' })List endpoints return:
{
"data": [...],
"meta": {
"total": 101,
"page": 1,
"limit": 10,
"totalPages": 11
}
}| 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 |
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) |
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:3000Or pass the host directly when constructing the client:
const client = new ApiClient('http://localhost:3000')| Layer | Technology |
|---|---|
| Language | TypeScript |
| HTTP Client | Fetch API (native) |
| Package Manager | npm |
| Backed by | Star Wars API |
MIT