Giter Club home page Giter Club logo

starwars.aspnet's Introduction

StarWars.AspNet

Star Wars REST API in ASP.NET 6.0.

Getting Started

Prerequisites

Running in Docker

To simply deploy/run the Star Wars REST API via Docker, you can run the command:

docker run -p 8080:80 ghcr.io/bashfulbandit/starwars.aspnet.api:latest

Running via docker compose

There is an example docker-compose.yaml file in the root of the repository. This can be used to easily start up an instance of the StarWars.AspNet.Api.

services:
  api:
    image: ghcr.io/bashfulbandit/starwars.aspnet.api:latest
    ports:
      - 8080:80

API Endpoint for getting started and documentation

There is a Healthcheck API endpoint at http://localhost:8080/api/healthz. There is also a Swagger UI available at http://localhost:8080/api/swagger.

The Swagger UI provides technical documentation for the API and an easy to use interface for interacting with the various API endpoints.

Coding Exercise API Endpoints

GET /api/characters/{characterId}/starships

#1 - Return a list of the Starships related to Luke Skywalker

Luke Skywalker's characterId is 2.

Query Parameters:

  • page - Defaults to 1.
  • pageSize - Defaults to 25.
{
  "starships": [
    {
      "id": "12",
      "name": "X-wing",
      "model": "T-65 X-wing",
      "starshipClass": "Starfighter",
      "manufacturer": [
        "Incom Corporation"
      ],
      "costInCredits": "149999",
      "length": "12.5",
      "crew": "1",
      "passengers": "0",
      "maxAtmospheringSpeed": "1050",
      "mglt": "100",
      "cargoCapacity": "110",
      "consumables": "1 week",
      "createdAt": "2014-12-12T11:19:05.34Z",
      "updatedAt": "2014-12-20T21:23:49.886Z"
    },
    {
      "id": "22",
      "name": "Imperial shuttle",
      "model": "Lambda-class T-4a shuttle",
      "starshipClass": "Armed government transport",
      "manufacturer": [
        "Sienar Fleet Systems"
      ],
      "costInCredits": "240000",
      "length": "20",
      "crew": "6",
      "passengers": "20",
      "maxAtmospheringSpeed": "850",
      "mglt": "50",
      "cargoCapacity": "80000",
      "consumables": "2 months",
      "createdAt": "2014-12-15T13:04:47.235Z",
      "updatedAt": "2014-12-20T21:23:49.9Z"
    }
  ],
  "pagination": {
    "pageNumber": 1,
    "pageSize": 25,
    "pageCount": 1,
    "totalCount": 2,
    "hasPrevious": false,
    "hasNext": false
  }
}

GET /api/episodes/{episodeId}/species

#2 - Return the classification of all species in the 1st episode

1st Star Wars episode episodeId is 1. If you go by release order a.k.a. The Good Hope. 1st Star Wars episode episodeId is 4. If you go by episode order a.k.a. The Phantom Menace.

Query Parameters:

  • page - Defaults to 1.
  • pageSize - Defaults to 25.
{
  "species": [
    {
      "id": "1",
      "name": "Human",
      "classification": "mammal",
      "designation": "sentient",
      "averageHeight": "180",
      "averageLifespan": "120",
      "eyeColors": [
        "brown",
        "blue",
        "green",
        "hazel",
        "grey",
        "amber"
      ],
      "hairColors": [
        "blonde",
        "brown",
        "black",
        "red"
      ],
      "skinColors": [
        "caucasian",
        "black",
        "asian",
        "hispanic"
      ],
      "language": "Galactic Basic",
      "createdAt": "2014-12-10T13:52:11.567Z",
      "updatedAt": "2014-12-20T21:36:42.136Z"
    },
    {
      "id": "2",
      "name": "Droid",
      "classification": "artificial",
      "designation": "sentient",
      "averageHeight": "n/a",
      "averageLifespan": "indefinite",
      "eyeColors": [
        "n/a"
      ],
      "hairColors": [
        "n/a"
      ],
      "skinColors": [
        "n/a"
      ],
      "language": "n/a",
      "createdAt": "2014-12-10T15:16:16.259Z",
      "updatedAt": "2014-12-20T21:36:42.139Z"
    },
    {
      "id": "3",
      "name": "Wookie",
      "classification": "mammal",
      "designation": "sentient",
      "averageHeight": "210",
      "averageLifespan": "400",
      "eyeColors": [
        "blue",
        "green",
        "yellow",
        "brown",
        "golden",
        "red"
      ],
      "hairColors": [
        "black",
        "brown"
      ],
      "skinColors": [
        "gray"
      ],
      "language": "Shyriiwook",
      "createdAt": "2014-12-10T16:44:31.486Z",
      "updatedAt": "2014-12-20T21:36:42.142Z"
    },
    {
      "id": "4",
      "name": "Rodian",
      "classification": "sentient",
      "designation": "reptilian",
      "averageHeight": "170",
      "averageLifespan": "unknown",
      "eyeColors": [
        "black"
      ],
      "hairColors": [
        "n/a"
      ],
      "skinColors": [
        "green",
        "blue"
      ],
      "language": "Galatic Basic",
      "createdAt": "2014-12-10T17:05:26.471Z",
      "updatedAt": "2014-12-20T21:36:42.144Z"
    },
    {
      "id": "5",
      "name": "Hutt",
      "classification": "gastropod",
      "designation": "sentient",
      "averageHeight": "300",
      "averageLifespan": "1000",
      "eyeColors": [
        "yellow",
        "red"
      ],
      "hairColors": [
        "n/a"
      ],
      "skinColors": [
        "green",
        "brown",
        "tan"
      ],
      "language": "Huttese",
      "createdAt": "2014-12-10T17:12:50.41Z",
      "updatedAt": "2014-12-20T21:36:42.146Z"
    }
  ],
  "pagination": {
    "pageNumber": 1,
    "pageSize": 25,
    "pageCount": 1,
    "totalCount": 5,
    "hasPrevious": false,
    "hasNext": false
  }
}

GET /api/population

#3 - Return the total population of all planets in the Galaxy

{
    "population": 1711401432500
}

Postman Collection

There is a Postman collection in the docs directory of this repository that can be used to interact with a running instance of the Star Wars API.

The Postman Collection is also a great way to learn about the various API endpoints that are available to use.

Support

We use GitHub for tracking bugs and feature requests related to the Star Wars API.

Don't know how something in this project works? Curious if this project can achieve your desired functionality? Please open an issue on GitHub with the label question.

starwars.aspnet's People

Contributors

bashfulbandit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.