A simple Go backend for the Star Wars API (SWAPI), exposing REST endpoints to list people and planets from the Star Wars universe.
Make sure you have the following installed:
- Go 1.25+
- Docker and Docker Compose (optional)
jq(optional, for parsing JSON in example commands)
Build and start the server:
make runBuild and start the Docker container with:
docker compose up -dThe server will run at http://localhost:6969.
The backend exposes the following endpoints:
| Method | Endpoint | Description |
|---|---|---|
| GET | /people |
Retrieve a list of Star Wars characters |
| GET | /planets |
Retrieve a list of Star Wars planets |
| GET | /health |
Check server health |
All data is fetched from SWAPI and cached in memory for better performance.
You can use query parameters to paginate, search, and sort results:
page– Page number (default: 1)limit– Number of results per page (default: 15)search– Filter results by name containing the search term (case-insensitive)sort– Field to sort by (nameorcreated, default:name)order– Sort order (ascordesc, default:asc)
Example requests:
curl -X GET http://localhost:6969/people?limit=2&page=2 | jq
curl -X GET http://localhost:6969/people?page=3&limit=1&search=ma&sort=name&order=asc | jq
curl -X GET http://localhost:6969/people?search=fe&sort=created&order=desc | jqRun tests with:
make test
# make test-integration