SWAPI Images API — Free Images for The Star Wars API

SWAPI returns only JSON text — no pictures. This free API serves 238 images for SWAPI people, planets, species, starships and vehicles, using exactly the same IDs as SWAPI. No API key, CORS enabled.

URL pattern

https://starwarsgallery.netlify.app/assets/{category}/{id}.jpg

Quick example

Luke Skywalker — SWAPI people 1
people/1 Luke Skywalker
Tatooine — SWAPI planets 1
planets/1 Tatooine
Wookiee — SWAPI species 3
species/3 Wookiee
Millennium Falcon — SWAPI starships 10
starships/10 Millennium Falcon
Snowspeeder — SWAPI vehicles 14
vehicles/14 Snowspeeder

Endpoints

CategorySWAPI endpointImage URLImages
Peopleswapi.dev/api/people/{id}//assets/people/{id}.jpg87
Planetsswapi.dev/api/planets/{id}//assets/planets/{id}.jpg38
Speciesswapi.dev/api/species/{id}//assets/species/{id}.jpg37
Starshipsswapi.dev/api/starships/{id}//assets/starships/{id}.jpg37
Vehiclesswapi.dev/api/vehicles/{id}//assets/vehicles/{id}.jpg39

Full list of available IDs (JSON): https://starwarsgallery.netlify.app/api/images.json. Works with SWAPI mirrors that keep the same IDs: swapi.dev, swapi.py4e.com, swapi.tech.

How to use it

JavaScript

const getSwapiImage = (category, swapiUrl) => {
  const id = swapiUrl.split('/').filter(Boolean).pop();
  return `https://starwarsgallery.netlify.app/assets/${category}/${id}.jpg`;
};

const res = await fetch('https://swapi.dev/api/people/1/');
const luke = await res.json();
const image = getSwapiImage('people', luke.url);
// "https://starwarsgallery.netlify.app/assets/people/1.jpg"

React (with fallback)

function SwapiImage({ category, id, name }) {
  const [src, setSrc] = React.useState(
    `https://starwarsgallery.netlify.app/assets/${category}/${id}.jpg`
  );
  return (
    <img
      src={src}
      alt={name}
      loading="lazy"
      onError={() => setSrc('/placeholder.jpg')}
    />
  );
}

Python

import requests

planet = requests.get("https://swapi.dev/api/planets/1/").json()
planet_id = planet["url"].rstrip("/").split("/")[-1]
image_url = f"https://starwarsgallery.netlify.app/assets/planets/{planet_id}.jpg"

HTML

<img src="https://starwarsgallery.netlify.app/assets/starships/10.jpg" alt="Millennium Falcon">

Features

FAQ

Does SWAPI provide images?

No. SWAPI only returns JSON. This API fills that gap using the same resource IDs.

What if an ID has no image?

The server returns 404. Check images.json for the list of available IDs.

Can I use it in commercial projects?

The API is free for personal, educational and portfolio projects. See the terms below.

Terms & credits

Unofficial fan project, not affiliated with Lucasfilm or Disney. Star Wars and all associated names and images are copyright Lucasfilm Ltd. Images were collected from Wookieepedia. Data comes from SWAPI. Please use the images for non-commercial, educational and portfolio purposes. The service is provided as-is, without guarantees of availability.

This API is free. If it helped your project, consider supporting the developer and the hosting costs.

Donate with PayPal Open the Star Wars Gallery