├── client
├── public
│ └── .gitkeep
├── src
│ ├── styles
│ │ ├── base
│ │ │ ├── .gitkeep
│ │ │ └── _common.scss
│ │ ├── pages
│ │ │ ├── .gitkeep
│ │ │ ├── _about.scss
│ │ │ ├── _docs.scss
│ │ │ └── _home-page.scss
│ │ ├── themes
│ │ │ └── .gitkeep
│ │ ├── vendors
│ │ │ └── .gitkeep
│ │ ├── abstracts
│ │ │ ├── .gitkeep
│ │ │ ├── _variables.scss
│ │ │ └── _animations.scss
│ │ ├── components
│ │ │ ├── .gitkeep
│ │ │ ├── _paypal-button.scss
│ │ │ └── _banner-ad.scss
│ │ ├── layout
│ │ │ ├── .gitkeep
│ │ │ ├── _footer.scss
│ │ │ ├── _swapi-header.scss
│ │ │ ├── _navbar.scss
│ │ │ └── _layout.scss
│ │ └── main.scss
│ ├── assets
│ │ └── images
│ │ │ └── saber-masters
│ │ │ ├── bogo-text.webp
│ │ │ ├── dual-grey.webp
│ │ │ ├── dual-red.webp
│ │ │ ├── gold-black.webp
│ │ │ ├── jedi-hand.webp
│ │ │ ├── logo_new.avif
│ │ │ ├── red-banner.webp
│ │ │ ├── dual-silver.webp
│ │ │ ├── gold-silver.webp
│ │ │ ├── red-banner-2.webp
│ │ │ ├── red-banner-3.webp
│ │ │ ├── silver-gunsmoke.webp
│ │ │ ├── Cinematic_SI_UGC_Tiara.avif
│ │ │ └── silver-black-blue-blades.webp
│ ├── main.jsx
│ ├── components
│ │ ├── SwapiHeader.jsx
│ │ ├── Footer.jsx
│ │ ├── Navbar.jsx
│ │ ├── affiliate
│ │ │ ├── BannerAds.jsx
│ │ │ └── PayPalButton.jsx
│ │ └── common
│ │ │ ├── LoadingSpinner.jsx
│ │ │ └── AtAtSpinner.jsx
│ ├── hooks
│ │ └── useDebounce.js
│ ├── App.jsx
│ ├── layouts
│ │ └── Layout.jsx
│ └── pages
│ │ ├── AdClickRedirectPage.jsx
│ │ ├── HomePage.jsx
│ │ ├── AboutPage.jsx
│ │ └── DocsPage.jsx
├── vite.config.js
├── package.json
├── eslint.config.js
└── index.html
├── Procfile
├── ads.txt
├── server
├── index.js
├── utils
│ ├── isWookiee.js
│ ├── cache.js
│ └── wookieeEncoding.js
├── middleware
│ ├── connectDb.js
│ ├── encodingFormat.js
│ ├── setUrl.js
│ ├── checkKey.js
│ ├── limiters.js
│ └── addAdURL.js
├── routes
│ ├── rootRoutes.js
│ ├── countRoutes.js
│ ├── adClickRoutes.js
│ ├── filmRoutes.js
│ ├── planetRoutes.js
│ ├── peopleRoutes.js
│ ├── speciesRoutes.js
│ ├── vehicleRoutes.js
│ └── starshipRoutes.js
├── models
│ ├── AdClickModel.js
│ ├── PlanetModel.js
│ ├── FilmModel.js
│ ├── SpeciesModel.js
│ ├── PeopleModel.js
│ ├── VehicleModel.js
│ └── StarshipModel.js
├── config
│ ├── config.js
│ └── dbConfig.js
├── services
│ ├── rootService.js
│ ├── filmService.js
│ ├── countService.js
│ ├── peopleService.js
│ ├── planetService.js
│ ├── speciesService.js
│ ├── vehicleService.js
│ ├── adClickService.js
│ └── starshipService.js
├── controllers
│ ├── countController.js
│ ├── rootController.js
│ ├── filmController.js
│ ├── adClickController.js
│ ├── peopleController.js
│ ├── vehicleController.js
│ ├── starshipController.js
│ ├── planetController.js
│ └── speciesController.js
├── package.json
├── app
│ ├── routes.js
│ ├── index.js
│ └── middleware.js
└── helpers
│ └── pagination.js
├── .editorconfig
├── .gitignore
├── package.json
├── LICENSE
├── CONTRIBUTORS.md
├── CONTRIBUTING.md
└── README.md
/client/public/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | web: npm start
2 |
--------------------------------------------------------------------------------
/ads.txt:
--------------------------------------------------------------------------------
1 | google.com, pub-6008860561343019, DIRECT, f08c47fec0942fa0
2 |
--------------------------------------------------------------------------------
/client/src/styles/base/.gitkeep:
--------------------------------------------------------------------------------
1 | Resets, typography, general global styles
--------------------------------------------------------------------------------
/client/src/styles/pages/.gitkeep:
--------------------------------------------------------------------------------
1 | Page-specific styles (home, about, docs, etc)
--------------------------------------------------------------------------------
/client/src/styles/themes/.gitkeep:
--------------------------------------------------------------------------------
1 | Different them styles (light, dark mode, etc)
--------------------------------------------------------------------------------
/client/src/styles/vendors/.gitkeep:
--------------------------------------------------------------------------------
1 | Third-party styles (Bootstrap, external css, etc)
--------------------------------------------------------------------------------
/client/src/styles/abstracts/.gitkeep:
--------------------------------------------------------------------------------
1 | Global helpers (variables, functions, mixins, etc)
--------------------------------------------------------------------------------
/client/src/styles/components/.gitkeep:
--------------------------------------------------------------------------------
1 | Reusable UI copmonents (buttons, cards, navbar)
--------------------------------------------------------------------------------
/client/src/styles/layout/.gitkeep:
--------------------------------------------------------------------------------
1 | Structural styles (header, footer, grid, sidebar, etc)
--------------------------------------------------------------------------------
/server/index.js:
--------------------------------------------------------------------------------
1 | const { startServer } = require("./app");
2 |
3 | startServer();
4 |
--------------------------------------------------------------------------------
/server/utils/isWookiee.js:
--------------------------------------------------------------------------------
1 | module.exports = isWookiee = (req) => {
2 | return req.encoding === "wookiee";
3 | };
4 |
--------------------------------------------------------------------------------
/client/src/styles/layout/_footer.scss:
--------------------------------------------------------------------------------
1 | .footer {
2 | a {
3 | color: #ffffff;
4 |
5 | &:hover {
6 | border-bottom: 1px solid;
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/bogo-text.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/bogo-text.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/dual-grey.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/dual-grey.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/dual-red.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/dual-red.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/gold-black.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/gold-black.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/jedi-hand.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/jedi-hand.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/logo_new.avif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/logo_new.avif
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/red-banner.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/red-banner.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/dual-silver.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/dual-silver.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/gold-silver.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/gold-silver.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/red-banner-2.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/red-banner-2.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/red-banner-3.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/red-banner-3.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/silver-gunsmoke.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/silver-gunsmoke.webp
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/Cinematic_SI_UGC_Tiara.avif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/Cinematic_SI_UGC_Tiara.avif
--------------------------------------------------------------------------------
/client/src/assets/images/saber-masters/silver-black-blue-blades.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/semperry/swapi/HEAD/client/src/assets/images/saber-masters/silver-black-blue-blades.webp
--------------------------------------------------------------------------------
/client/src/styles/abstracts/_variables.scss:
--------------------------------------------------------------------------------
1 | $main-text-color: #c8c8c8;
2 | $main-background: #272b30;
3 | $swapi-yellow: #ffe300;
4 | $navbar-height: 50px;
5 |
6 | .yellow {
7 | color: $swapi-yellow;
8 | }
--------------------------------------------------------------------------------
/server/middleware/connectDb.js:
--------------------------------------------------------------------------------
1 | const dbConfig = require("../app/dbConfig");
2 |
3 | async function connectDb(req, res, next) {
4 | await dbConfig();
5 | next();
6 | }
7 |
8 | module.exports = connectDb;
9 |
--------------------------------------------------------------------------------
/client/src/styles/components/_paypal-button.scss:
--------------------------------------------------------------------------------
1 | #donate-form {
2 | text-align: center;
3 | filter: brightness(50%);
4 | transition: 0.3s ease-in-out all;
5 |
6 | &:hover {
7 | filter: brightness(100%);
8 | }
9 | }
--------------------------------------------------------------------------------
/server/routes/rootRoutes.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const rootController = require("../controllers/rootController");
3 |
4 | const router = express.Router();
5 |
6 | router.get("/", rootController.getRootData);
7 |
8 | module.exports = router;
9 |
--------------------------------------------------------------------------------
/server/routes/countRoutes.js:
--------------------------------------------------------------------------------
1 | const countRouter = require("express").Router();
2 | const countController = require("../controllers/countController");
3 |
4 | // Get counts
5 | countRouter.get("/all", countController.getCounts);
6 |
7 | module.exports = countRouter;
8 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = tab
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.{js,jsx,ts,tsx}]
12 | indent_style = tab
13 | indent_size = 2
14 |
--------------------------------------------------------------------------------
/client/src/main.jsx:
--------------------------------------------------------------------------------
1 | import { StrictMode } from "react";
2 | import { createRoot } from "react-dom/client";
3 |
4 | import App from "./App.jsx";
5 | import "./styles/main.scss";
6 |
7 | createRoot(document.getElementById("root")).render(
8 |
The Star Wars API
6 | 7 |8 | "In my experience, there's no such thing as luck. Big changes are 9 | coming, and we must be prepared."{" "} 10 |
11 | 12 |Over 3,000,000+ API requests served every day!
13 |
45 |
{props.message}
113 | > 114 | ); 115 | }; 116 | 117 | export default AtAtSpinner; 118 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # Contributors ✨ 2 | 3 | Swapi is an open-source project made possible by contributions from an amazing community. Below is a list of people who have helped improve and maintain this project in various ways. 4 | 5 | We appreciate all contributions whether it's code, documentation, bug reports, ideas, community support, third-party integrations, or financial support. Want to contribute? Check out our [CONTRIBUTING.md](CONTRIBUTING.md) guide! 6 | 7 | --- 8 | 9 | ## 🔧 Maintainer 10 | 11 | - **[Ryan Curtis](https://github.com/semperry)** – Current maintainer & lead developer 12 | 13 | --- 14 | 15 | ## 🏛️ Original Creators (swapi.co) 16 | 17 | Special thanks to the original team who built swapi.co and laid the foundation for this project: 18 | 19 | - **[Paul Hallett](https://github.com/phalt)** – Creator of swapi.co 20 | 21 | --- 22 | 23 | ## 🚀 Code Contributors 24 | 25 | Those who have directly contributed to swapi.tech's core codebase. 26 | 27 | - **[Frankieali](https://github.com/frankieali)** – 'Expanded' query parameter for full result properties 28 | 29 | --- 30 | 31 | ## 🔌 Integrations & SDKs 32 | 33 | Developers who have built tools, wrappers, or third-party libraries to extend swapi.tech. 34 | 35 | - **[Carrie Mathieu](https://github.com/carriemathieu)** – Built the **Ruby gem [sw_tour](https://github.com/carriemathieu/sw_tour)** for swapi.tech 36 | - **[Ryan Curtis](https://github.com/semperry)** – Created **[react-swapi](https://www.npmjs.com/package/react-swapi)** wrapper for swapi.tech 37 | 38 | --- 39 | 40 | ## 📝 Documentation 41 | 42 | Contributors who improved the API docs, examples, and guides. 43 | 44 | - _(No contributors yet. Want to help? Open an issue or PR!)_ 45 | 46 | ## 🐛 Bug Reports & Testing 47 | 48 | Users who reported bugs or helped with testing. 49 | 50 | - **[Abhay Lokesh](https://github.com/abhay-lokesh)** – Identified a discrepency between documenation and data being returned by the people api 51 | - **[Rodrigo Deodoro](https://github.com/roddds)** – Reported search api break after a library update 52 | 53 | --- 54 | 55 | ## 🌱 Ideas & Suggestions 56 | 57 | People who provided valuable insights, suggestions, or feature requests. 58 | 59 | - _(No contributors yet. Want to help? Open an issue or PR!)_ 60 | 61 | ## 📢 Community & Support 62 | 63 | People who help answer questions, support users, or spread the word about swapi.tech. 64 | 65 | - _(No contributors yet. Want to help? Open an issue or PR!)_ 66 | 67 | --- 68 | 69 | ## 💖 Donors & Supporters 70 | 71 | A huge thank you to those who have financially supported Swapi! Your contributions help keep the project running and improve its development. 72 | 73 | - **[Sean Doyle](https://github.com/HumberSean)** - Supported Swapi financially 74 | - **[Norman MacPherson](https://github.com/leemacpherson)** – Supported Swapi financially 75 | - **[Tom Power](https://github.com/TPower2112)** – Supported Swapi financially 76 | - **[Andrew Wold](https://github.com/Andrewf9001)** – Supported Swapi financially 77 | - _(Donated? Add yourself here!)_ 78 | 79 | Thank you all so much!!! 80 | 81 | --- 82 | 83 | ## Want to be listed here? 84 | 85 | Contributions of all types are welcome! If you've contributed to Swapi in any way and aren't listed, feel free to submit a pull request to be added. 86 | -------------------------------------------------------------------------------- /client/src/styles/pages/_home-page.scss: -------------------------------------------------------------------------------- 1 | .content-container { 2 | text-align: center; 3 | 4 | .input-group { 5 | .input-group-addon { 6 | padding: 8px 12px; 7 | font-size: 14px; 8 | font-weight: normal; 9 | line-height: 1; 10 | color: #272b30; 11 | text-align: center; 12 | background-color: #999999; 13 | border: 1px solid #cccccc; 14 | border-radius: 4px; 15 | } 16 | 17 | .input-group-control { 18 | width: 33%; 19 | padding: 7px 12px; 20 | font-size: 14px; 21 | line-height: 1.42857143; 22 | color: #272b30; 23 | background-color: #ffffff; 24 | border: 1px solid #cccccc; 25 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); 26 | transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; 27 | } 28 | 29 | .input-group-btn { 30 | background-image: linear-gradient(#8a9196, #7a8288 60%, #70787d); 31 | .btn { 32 | text-align: center; 33 | cursor: pointer; 34 | background-image: none; 35 | border: 1px solid transparent; 36 | padding: 8px 12px; 37 | font-size: 14px; 38 | line-height: 1.42857143; 39 | border-radius: 4px; 40 | border-bottom-left-radius: 0; 41 | border-top-left-radius: 0; 42 | } 43 | 44 | .btn-primary { 45 | background-repeat: no-repeat; 46 | background-color: #7a8288; 47 | 48 | &:hover { 49 | background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); 50 | border-color: rgba(0, 0, 0, 0.6); 51 | text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); 52 | } 53 | } 54 | } 55 | 56 | :first-child { 57 | border-right: 0; 58 | border-bottom-right-radius: 0; 59 | border-top-right-radius: 0; 60 | background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); 61 | border-color: rgba(0, 0, 0, 0.6); 62 | background-repeat: no-repeat; 63 | color: #ffffff; 64 | } 65 | } 66 | 67 | .example-routes-wrapper { 68 | width: 100%; 69 | position: relative; 70 | right: 15%; 71 | 72 | a { 73 | color: #ffffff; 74 | &:hover { 75 | border-bottom: 1px solid #ffffff; 76 | } 77 | } 78 | } 79 | 80 | .result-header { 81 | position: relative; 82 | right: 24.5%; 83 | padding-top: 34px; 84 | font-weight: 300; 85 | margin-bottom: 20px; 86 | line-height: 1.4; 87 | font-size: 21px; 88 | } 89 | 90 | .json-content { 91 | display: flex; 92 | justify-content: center; 93 | align-items: center; 94 | text-align: center; 95 | min-height: 20px; 96 | 97 | .well { 98 | max-width: 50%; 99 | padding: 19px; 100 | margin-bottom: 20px; 101 | background-color: #1c1e22; 102 | border: 1px solid #0c0d0e; 103 | border-radius: 4px; 104 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); 105 | 106 | .react-json-view { 107 | overflow: scroll; 108 | } 109 | } 110 | } 111 | 112 | .bottom-row { 113 | padding-bottom: 34px; 114 | display: grid; 115 | gap: 50px; 116 | grid-template-columns: 1fr 1fr 1fr; 117 | text-align: left; 118 | margin-left: 100px; 119 | margin-right: 100px; 120 | h4 { 121 | text-align: center; 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /client/src/pages/HomePage.jsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect, useCallback } from "react"; 2 | import { Link } from "react-router-dom"; 3 | 4 | import AtAtSpinner from "../components/common/AtAtSpinner"; 5 | import useDebounce from "../hooks/useDebounce"; 6 | 7 | const HomePage = () => { 8 | const [endpoint, setEndpoint] = useState(""); 9 | const [currentData, setCurrentData] = useState(null); 10 | const [isDataLoading, setIsDataLoading] = useState(true); 11 | const debouncedEndpoint = useDebounce(endpoint); 12 | 13 | const handleFetchPreview = useCallback( 14 | (signal) => { 15 | setIsDataLoading(true); 16 | 17 | fetch(`/api/${endpoint}`, { signal }) 18 | .then((res) => res.json()) 19 | .then((data) => { 20 | setCurrentData(data); 21 | setIsDataLoading(false); 22 | }) 23 | .catch((err) => { 24 | console.log(err); 25 | if (!signal.aborted) { 26 | setIsDataLoading(false); 27 | } 28 | }); 29 | }, 30 | [endpoint] 31 | ); 32 | 33 | const handleChange = (e) => { 34 | setIsDataLoading(true); 35 | setEndpoint(e.target.value); 36 | }; 37 | 38 | const renderData = () => { 39 | if (isDataLoading) 40 | return ( 41 |{JSON.stringify(currentData, null, 2)};
48 | } else {
49 | return null;
50 | }
51 | };
52 |
53 | useEffect(() => {
54 | const abortController = new AbortController();
55 | const signal = abortController.signal;
56 |
57 | if (debouncedEndpoint || !currentData) {
58 | handleFetchPreview(signal);
59 | }
60 |
61 | return () => abortController.abort();
62 | }, [debouncedEndpoint]);
63 |
64 | return (
65 | All the Star Wars data you've ever wanted:
69 |70 | Planets, Spaceships, Vehicles, People, Films and Species 71 |
72 |Result:
116 |125 | The Star Wars API, or "swapi" (Swah-pee) is the world's first 126 | quantified and programmatically-accessible data source for all the 127 | data from the Star Wars canon universe! 128 |
129 |130 | We've taken all the rich contextual stuff from the universe and 131 | formatted into something easier to consume with software. Then we 132 | went and stuck an API on the front so you can access it all! 133 |
134 |138 | All the data is accessible through our HTTP web API. Consult our{" "} 139 | documentation if you'd like to get 140 | started. 141 |
142 |146 | The original swapi.co is not supported or maintained anymore. But 147 | since so many of my projects and tutorials used it, as well as my 148 | colleagues I decided to rebuild it from (almost) scratch. 149 |
150 |12 | {stat[0].toUpperCase() + stat.slice(1)}: {counts[stat]} 13 |
14 | ); 15 | }); 16 | }; 17 | 18 | useEffect(() => { 19 | const abortController = new AbortController(); 20 | const signal = abortController.signal; 21 | 22 | fetch("/count/all", { signal }) 23 | .then((res) => res.json()) 24 | .then((data) => setCounts(data.counts)) 25 | .catch((err) => console.log(err)); 26 | 27 | return () => abortController.abort(); 28 | }, []); 29 | 30 | return ( 31 |From the prequel:
40 |41 | "The Star Wars API is the world's first quantified and 42 | programmatically-formatted set of Star Wars data. 43 |
44 | 45 |46 | After hours of watching films and trawling through content online, we 47 | present to you all the{" "} 48 | 49 | People, Films, Species, Starships, Vehicles and Planets 50 | {" "} 51 | from Star Wars. 52 |
53 | 54 |55 | We've formatted this data in{" "} 56 | 57 | JSON 58 | {" "} 59 | and exposed it to you in a{" "} 60 | 61 | RESTish 62 | {" "} 63 | implementation that allows you to programmatically collect and measure 64 | the data." 65 |
66 | 67 |
68 | I have replicated the original SWAPI platform, not only as a challenge
69 | for myself ( the{" "}
70 |
75 | {" "}
76 | Official SWAPI repository{" "}
77 | {" "}
78 | takes you pretty far if you want a clone in Django),
79 | but as a way to provide a standard API for my students without fear of
80 | it being taken down
81 |
84 | 85 | Check out the documentation to get started consuming swapi data 86 | 87 |
88 | 89 |92 | Swapi.co?? Swapi.co.... That's a name I've not heard in a long time... 93 | A long time. 94 |
95 |
96 | Unfortulately swapi.co is no longer maintained, and the service is
97 | currently down. This is a personalized branch of SWAPI that I have
98 | built to continue in assisting
99 | my students (and others) with api comminucation. I will maintain it as
100 | much as possible.
101 |
106 | Use SWAPI to fetch Star Wars universe data. This api is a fantastic 107 | educational resource. 108 |
109 |110 | The original swapi had amazing helper libraries that I will steadily 111 | begin implenting. If you have one to contribute, or would like to 112 | contribute, feel free to contact me: inquiry@swapi.tech 113 |
114 | 115 |116 | Fetch people, planets, vehicles, and more.: 117 |
118 | 119 |
120 |
121 | fetch('https://www.swapi.tech/api/planets/1')
122 |
{`.then(res => res.json())`}
123 |
{`.then(data => console.log(data))`}
124 |
{`.catch(err => console.error(err);`}
125 |
126 |
127 |
128 |
129 | 132 | Originially SWAPI used{" "} 133 | 138 | Django{" "} 139 | 140 | and{" "} 141 | 146 | Django REST Framework 147 | {" "} 148 | to serve a{" "} 149 | 154 | RESTish 155 | {" "} 156 | API to you. 157 |
158 |159 | In this implementation I used{" "} 160 | 165 | React 166 | {" "} 167 | and{" "} 168 | 173 | Express 174 | {" "} 175 | to serve a{" "} 176 | 181 | monolothic 182 | {" "} 183 | style application . The data is all formatted in{" "} 184 | 185 | JSON 186 | 187 | . 188 |
189 | 190 |193 | I am{" "} 194 | 199 | Ryan Curtis 200 | 201 | , Full Stack Web Engineer and CTO. 202 |
203 | 204 |207 | This project was originally built and maintained by{" "} 208 | 209 | Paul Hallett 210 | 211 | . 212 |
213 | 214 |Star Wars and all associated names are copyright Lucasfilm ltd.
217 | 218 |This project is open source and carries a BSD licence.
219 | 220 |221 | All data has been freely collected from open sources such as{" "} 222 | 227 | Wookiepedia 228 | 229 | . 230 |
231 | 232 |233 | All data as of 5/8/2020 was collected by the original contributors. I 234 | will be adding data from the same open sources slowly but surely 235 |
236 | 237 |240 | SWAPI would not be possible without contributions from the following 241 | people: 242 |
243 | 244 |293 | I thank you for providing a solid framework to piggy back off of to 294 | continue educating the masses about api comminucation. Thank you. 295 |
296 |87 | Welcome to the swapi, the Star Wars API! This documentation should 88 | help you familiarise yourself with the resources available and how to 89 | consume them with HTTP requests. If you're after a native helper 90 | library then I suggest you scroll down and check out what's available. 91 | Read through the getting started section before you dive in. Most of 92 | your problems should be solved just by reading through it. 93 |
94 | 95 |Let's make our first API request to the Star Wars API!
97 | 98 |99 | Open up a terminal and use{" "} 100 | 105 | curl 106 | {" "} 107 | or use a{" "} 108 | 113 | fetch 114 | {" "} 115 | call to make an API request for a resource. In the example below, 116 | we're trying to get the first planet, Tatooine: 117 |
118 | 119 |
120 |
121 | {`
122 | fetch("https://www.swapi.tech/api/planets/1/")
123 | .then(res => res.json())
124 | .then(data => console.log(data))
125 | .catch(err => console.error(err))
126 | `}
127 |
128 |
129 |
130 | 131 | We'll use{" "} 132 | 137 | fetch 138 | {" "} 139 | If you don't want to use the fetch api, just use the curl{" "} 140 | command, your browser window, or{" "} 141 | 146 | Postman 147 | {" "} 148 | instead. 149 |
150 | 151 |Here is the response we get:
152 | 153 |
154 |
155 | {`{
156 | message: "ok",
157 | result: {
158 | properties: {
159 | climate: "Arid",
160 | diameter: "10465",
161 | gravity: "1 standard",
162 | name: "Tatooine",
163 | orbital_period: "304",
164 | population: "200000",
165 | residents: [
166 | "https://www.swapi.tech/api/people/1/",
167 | "https://www.swapi.tech/api/people/2/",
168 | ...
169 | ],
170 | rotation_period: "23",
171 | surface_water: "1",
172 | terrain: "Desert",
173 | url: "https://www.swapi.tech/api/planets/1/",
174 | }
175 | }
176 | ...
177 | }`}
178 |
179 |
180 |
181 | 182 | If your response looks slightly different don't panic. This is 183 | probably because more data has been added to swapi since we made this 184 | documentation. 185 |
186 | 187 |189 | The Base URL is the root URL for all of the API, if 190 | you ever make a request to swapi and you get back a{" "} 191 | 404 NOT FOUND response then check the Base URL first. 192 |
193 | 194 |The Base URL for swapi is:
195 | 196 |
197 | https://www.swapi.tech/api/
198 |
199 |
200 | OR
201 | 202 |
203 | https://swapi.tech/api/
204 |
205 |
206 | 207 | The documentation below assumes you are prepending the Base URL to the 208 | endpoints in order to make requests. 209 |
210 | 211 |214 | Swapi has rate limiting to prevent malicious abuse (as if anyone would 215 | abuse Star Wars data!) and to make sure our service can handle a 216 | potentially large amount of traffic. Rate limiting is done via IP 217 | address and is currently limited to 10,000 API request per day. This 218 | is enough to request all the data on the website at least ten times 219 | over. There should be no reason for hitting the rate limit. 220 |
221 | 222 |225 | Swapi now has rate slowing on top of the rate limiting. Rate slowing 226 | is also done via IP address and is currently set to slow by 100ms 227 | starting after the 5th API request within a 15 minute window. Each 228 | subsequent request will take longer to receieve a response for. 229 |
230 | 231 |234 | Swapi is a completely open API. No authentication is 235 | required to query and get data. This also means that we've limited 236 | what you can do to just GET-ing the data. If you find 237 | a mistake in the data, then{" "} 238 | console.log("author email: admin@swapi.tech")} 240 | href="mailto:admin@swapi.tech" 241 | target="_blank" 242 | rel="noopener noreferrer" 243 | > 244 | email the author 245 | 246 | . 247 |
248 | 249 |Coming Soon
251 | {/*
252 | All resources support JSON Schema
253 | . Making a request to /api/<resource>/schema will
254 | give you the details of that resource. This will allow you to
255 | programmatically inspect the attributes of that resource and their
256 | types.
257 |
262 | All resources support a search parameter that filters the
263 | set of resources returned. This allows you to make queries like:
264 |
267 | https://www.swapi.tech/api/people/?name=r2
268 |
271 | All searches will use case-insensitive partial matches on the set of 272 | search fields. To see the set of search fields for each resource, 273 | check out the individual resource documentation. 274 |
275 | 276 |
279 | Routes that include all resources now supports an{" "}
280 | expanded parameter that will return all of the requested
281 | resource's properties instead of the short hand version:
282 |
285 | https://www.swapi.tech/api/starships/?expanded=true
286 |
SWAPI provides two encodings for you to render the data with:
293 | 294 |JSON is the standard data format provided by SWAPI by default.
297 | 298 |301 | Wookiee is for our tall hairy allies who speak Wookiee, this encoding 302 | returns the same data as json in a stringified syntax, except using 303 | with wookiee translations. 304 |
305 | 306 |
307 | Using the wookiee renderer is easy, just append{" "}
308 | ?format=wookiee to your urls:
309 |
312 | https://www.swapi.tech/api/planets/1/?format=wookiee
313 |
322 | The Root resource provides information on all available resources 323 | within the API. 324 |
325 | 326 |327 | Example request: 328 |
329 | 330 |
331 |
332 | {" "}
333 | {`
334 | fetch("https://www.swapi.tech/api")
335 | .then(res => res.json())
336 | .then(data => console.log(data))
337 | .catch(err => console.error(err))
338 | `}
339 |
340 |
341 |
342 | 343 | Example response: 344 |
345 | 346 |
347 |
348 | {`{
349 | "films": "https://www.swapi.tech/api/films/",
350 | "people": "https://www.swapi.tech/api/people/",
351 | "planets": "https://www.swapi.tech/api/planets/",
352 | "species": "https://www.swapi.tech/api/species/",
353 | "starships": "https://www.swapi.tech/api/starships/",
354 | "vehicles": "https://www.swapi.tech/api/vehicles/"
355 | }`}
356 |
357 |
358 |
359 | 360 | Attributes: 361 |
362 | 363 |films string
366 | -- The URL root for Film resources
367 | people string
370 | -- The URL root for People resources
371 | planets string
374 | -- The URL root for Planet resources
375 | species string
378 | -- The URL root for Species resources
379 | starships string
382 | -- The URL root for Starships resources
383 | vehicles string
386 | -- The URL root for Vehicles resources
387 | 395 | A People resource is an individual person or character within the Star 396 | Wars universe. 397 |
398 | 399 |400 | Endpoints 401 |
402 | 403 |/people/ -- get all the people resources
406 | /people/:id/ -- get a specific people resource
409 | /people/schema/ -- view the JSON schema for this
412 | resource
413 | 417 | Example request: 418 |
419 | 420 |
421 |
422 | {" "}
423 | {`
424 | fetch("https://www.swapi.tech/api/people/1")
425 | .then(res => res.json())
426 | .then(data => console.log(data))
427 | .catch(err => console.error(err))
428 | `}
429 |
430 |
431 |
432 | 433 | Example response: 434 |
435 | 436 |
437 |
438 | {`{
439 | ...
440 | properties: {
441 | "birth_year": "19 BBY",
442 | "eye_color": "Blue",
443 | "films": [ "https://www.swapi.tech/api/films/1/", ... ],
444 | "gender": "Male",
445 | "hair_color": "Blond",
446 | "height": "172",
447 | "homeworld": "https://www.swapi.tech/api/planets/1/",
448 | "mass": "77",
449 | "name": "Luke Skywalker",
450 | "skin_color": "Fair",
451 | "created": "2014-12-09T13:50:51.644000Z",
452 | "edited": "2014-12-10T13:52:43.172000Z",
453 | "species": [ "https://www.swapi.tech/api/species/1/" ],
454 | "starships": [ "https://www.swapi.tech/api/starships/12/", ... ],
455 | "url": "https://www.swapi.tech/api/people/1/",
456 | "vehicles": [ "https://www.swapi.tech/api/vehicles/14/" ... ]
457 | }
458 | }`}
459 |
460 |
461 |
462 | 463 | Attributes: 464 |
465 | 466 |name string
469 | -- The name of this person.
470 | birth_year string
473 | -- The birth year of the person, using the in-universe standard of{" "}
474 | BBY or ABY - Before the Battle of
475 | Yavin or After the Battle of Yavin. The Battle of Yavin is a battle
476 | that occurs at the end of Star Wars episode IV: A New Hope.
477 | eye_color string
480 | -- The eye color of this person. Will be "unknown" if not known or
481 | "n/a" if the person does not have an eye.
482 | gender string
485 | -- The gender of this person. Either "Male", "Female" or "unknown",
486 | "n/a" if the person does not have a gender.
487 | hair_color string
490 | -- The hair color of this person. Will be "unknown" if not known or
491 | "n/a" if the person does not have hair.
492 | height string
495 | -- The height of the person in centimeters.
496 | mass string
499 | -- The mass of the person in kilograms.
500 | skin_color string
503 | -- The skin color of this person.
504 | homeworld string
507 | -- The URL of a planet resource, a planet that this person was born
508 | on or inhabits.
509 | films array
512 | -- An array of film resource URLs that this person has been in.
513 | species array
516 | -- An array of species resource URLs that this person belongs to.
517 | starships array
520 | -- An array of starship resource URLs that this person has piloted.
521 | vehicles array
524 | -- An array of vehicle resource URLs that this person has piloted.
525 | url string
528 | -- the hypermedia URL of this resource.
529 | created string
532 | -- the ISO 8601 date format of the time that this resource was
533 | created.
534 | edited string
537 | -- the ISO 8601 date format of the time that this resource was
538 | edited.
539 | 543 | Search Fields: 544 |
545 | 546 |name
549 | A Film resource is a single film.
557 | 558 |559 | Endpoints 560 |
561 | 562 |/films/ -- get all the film resources
565 | /films/:id/ -- get a specific film resource
568 | /films/schema/ -- view the JSON schema for this
571 | resource
572 | 576 | Example request: 577 |
578 | 579 |
580 |
581 | {" "}
582 | {`
583 | fetch("https://www.swapi.tech/api/films/1")
584 | .then(res => res.json())
585 | .then(data => console.log(data))
586 | .catch(err => console.error(err))
587 | `}
588 |
589 |
590 |
591 | 592 | Example response: 593 |
594 | 595 |
596 |
597 | {`{
598 | ...
599 | "properties": {
600 | "characters": [ "https://www.swapi.tech/api/people/1/", ... ],
601 | "created": "2014-12-10T14:23:31.880000Z",
602 | "director": "George Lucas",
603 | "edited": "2014-12-12T11:24:39.858000Z",
604 | "episode_id": 4,
605 | "opening_crawl": "It is a period of civil war ...",
606 | "planets": [ "https://www.swapi.tech/api/planets/1/", ... ],
607 | "producer": "Gary Kurtz, Rick McCallum",
608 | "release_date": "1977-05-25",
609 | "species": [ "https://www.swapi.tech/api/species/1/", ... ],
610 | "starships": [ "https://www.swapi.tech/api/starships/2/", ... ],
611 | "title": "A New Hope",
612 | "url": "https://www.swapi.tech/api/films/1/",
613 | "vehicles": [ "https://www.swapi.tech/api/vehicles/4/", ... ]
614 | }
615 | }`}
616 |
617 |
618 |
619 | 620 | Attributes: 621 |
622 | 623 |title string
626 | -- The title of this film
627 | episode_id integer
630 | -- The episode number of this film.
631 | opening_crawl string
634 | -- The opening paragraphs at the beginning of this film.
635 | director string
638 | -- The name of the director of this film.
639 | producer string
642 | -- The name(s) of the producer(s) of this film. Comma separated.
643 | release_date date
646 | -- The ISO 8601 date format of film release at original creator
647 | country.
648 | species array
651 | -- An array of species resource URLs that are in this film.
652 | starships array
655 | -- An array of starship resource URLs that are in this film.
656 | vehicles array
659 | -- An array of vehicle resource URLs that are in this film.
660 | characters array
663 | -- An array of people resource URLs that are in this film.
664 | planets array
667 | -- An array of planet resource URLs that are in this film.
668 | url string
671 | -- the hypermedia URL of this resource.
672 | created string
675 | -- the ISO 8601 date format of the time that this resource was
676 | created.
677 | edited string
680 | -- the ISO 8601 date format of the time that this resource was
681 | edited.
682 | 686 | Search Fields: 687 |
688 | 689 |title
692 | 700 | A Starship resource is a single transport craft that has hyperdrive 701 | capability. 702 |
703 | 704 |705 | Endpoints 706 |
707 | 708 |/starships/ -- get all the starship resources
711 | /starships/:id/ -- get a specific starship resource
714 | /starships/schema/ -- view the JSON schema for this
717 | resource
718 | 722 | Example request: 723 |
724 | 725 |
726 |
727 | {" "}
728 | {`
729 | fetch("https://www.swapi.tech/api/starships/9")
730 | .then(res => res.json())
731 | .then(data => console.log(data))
732 | .catch(err => console.error(err))
733 | `}
734 |
735 |
736 |
737 | 738 | Example response: 739 |
740 | 741 |
742 |
743 | {`{
744 | ...
745 | "properties": {
746 | "MGLT": "10 MGLT",
747 | "cargo_capacity": "1000000000000",
748 | "consumables": "3 years",
749 | "cost_in_credits": "1000000000000",
750 | "created": "2014-12-10T16:36:50.509000Z",
751 | "crew": "342953",
752 | "edited": "2014-12-10T16:36:50.509000Z",
753 | "hyperdrive_rating": "4.0",
754 | "length": "120000",
755 | "manufacturer": "Imperial Department of Military Research, Sienar Fleet Systems",
756 | "max_atmosphering_speed": "n/a",
757 | "model": "DS-1 Orbital Battle Station",
758 | "name": "Death Star",
759 | "passengers": "843342",
760 | "films": [ "https://www.swapi.tech/api/films/1/" ],
761 | "pilots": [],
762 | "starship_class": "Deep Space Mobile Battlestation",
763 | "url": "https://www.swapi.tech/api/starships/9/"
764 | }
765 | }`}
766 |
767 |
768 |
769 | 770 | Attributes: 771 |
772 | 773 |name string
776 | -- The name of this starship. The common name, such as "Death Star".
777 | model string
780 | -- The model or official name of this starship. Such as "T-65
781 | X-wing" or "DS-1 Orbital Battle Station".
782 | starship_class string
785 | -- The class of this starship, such as "Starfighter" or "Deep Space
786 | Mobile Battlestation"
787 | manufacturer string
790 | -- The manufacturer of this starship. Comma separated if more than
791 | one.
792 | cost_in_credits string
795 | -- The cost of this starship new, in galactic credits.
796 | length string
799 | -- The length of this starship in meters.
800 | crew string
803 | -- The number of personnel needed to run or pilot this starship.
804 | passengers string
807 | -- The number of non-essential people this starship can transport.
808 | max_atmosphering_speed string
811 | -- The maximum speed of this starship in the atmosphere. "N/A" if
812 | this starship is incapable of atmospheric flight.
813 | hyperdrive_rating string
816 | -- The class of this starships hyperdrive.
817 | MGLT string
820 | -- The Maximum number of Megalights this starship can travel in a
821 | standard hour. A "Megalight" is a standard unit of distance and has
822 | never been defined before within the Star Wars universe. This figure
823 | is only really useful for measuring the difference in speed of
824 | starships. We can assume it is similar to AU, the distance between
825 | our Sun (Sol) and Earth.
826 | cargo_capacity string
829 | -- The maximum number of kilograms that this starship can transport.
830 | consumables *string
833 | films array
840 | -- An array of Film URL Resources that this starship has appeared
841 | in.
842 | pilots array
845 | -- An array of People URL Resources that this starship has been
846 | piloted by.
847 | url string
850 | -- the hypermedia URL of this resource.
851 | created string
854 | -- the ISO 8601 date format of the time that this resource was
855 | created.
856 | edited string
859 | -- the ISO 8601 date format of the time that this resource was
860 | edited.
861 | 865 | Search Fields: 866 |
867 | 868 |name
871 | model
874 | 882 | A Vehicle resource is a single transport craft that{" "} 883 | does not have hyperdrive capability. 884 |
885 | 886 |887 | Endpoints 888 |
889 | 890 |/vehicles/ -- get all the vehicle resources
893 | /vehicles/:id/ -- get a specific vehicle resource
896 | /vehicles/schema/ -- view the JSON schema for this
899 | resource
900 | 904 | Example request: 905 |
906 | 907 |
908 |
909 | {" "}
910 | {`
911 | fetch("https://www.swapi.tech/api/vehicles/4")
912 | .then(res => res.json())
913 | .then(data => console.log(data))
914 | .catch(err => console.error(err))
915 | `}
916 |
917 |
918 |
919 | 920 | Example response: 921 |
922 | 923 |
924 |
925 | {`{
926 | ...
927 | "properties": {
928 | "cargo_capacity": "50000",
929 | "consumables": "2 months",
930 | "cost_in_credits": "150000",
931 | "created": "2014-12-10T15:36:25.724000Z",
932 | "crew": "46",
933 | "edited": "2014-12-10T15:36:25.724000Z",
934 | "length": "36.8",
935 | "manufacturer": "Corellia Mining Corporation",
936 | "max_atmosphering_speed": "30",
937 | "model": "Digger Crawler",
938 | "name": "Sand Crawler",
939 | "passengers": "30",
940 | "pilots": [],
941 | "films": [ "https://www.swapi.tech/api/films/1/" ],
942 | "url": "https://www.swapi.tech/api/vehicles/4/",
943 | "vehicle_class": "wheeled"
944 | }
945 | }`}
946 |
947 |
948 |
949 | 950 | Attributes: 951 |
952 | 953 |name string
956 | -- The name of this vehicle. The common name, such as "Sand Crawler"
957 | or "Speeder bike".
958 | model string
961 | -- The model or official name of this vehicle. Such as "All-Terrain
962 | Attack Transport".
963 | vehicle_class string
966 | -- The class of this vehicle, such as "Wheeled" or "Repulsorcraft".
967 | manufacturer string
970 | -- The manufacturer of this vehicle. Comma separated if more than
971 | one.
972 | length string
975 | -- The length of this vehicle in meters.
976 | cost_in_credits string
979 | -- The cost of this vehicle new, in Galactic Credits.
980 | crew string
983 | -- The number of personnel needed to run or pilot this vehicle.
984 | passengers string
987 | -- The number of non-essential people this vehicle can transport.
988 | max_atmosphering_speed string
991 | -- The maximum speed of this vehicle in the atmosphere.
992 | cargo_capacity string
995 | -- The maximum number of kilograms that this vehicle can transport.
996 | consumables *string
999 | films array
1006 | -- An array of Film URL Resources that this vehicle has appeared in.
1007 | pilots array
1010 | -- An array of People URL Resources that this vehicle has been
1011 | piloted by.
1012 | url string
1015 | -- the hypermedia URL of this resource.
1016 | created string
1019 | -- the ISO 8601 date format of the time that this resource was
1020 | created.
1021 | edited string
1024 | -- the ISO 8601 date format of the time that this resource was
1025 | edited.
1026 | 1030 | Search Fields: 1031 |
1032 | 1033 |name
1036 | model
1039 | 1047 | A Species resource is a type of person or character within the Star 1048 | Wars Universe. 1049 |
1050 | 1051 |1052 | Endpoints 1053 |
1054 | 1055 |/species/ -- get all the species resources
1058 | /species/:id/ -- get a specific species resource
1061 | /species/schema/ -- view the JSON schema for this
1064 | resource
1065 | 1069 | Example request: 1070 |
1071 | 1072 |
1073 |
1074 | {" "}
1075 | {`
1076 | fetch("https://www.swapi.tech/api/species/3")
1077 | .then(res => res.json())
1078 | .then(data => console.log(data))
1079 | .catch(err => console.error(err))
1080 | `}
1081 |
1082 |
1083 |
1084 | 1085 | Example response: 1086 |
1087 | 1088 |
1089 |
1090 | {`{
1091 | ...
1092 | "properties": {
1093 | "average_height": "2.1",
1094 | "average_lifespan": "400",
1095 | "classification": "Mammal",
1096 | "created": "2014-12-10T16:44:31.486000Z",
1097 | "designation": "Sentient",
1098 | "edited": "2014-12-10T16:44:31.486000Z",
1099 | "eye_colors": "blue, green, yellow, brown, golden, red",
1100 | "hair_colors": "black, brown",
1101 | "homeworld": "https://www.swapi.tech/api/planets/14/",
1102 | "language": "Shyriiwook",
1103 | "name": "Wookie",
1104 | "people": [ "https://www.swapi.tech/api/people/13/" ],
1105 | "films": [ "https://www.swapi.tech/api/films/1/", ... ],
1106 | "skin_colors": "gray",
1107 | "url": "https://www.swapi.tech/api/species/3/"
1108 | }
1109 | }`}
1110 |
1111 |
1112 |
1113 | 1114 | Attributes: 1115 |
1116 | 1117 |name string
1120 | -- The name of this species.
1121 | classification string
1124 | -- The classification of this species, such as "mammal" or
1125 | "reptile".
1126 | designation string
1129 | -- The designation of this species, such as "sentient".
1130 | average_height string
1133 | -- The average height of this species in centimeters.
1134 | average_lifespan string
1137 | -- The average lifespan of this species in years.
1138 | eye_colors string
1141 | -- A comma-separated string of common eye colors for this species,
1142 | "none" if this species does not typically have eyes.
1143 | hair_colors string
1146 | -- A comma-separated string of common hair colors for this species,
1147 | "none" if this species does not typically have hair.
1148 | skin_colors string
1151 | -- A comma-separated string of common skin colors for this species,
1152 | "none" if this species does not typically have skin.
1153 | language string
1156 | -- The language commonly spoken by this species.
1157 | homeworld string
1160 | -- The URL of a planet resource, a planet that this species
1161 | originates from.
1162 | people array
1165 | -- An array of People URL Resources that are a part of this species.
1166 | films array
1169 | -- An array of Film URL Resources that this species has appeared in.
1170 | url string
1173 | -- the hypermedia URL of this resource.
1174 | created string
1177 | -- the ISO 8601 date format of the time that this resource was
1178 | created.
1179 | edited string
1182 | -- the ISO 8601 date format of the time that this resource was
1183 | edited.
1184 | 1188 | Search Fields: 1189 |
1190 | 1191 |name
1194 | 1202 | A Planet resource is a large mass, planet or planetoid in the Star 1203 | Wars Universe, at the time of 0 ABY. 1204 |
1205 | 1206 |1207 | Endpoints 1208 |
1209 | 1210 |/planets/ -- get all the planets resources
1213 | /planets/:id/ -- get a specific planets resource
1216 | /planets/schema/ -- view the JSON schema for this
1219 | resource
1220 | 1224 | Example request: 1225 |
1226 | 1227 |
1228 |
1229 | {" "}
1230 | {`
1231 | fetch("https://www.swapi.tech/api/planets/1")
1232 | .then(res => res.json())
1233 | .then(data => console.log(data))
1234 | .catch(err => console.error(err))
1235 | `}
1236 |
1237 |
1238 |
1239 | 1240 | Example response: 1241 |
1242 | 1243 |
1244 |
1245 | {`{
1246 | ...
1247 | "properties": {
1248 | "climate": "Arid",
1249 | "created": "2014-12-09T13:50:49.641000Z",
1250 | "diameter": "10465",
1251 | "edited": "2014-12-15T13:48:16.167217Z",
1252 | "films": [ "https://www.swapi.tech/api/films/1/", ... ],
1253 | "gravity": "1",
1254 | "name": "Tatooine",
1255 | "orbital_period": "304",
1256 | "population": "120000",
1257 | "residents": [ "https://www.swapi.tech/api/people/1/", ... ],
1258 | "rotation_period": "23",
1259 | "surface_water": "1",
1260 | "terrain": "Dessert",
1261 | "url": "https://www.swapi.tech/api/planets/1/"
1262 | }
1263 | }`}
1264 |
1265 |
1266 |
1267 | 1268 | Attributes: 1269 |
1270 | 1271 |name string
1274 | -- The name of this planet.
1275 | diameter string
1278 | -- The diameter of this planet in kilometers.
1279 | rotation_period string
1282 | -- The number of standard hours it takes for this planet to complete
1283 | a single rotation on its axis.
1284 | orbital_period string
1287 | -- The number of standard days it takes for this planet to complete
1288 | a single orbit of its local star.
1289 | gravity string
1292 | -- A number denoting the gravity of this planet, where "1" is normal
1293 | or 1 standard G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5
1294 | standard Gs.
1295 | population string
1298 | -- The average population of sentient beings inhabiting this planet.
1299 | climate string
1302 | -- The climate of this planet. Comma separated if diverse.
1303 | terrain string
1306 | -- The terrain of this planet. Comma separated if diverse.
1307 | surface_water string
1310 | -- The percentage of the planet surface that is naturally occurring
1311 | water or bodies of water.
1312 | residents array
1315 | -- An array of People URL Resources that live on this planet.
1316 | films array
1319 | -- An array of Film URL Resources that this planet has appeared in.
1320 | url string
1323 | -- the hypermedia URL of this resource.
1324 | created string
1327 | -- the ISO 8601 date format of the time that this resource was
1328 | created.
1329 | edited string
1332 | -- the ISO 8601 date format of the time that this resource was
1333 | edited.
1334 | 1338 | Search Fields: 1339 |
1340 | 1341 |name
1344 | 1352 | There are helper libraries available for consuming the Star Wars API 1353 | in a native programming language. Be on the look out for more, or 1354 | submit your own: support@swapi.tech 1355 |
1356 | 1357 |