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

people/1 Luke Skywalker
planets/1 Tatooine
species/3 Wookiee
starships/10 Millennium Falcon
vehicles/14 SnowspeederEndpoints
| Category | SWAPI endpoint | Image URL | Images |
|---|---|---|---|
| People | swapi.dev/api/people/{id}/ | /assets/people/{id}.jpg | 87 |
| Planets | swapi.dev/api/planets/{id}/ | /assets/planets/{id}.jpg | 38 |
| Species | swapi.dev/api/species/{id}/ | /assets/species/{id}.jpg | 37 |
| Starships | swapi.dev/api/starships/{id}/ | /assets/starships/{id}.jpg | 37 |
| Vehicles | swapi.dev/api/vehicles/{id}/ | /assets/vehicles/{id}.jpg | 39 |
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
- Same IDs as SWAPI — no mapping table needed.
- CORS enabled (
Access-Control-Allow-Origin: *) — works withfetch(),<img>,<canvas>and mobile apps. - No API key and no sign-up.
- Real HTTP 404 for missing images, so
onErrorfallbacks work. - Fast static CDN hosting with browser caching.
- A drop-in alternative for projects that used the old
starwars-visualguide.comimage URLs.
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