SWAPI (Star Wars) API
Free Star Wars API with no key: people, films, starships, vehicles, species and planets with linked resources. Classic learning API. Tested curl example.
Endpoint tested and returned HTTP 200 on 2026-08-19
What is the SWAPI (Star Wars) API?
SWAPI is a free, key-free Star Wars API providing data on characters, films, starships, vehicles, species and planets, with resources linked to each other by URL.
SWAPI was one of the first widely used free public APIs and it remains a solid teaching tool. Its resources are richly cross-linked — a character links to their films, starships and homeworld — which makes it a natural way to teach following relationships across requests.
One thing to be aware of when parsing: numeric fields such as height, mass and population are returned as strings, and unknown values appear as the literal strings `unknown` or `n/a` rather than null. Any arithmetic needs to guard against those.
Quick facts
- Base URL
https://swapi.dev/api- Authentication
- No key required.
- Rate limit
- 10,000 requests per day per IP.
- Pricing
- Free.
- CORS
- Enabled — callable directly from browser JavaScript
- Official docs
- Read the docs
How to use the SWAPI (Star Wars) API
Every request below was executed against the live API on 2026-08-19, and the response shown is the real body it returned — not an illustration.
1. Fetch a Star Wars character
GET https://swapi.dev/api/people/1/
curl 'https://swapi.dev/api/people/1/'const res = await fetch("https://swapi.dev/api/people/1/");
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);import requests
res = requests.get("https://swapi.dev/api/people/1/", timeout=20)
res.raise_for_status()
print(res.json()){
"name": "Luke Skywalker",
"height": "172",
"mass": "77",
"hair_color": "blond",
"skin_color": "fair",
"eye_color": "blue",
"birth_year": "19BBY",
"gender": "male",
"homeworld": "https://swapi.dev/api/planets/1/",
"films": [
"https://swapi.dev/api/films/1/",
"https://swapi.dev/api/films/2/",
"https://swapi.dev/api/films/3/",
"https://swapi.dev/api/films/6/"
],
"species": [],
"vehicles": [
"https://swapi.dev/api/vehicles/14/",
"https://swapi.dev/api/vehicles/30/"
],
"starships": [
"https://swapi.dev/api/starships/12/",
"https://swapi.dev/api/starships/22/"
],
"created": "2014-12-09T13:50:51.644000Z",
"edited": "2014-12-20T21:17:56.891000Z",
"url": "https://swapi.dev/api/people/1/"
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
<resource> | path | Required | people, films, starships, vehicles, species or planets. people |
<id> | path | Optional | Numeric resource id. 1 |
search | query | Optional | Search within a resource type. luke |
page | integer | Optional | Page number; results paginate at 10 per page. 2 |
Response fields
namestring- Resource name.
height / massstring- Returned as strings; may be `unknown`.
filmsarray- URLs of films the resource appears in — follow them for details.
homeworldstring- URL of the planet resource, not an embedded object.
count / next / previousinteger|string- Pagination metadata on list endpoints.
What you can build with the SWAPI (Star Wars) API
- Teach linked-resource traversal across multiple requests
- Build a Star Wars encyclopaedia or quiz app
- Practise pagination and search against a stable dataset
- Demonstrate defensive parsing of inconsistent string values
Common errors and how to fix them
NaN in calculations
Numeric fields are strings and may be `unknown`.
Fix: Guard with a check for `unknown`/`n/a` before parsing to a number.
Occasional downtime or TLS errors
SWAPI has had reliability issues over the years.
Fix: Handle failures gracefully; community mirrors exist if the main host is unavailable.
SWAPI (Star Wars) API — frequently asked questions
Is SWAPI free to use?
Yes, free with no API key, limited to around 10,000 requests per day per IP.
Why are height and mass returned as strings?
SWAPI returns all values as strings, and uses the literal text `unknown` or `n/a` where data is missing. Check for those before parsing to a number, or you will get NaN.
How do I get a character's films?
The `films` field contains an array of URLs rather than embedded objects. Fetch each URL for the film details — this linked design is what makes SWAPI good for teaching.
Is SWAPI still maintained?
It has had reliability wobbles over the years and is not actively developed, so build in error handling. Community mirrors exist if the primary host is down.
Tools that pair with this API
JSON Formatter
Format, beautify and minify JSON online with 2-space, 4-space or tab indentation. Sort keys alphabetically and catch syntax errors instantly — free and private.
Unit Converter
Convert between units of length, weight, temperature, area, volume, speed, time and data storage instantly, with a swap button and common conversion tables.
SWAPI (Star Wars) is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-19; always check the official documentation before relying on this API in production, as terms and limits can change.