An open API service indexing awesome lists of open source software.

https://github.com/simplr-sh/swapi-sdk

A simple Typescript SDK for the Simplr's Star Wars API (SWAPI) service that provides a simple, typesafe interface to interact with the API.
https://github.com/simplr-sh/swapi-sdk

api sdk starwars starwars-api swapi typescript typescript-library typescript-sdk

Last synced: about 1 month ago
JSON representation

A simple Typescript SDK for the Simplr's Star Wars API (SWAPI) service that provides a simple, typesafe interface to interact with the API.

Awesome Lists containing this project

README

        

# @simplr-sh/swapi-sdk

A TypeScript SDK for interacting with the Star Wars API (SWAPI) @ [Simplr's SW-API](https://github.com/simplr-sh/sw-api).

## Installation

```bash
# Using bun
bun i @simplr-sh/swapi-sdk
```
```bash
# Using NPM
npm i @simplr-sh/swapi-sdk
```
```bash
# Using NPM
yarn i @simplr-sh/swapi-sdk
```

## Features

- Full TypeScript support
- Type-safe responses
- Simple and intuitive API

## API Reference

### Films
- `getFilms()`: Get all Star Wars films
- `getFilmById(id: number)`: Get a film by ID
- `getFilmSchema()`: Get the film schema
- `searchFilms(query: string)`: Search films by title

### People
- `getPeople()`: Get all people
- `getPersonById(id: number)`: Get a person by ID
- `getPersonSchema()`: Get the person schema
- `searchPeople(query: string)`: Search people by name

### Planets
- `getPlanets()`: Get all planets
- `getPlanetById(id: number)`: Get a planet by ID
- `getPlanetSchema()`: Get the planet schema
- `searchPlanets(query: string)`: Search planets by name

### Species
- `getSpecies()`: Get all species
- `getSpeciesById(id: number)`: Get a species by ID
- `getSpeciesSchema()`: Get the species schema
- `searchSpecies(query: string)`: Search species by name

### Starships
- `getStarships()`: Get all starships
- `getStarshipById(id: number)`: Get a starship by ID
- `getStarshipSchema()`: Get the starship schema
- `searchStarships(query: string)`: Search starships by name

### Vehicles
- `getVehicles()`: Get all vehicles
- `getVehicleById(id: number)`: Get a vehicle by ID
- `getVehicleSchema()`: Get the vehicle schema
- `searchVehicles(query: string)`: Search vehicles by name

### Root
- `getRoot()`: Get the API root endpoints

## Usage

```typescript
import { films, people, planets, species, starships, vehicles } from '@simplr-sh/swapi-sdk';

// Get all films
const allFilms = await films.getFilms();

// Search for people
const searchResults = await people.searchPeople('luke');

// Get a specific planet
const tatooine = await planets.getPlanetById(1);
```

## Development

```bash
bun install
bun run index.ts
```

This project was created using `bun init` in bun v1.1.42.