swapi.info a simple, fast, GET-only JSON placeholder alternative to swapi.dev

https://swapi.info An Open-Source, CDN-powered, Uber-fast, highly-available, GET-only JSON APIs with an Explorer for better discoverability and beginner-friendliness.

Sivaram P
3 min readAug 27, 2023
https://swapi.info

Powered by Cloudflare Pages & built using Next.js 13’s latest features

View the Open-Source Repo

Status Monitoring to ensure APIs & Explorer are up and running at all times & provide up-time visibility & Health status to admins & users alike.

swapi.info Status monitoring page

SWAPI.INFO API Explorer View

swapi.info API Explorer

Play around with the API usage examples on demo Stackblitz project :)

For my peeps who don’t want to leave this page 😀

// TO Explore all the available APIs on SWAPI.INFO, please visit the explorer
// https://swapi.info

const API_URL = "https://swapi.info/api";

async function fetchRootUrls() {
try {
const response = await fetch(API_URL);
const data = await response.json();

console.log(data);

// Response:
// const data = {
// films: 'https://swapi.info/api/films',
// people: 'https://swapi.info/api/people',
// planets: 'https://swapi.info/api/planets',
// species: 'https://swapi.info/api/species',
// vehicles: 'https://swapi.info/api/vehicles',
// starships: 'https://swapi.info/api/starships',
// };
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchSwapiFilms() {
try {
const response = await fetch(API_URL + "/films");
const data = await response.json();

console.log(data);
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchSwapiPeople(showLog = true) {
try {
console.time("fetching all people");
const response = await fetch(API_URL + "/people");
const data = await response.json();

if (showLog) {
console.log(data);
}
console.timeEnd("fetching all people");
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchSwapiPlanets() {
try {
const response = await fetch(API_URL + "/planets");
const data = await response.json();

console.log(data);
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchSwapiSpecies() {
try {
const response = await fetch(API_URL + "/species");
const data = await response.json();

console.log(data);
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchSwapiVehicles() {
try {
const response = await fetch(API_URL + "/vehicles");
const data = await response.json();

console.log(data);
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchSwapiStarships() {
try {
const response = await fetch(API_URL + "/starships");
const data = await response.json();

console.log(data);
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchIndividualSwapiFilm(id = 1) {
try {
const response = await fetch(API_URL + "/films/" + id);
const data = await response.json();

console.log(data);
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchIndividualSwapiPerson(showLog = true, id = 1) {
try {
console.time("fetching all people");
const response = await fetch(API_URL + "/people/" + id);
const data = await response.json();

if (showLog) {
console.log(data);
}
console.timeEnd("fetching all people");
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchIndividualSwapiPlanet(id = 1) {
try {
const response = await fetch(API_URL + "/planets/" + id);
const data = await response.json();

console.log(data);
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchIndividualSwapiSpecie(id = 1) {
try {
const response = await fetch(API_URL + "/species/" + id);
const data = await response.json();

console.log(data);
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchIndividualSwapiVehicle(id = 1) {
try {
const response = await fetch(API_URL + "/vehicles/" + id);
const data = await response.json();

console.log(data);
} catch (error) {
console.log(error);
process.exit(1);
}
}

async function fetchIndividualSwapiStarship(id = 1) {
try {
const response = await fetch(API_URL + "/starships/" + id);
const data = await response.json();

console.log(data);
} catch (error) {
console.log(error);
process.exit(1);
}
}

fetchRootUrls();
fetchSwapiFilms();
fetchSwapiPeople();
fetchSwapiPlanets();
fetchSwapiSpecies();
fetchSwapiVehicles();
fetchSwapiStarships();

fetchIndividualSwapiFilm(2);
fetchIndividualSwapiPerson(3);
fetchIndividualSwapiPlanet(4);
fetchIndividualSwapiSpecie(5);
fetchIndividualSwapiVehicle(6);
fetchIndividualSwapiStarship(10);

Hope you enjoy using the service, it was a great learning experience for myself and a start to a journey of giving back to the wonderful web dev community

Happy Hacking & Adios 👋

--

--