SWAPI - Star Wars API
swapi.dev · Developer Tools
All Star Wars data — people, films, starships, vehicles, species, and planets. Classic beginner API. Free, no API key required.
Authentication
No authentication requiredFree to use with no key needed.
Sample Requests
GET
Get all films
Get all Star Wars films.
https://swapi.dev/api/films
Hover any highlighted part to learn what it does
curl -X GET "https://swapi.dev/api/films/"
import requests
response = requests.get(
"https://swapi.dev/api/films/",
)
print(response.json())const url = 'https://swapi.dev/api/films/'; const response = await fetch(url); const data = await response.json(); console.log(data);
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://swapi.dev/api/films/"
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://swapi.dev/api/films/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://swapi.dev/api/films/";
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
Get a person
Get Luke Skywalker's data.
https://swapi.dev/api/people/1
Hover any highlighted part to learn what it does
curl -X GET "https://swapi.dev/api/people/1/"
import requests
response = requests.get(
"https://swapi.dev/api/people/1/",
)
print(response.json())const url = 'https://swapi.dev/api/people/1/'; const response = await fetch(url); const data = await response.json(); console.log(data);
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://swapi.dev/api/people/1/"
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://swapi.dev/api/people/1/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://swapi.dev/api/people/1/";
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- No API key needed
- People: GET /people/?search=darth
- Films: GET /films/
- Starships: GET /starships/
- Planets: GET /planets/
- Vehicles: GET /vehicles/