BYTETOOLS

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.

No API key requiredCORS enabledHTTPSFree tier

Endpoint tested and returned HTTP 200 on 19 Aug 2026

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 19 Aug 2026, 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
curl 'https://swapi.dev/api/people/1/'
JavaScript (fetch)
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);
Python (requests)
import requests

res = requests.get("https://swapi.dev/api/people/1/", timeout=20)
res.raise_for_status()
print(res.json())
Response — HTTP 200
{
  "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

ParameterTypeRequiredDescription
<resource>pathRequiredpeople, films, starships, vehicles, species or planets. people
<id>pathOptionalNumeric resource id. 1
searchqueryOptionalSearch within a resource type. luke
pageintegerOptionalPage 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

Alternatives to SWAPI (Star Wars) API

If SWAPI (Star Wars) does not fit, these game & anime apis cover similar ground. Every one was called before publishing, and each links to its own reference page with a working curl command and the response it returned.

APIWhat it doesAuthCORSLast verified
PokéAPIFree Pokémon API with no key: stats, types, abilities, moves, evolutions and sprites for 1,000+ species. The most popular API for learning REST. Tested example.No keyYes19 Aug 2026
Rick and Morty APIFree Rick and Morty API with no key: 800+ characters, episodes and locations with images, filtering and pagination. REST and GraphQL. Tested example.No keyYes19 Aug 2026
Jikan (MyAnimeList)Free unofficial MyAnimeList API with no key: anime and manga data, scores, characters, staff and seasonal listings. Tested curl example and live JSON.No keyYes19 Aug 2026
Deck of CardsFree playing card API with no key: shuffle decks, draw cards, manage piles and get card images. Stateful deck ids. Tested curl example and live JSON.No keyYes19 Aug 2026
TCGdexFree Pokémon Trading Card Game API with no key: every set and card in 10+ languages, with images, card counts and full card data. Tested curl example included.No keyYes21 Aug 2026
TETR.IO Tetra ChannelFree TETR.IO Tetra Channel API with no key: player records, TETRA LEAGUE ranks, global leaderboards and live service-wide statistics. Tested example and real response.No keyNo21 Aug 2026
All Game & Anime APIs

SWAPI (Star Wars) is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 19 Aug 2026; always check the official documentation before relying on this API in production, as terms and limits can change.