Menu

Free images for SWAPI (The Star Wars API) — no API key, CORS enabled
📰

Free images for SWAPI (The Star Wars API) — no API key, CORS enabled

DEV Community: react·Sergio Coitiño·18 days ago
#tBTOG6Dr
#devtoreact#devto#dev#const#swapi
Reading 0:00
15s threshold

SWAPI (The Star Wars API) is one of the most popular free APIs for learning REST APIs in React, Vue, or vanilla JS — but it only returns JSON text. There are no images for Luke Skywalker, Tatooine, or the Millennium Falcon.

Furthermore, the old image host frequently used in tutorials (starwars-visualguide.com) currently has broken SSL certificates, failing to load across modern browsers.

To solve this, I created a free static image API where every image matches the exact same ID used by SWAPI:

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

It covers 238 images across 5 categories: people, planets, species, starships, and vehicles.

How to Use It (JavaScript)

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

// Fetch data from SWAPI const res = await fetch('https://swapi.dev/api/people/1/'); const luke = await res.json();

// Get the matching image…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.