UNPKG

@simplr-sh/swapi-sdk

Version:

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

711 lines (696 loc) 18.3 kB
/** * Get all Star Wars films * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/films/all.json */ declare function getFilms(): Promise<Film[]>; /** * Get a Star Wars film by ID * @param id The ID of the film * * Example File: https://github.com/simplr-sh/sw-api/blob/main/public/api/films/1.json */ declare function getFilmById(id: number): Promise<Film>; /** * Get the schema for a Star Wars film * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/films/schema.json */ declare function getFilmSchema(): Promise<FilmSchema>; /** * Search for a Star Wars film by title * @param query The title of the film */ declare function searchFilms(query: string): Promise<Film[]>; type Film = { title: string; episode_id: number; opening_crawl: string; director: string; producer: string; release_date: string; characters: Array<string>; planets: Array<string>; starships: Array<string>; vehicles: Array<string>; species: Array<string>; created: string; edited: string; url: string; }; type FilmSchema = { $schema: string; type: string; properties: { title: { type: string; }; episode_id: { type: string; }; opening_crawl: { type: string; }; director: { type: string; }; producer: { type: string; }; release_date: { type: string; }; characters: { type: string; items: Array<{ type: string; }>; }; planets: { type: string; items: Array<{ type: string; }>; }; starships: { type: string; items: Array<{ type: string; }>; }; vehicles: { type: string; items: Array<{ type: string; }>; }; species: { type: string; items: Array<{ type: string; }>; }; created: { type: string; }; edited: { type: string; }; url: { type: string; }; }; required: Array<string>; }; type films_Film = Film; type films_FilmSchema = FilmSchema; declare const films_getFilmById: typeof getFilmById; declare const films_getFilmSchema: typeof getFilmSchema; declare const films_getFilms: typeof getFilms; declare const films_searchFilms: typeof searchFilms; declare namespace films { export { type films_Film as Film, type films_FilmSchema as FilmSchema, films_getFilmById as getFilmById, films_getFilmSchema as getFilmSchema, films_getFilms as getFilms, films_searchFilms as searchFilms }; } /** * Get all people in the Star Wars universe * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/people/all.json */ declare function getPeople(): Promise<Person[]>; /** * Get a person by their ID * @param id The ID of the person * * Example File: https://github.com/simplr-sh/sw-api/blob/main/public/api/people/1.json */ declare function getPersonById(id: number): Promise<Person>; /** * Get the schema for a person * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/people/schema.json */ declare function getPersonSchema(): Promise<PersonSchema>; /** * Search for people by name * @param query The search query */ declare function searchPeople(query: string): Promise<Person[]>; type Person = { name: string; height: string; mass: string; hair_color: string; skin_color: string; eye_color: string; birth_year: string; gender: string; homeworld: string; films: Array<string>; species: Array<string>; vehicles: Array<string>; starships: Array<string>; created: string; edited: string; url: string; }; type PersonSchema = { $schema: string; type: string; properties: { name: { type: string; }; height: { type: string; }; mass: { type: string; }; hair_color: { type: string; }; skin_color: { type: string; }; eye_color: { type: string; }; birth_year: { type: string; }; gender: { type: string; }; homeworld: { type: string; }; films: { type: string; items: Array<{ type: string; }>; }; species: { type: string; items: Array<{ type: string; }>; }; vehicles: { type: string; items: Array<{ type: string; }>; }; starships: { type: string; items: Array<{ type: string; }>; }; created: { type: string; }; edited: { type: string; }; url: { type: string; }; }; required: Array<string>; }; type people_Person = Person; type people_PersonSchema = PersonSchema; declare const people_getPeople: typeof getPeople; declare const people_getPersonById: typeof getPersonById; declare const people_getPersonSchema: typeof getPersonSchema; declare const people_searchPeople: typeof searchPeople; declare namespace people { export { type people_Person as Person, type people_PersonSchema as PersonSchema, people_getPeople as getPeople, people_getPersonById as getPersonById, people_getPersonSchema as getPersonSchema, people_searchPeople as searchPeople }; } /** * Get all planets in the Star Wars universe * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/planets/all.json */ declare function getPlanets(): Promise<Planet[]>; /** * Get a planet by its ID * @param id The ID of the planet * * Example File: https://github.com/simplr-sh/sw-api/blob/main/public/api/planets/1.json */ declare function getPlanetById(id: number): Promise<Planet>; /** * Get the schema for a planet * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/planets/schema.json */ declare function getPlanetSchema(): Promise<PlanetSchema>; /** * Search for a planet by name * @param query The search query */ declare function searchPlanets(query: string): Promise<Planet[]>; type Planet = { name: string; rotation_period: string; orbital_period: string; diameter: string; climate: string; gravity: string; terrain: string; surface_water: string; population: string; residents: Array<string>; films: Array<string>; created: string; edited: string; url: string; }; type PlanetSchema = { $schema: string; type: string; properties: { name: { type: string; }; rotation_period: { type: string; }; orbital_period: { type: string; }; diameter: { type: string; }; climate: { type: string; }; gravity: { type: string; }; terrain: { type: string; }; surface_water: { type: string; }; population: { type: string; }; residents: { type: string; items: Array<{ type: string; }>; }; films: { type: string; items: Array<{ type: string; }>; }; created: { type: string; }; edited: { type: string; }; url: { type: string; }; }; required: Array<string>; }; type planets_Planet = Planet; type planets_PlanetSchema = PlanetSchema; declare const planets_getPlanetById: typeof getPlanetById; declare const planets_getPlanetSchema: typeof getPlanetSchema; declare const planets_getPlanets: typeof getPlanets; declare const planets_searchPlanets: typeof searchPlanets; declare namespace planets { export { type planets_Planet as Planet, type planets_PlanetSchema as PlanetSchema, planets_getPlanetById as getPlanetById, planets_getPlanetSchema as getPlanetSchema, planets_getPlanets as getPlanets, planets_searchPlanets as searchPlanets }; } /** * Get the root of the Star Wars API * e.g. the URLs for all the other endpoints * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/root.json */ declare function getRoot(): Promise<Root>; type Root = { films: string; people: string; planets: string; species: string; vehicles: string; starships: string; }; type root_Root = Root; declare const root_getRoot: typeof getRoot; declare namespace root { export { type root_Root as Root, root_getRoot as getRoot }; } /** * Get all species in the Star Wars universe * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/species/all.json */ declare function getSpecies(): Promise<Species[]>; /** * Get a species by its ID * @param id The ID of the species * * Example File: https://github.com/simplr-sh/sw-api/blob/main/public/api/species/1.json */ declare function getSpeciesById(id: number): Promise<Species>; /** * Get the schema for a species * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/species/schema.json */ declare function getSpeciesSchema(): Promise<SpeciesSchema>; /** * Search for a species by name * @param query The search query */ declare function searchSpecies(query: string): Promise<Species[]>; type Species = { name: string; classification: string; designation: string; average_height: string; skin_colors: string; hair_colors: string; eye_colors: string; average_lifespan: string; homeworld?: string; language: string; people: Array<string>; films: Array<string>; created: string; edited: string; url: string; }; type SpeciesSchema = { $schema: string; type: string; properties: { name: { type: string; }; classification: { type: string; }; designation: { type: string; }; average_height: { type: string; }; skin_colors: { type: string; }; hair_colors: { type: string; }; eye_colors: { type: string; }; average_lifespan: { type: string; }; homeworld: { type: string; }; language: { type: string; }; people: { type: string; items: Array<{ type: string; }>; }; films: { type: string; items: Array<{ type: string; }>; }; created: { type: string; }; edited: { type: string; }; url: { type: string; }; }; required: Array<string>; }; type species_Species = Species; type species_SpeciesSchema = SpeciesSchema; declare const species_getSpecies: typeof getSpecies; declare const species_getSpeciesById: typeof getSpeciesById; declare const species_getSpeciesSchema: typeof getSpeciesSchema; declare const species_searchSpecies: typeof searchSpecies; declare namespace species { export { type species_Species as Species, type species_SpeciesSchema as SpeciesSchema, species_getSpecies as getSpecies, species_getSpeciesById as getSpeciesById, species_getSpeciesSchema as getSpeciesSchema, species_searchSpecies as searchSpecies }; } /** * Get all starships * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/starships/all.json */ declare function getStarships(): Promise<Starship[]>; /** * Get a starship by id * @param id The id of the starship * * Example File: https://github.com/simplr-sh/sw-api/blob/main/public/api/starships/9.json */ declare function getStarshipById(id: number): Promise<Starship>; /** * Get the schema for a starship * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/starships/schema.json */ declare function getStarshipSchema(): Promise<StarshipSchema>; /** * Search for starships by name * @param query The search query */ declare function searchStarships(query: string): Promise<Starship[]>; type Starship = { name: string; model: string; manufacturer: string; cost_in_credits: string; length: string; max_atmosphering_speed: string; crew: string; passengers: string; cargo_capacity: string; consumables: string; hyperdrive_rating: string; MGLT: string; starship_class: string; pilots: Array<string>; films: Array<string>; created: string; edited: string; url: string; }; type StarshipSchema = { $schema: string; type: string; properties: { name: { type: string; }; model: { type: string; }; manufacturer: { type: string; }; cost_in_credits: { type: string; }; length: { type: string; }; max_atmosphering_speed: { type: string; }; crew: { type: string; }; passengers: { type: string; }; cargo_capacity: { type: string; }; consumables: { type: string; }; hyperdrive_rating: { type: string; }; MGLT: { type: string; }; starship_class: { type: string; }; pilots: { type: string; items: Array<{ type: string; }>; }; films: { type: string; items: Array<{ type: string; }>; }; created: { type: string; }; edited: { type: string; }; url: { type: string; }; }; required: Array<string>; }; type starships_Starship = Starship; type starships_StarshipSchema = StarshipSchema; declare const starships_getStarshipById: typeof getStarshipById; declare const starships_getStarshipSchema: typeof getStarshipSchema; declare const starships_getStarships: typeof getStarships; declare const starships_searchStarships: typeof searchStarships; declare namespace starships { export { type starships_Starship as Starship, type starships_StarshipSchema as StarshipSchema, starships_getStarshipById as getStarshipById, starships_getStarshipSchema as getStarshipSchema, starships_getStarships as getStarships, starships_searchStarships as searchStarships }; } /** * Get all Star Wars vehicles * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/vehicles/all.json */ declare function getVehicles(): Promise<Vehicle[]>; /** * Get a vehicle by its ID * @param id The ID of the vehicle * * Example File: https://github.com/simplr-sh/sw-api/blob/main/public/api/vehicles/4.json */ declare function getVehicleById(id: number): Promise<Vehicle>; /** * Get the schema for a vehicle * * File: https://github.com/simplr-sh/sw-api/blob/main/public/api/vehicles/schema.json */ declare function getVehicleSchema(): Promise<VehicleSchema>; /** * Search for a vehicle by name * @param query The search query */ declare function searchVehicles(query: string): Promise<Vehicle[]>; type Vehicle = { name: string; model: string; manufacturer: string; cost_in_credits: string; length: string; max_atmosphering_speed: string; crew: string; passengers: string; cargo_capacity: string; consumables: string; vehicle_class: string; pilots: Array<string>; films: Array<string>; created: string; edited: string; url: string; }; type VehicleSchema = { $schema: string; type: string; properties: { name: { type: string; }; model: { type: string; }; manufacturer: { type: string; }; cost_in_credits: { type: string; }; length: { type: string; }; max_atmosphering_speed: { type: string; }; crew: { type: string; }; passengers: { type: string; }; cargo_capacity: { type: string; }; consumables: { type: string; }; vehicle_class: { type: string; }; pilots: { type: string; items: Array<{ type: string; }>; }; films: { type: string; items: Array<{ type: string; }>; }; created: { type: string; }; edited: { type: string; }; url: { type: string; }; }; required: Array<string>; }; type vehicles_Vehicle = Vehicle; type vehicles_VehicleSchema = VehicleSchema; declare const vehicles_getVehicleById: typeof getVehicleById; declare const vehicles_getVehicleSchema: typeof getVehicleSchema; declare const vehicles_getVehicles: typeof getVehicles; declare const vehicles_searchVehicles: typeof searchVehicles; declare namespace vehicles { export { type vehicles_Vehicle as Vehicle, type vehicles_VehicleSchema as VehicleSchema, vehicles_getVehicleById as getVehicleById, vehicles_getVehicleSchema as getVehicleSchema, vehicles_getVehicles as getVehicles, vehicles_searchVehicles as searchVehicles }; } export { type Film, type FilmSchema, type Person, type PersonSchema, type Planet, type PlanetSchema, type Root, type Species, type SpeciesSchema, type Starship, type StarshipSchema, type Vehicle, type VehicleSchema, films, people, planets, root, species, starships, vehicles };