Skip to content

JacobBrown4/MarvelAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


MarvelAPI Docs

With this API, you can register as a user, then, create and manage character entries in a database of Marvel characters, as well as their appearances on TV and in the MCU[x].


Table of Contents
  1. Creators
  2. Setup
  3. Usage
  4. Database Schema
  5. Schemas
  6. Resources

Creators


Setup

To start, you will need to clone the repository into your desired directory. Everything you need to access and run this API is included in this repository. You do not need any external dependencies.

To clone the repository, run this command in your terminal:

git clone https://github.com/zdearmin/MarvelAPI.git

With your server running, you can execute the following command to create the database and tables. If your current working directory is the same as the folder with the .git file, your command should look like below:

dotnet ef database update -p .\MarvelAPI.Data\ -s .\MarvelAPI.WebAPI\

(back to top)

Usage

By running the project file within the MarvelAPI.WebAPI assembly, the endpoints will become active, and if your server where you would like to host your data is live as well, you can begin the process of migrating, then posting to the newly created database.

The command to startup the project should look similar to:

dotnet run --project .\MarvelAPI.WebAPI\

For interacting with your database, the project includes an implementation of Swagger[x] to run queries from within your browser. To run Swagger, post the text below into your browser, and adjust the port number to match what is shown on your local device.

https://localhost:[EnterPortHere]/swagger

Alternatively, Postman[x] is a recommended platform that allows you to save multiple customized queries. Click the button below to get the data framework for this collection. Then, import that data into your desired Postman workspace to create the MarvelAPI collection.

Run in Postman

This API utilizes JSON Web Tokens (JWT)[x] for authentication and authorization. All GET endpoints are open access. All other endpoints are restricted to users with authorization. Authorization can be granted in the form of a token. Steps to generating a token are listed below:

  1. Create a new user at the POST /api/User/Register endpoint.

  2. Enter your newly created "Username" and "Password" at the POST /api/Token enpoint. If the username and password match a valid user, a new token will be generated. The generated token can then be added to the authorization fields in either Postman or Swagger to gain access to remaining CRUD methods.

(back to top)

Database Schema

Here is an overview of the tables:

  • Characters
    • Id - int
    • Name - string
    • Age - string (e.g., "30s", "Immortal", "Unknown")
    • Location - string (i.e., current location in MCU)
    • Origin - string (i.e., homeworld / birthplace)
    • Abilities - string (comma-separated)
    • Abilities Origin - string (1-or-2 word description)
    • Aliases - string (comma-separated)
    • Status - string (i.e., "Alive", "Dead", "Unknown")
  • Movies
    • Id - int
    • Title - string
    • Release Year - int
  • Movie Appearances
    • Id - int
    • Character Id - Foreign Key to Characters table
    • Movie Id - Foreign Key to Movies table
  • Team Memberships
    • Id - int
    • Team Id - Foreign Key to Teams table
    • Member Id - Foreign Key to Characters table
  • Teams
    • Id - int
    • Name - string
    • Authority - string
    • Alignment - string
  • TV Shows
    • Id - int
    • Title - string
    • Release Year - int
    • Number of Seasons - int
  • TV Show Appearances
    • Id - int
    • Character Id - Foreign Key to Characters table
    • TV Show Id - Foreign Key to TV Shows table
  • Users
    • Id - int
    • Email - string (i.e., [email protected])
    • Username - string (minimum length of 4 characters)
    • Password - string (minimum length of 4 characters)
    • First Name - string
    • Last Name - string
    • Date Created - DateTime

(back to top)

Schemas

Each table in the database is equipped with functionality for Creating, Reading, Updating, and Deleting (aka CRUD). Details for information needed to complete requests are provided below. All requests and returns are represented in JSON format.


Characters


Create a new character:

POST /api/Character

  • Request completed using Body

Example Request:

{
  "fullName": "string",
  "age": "string"
}

Get all characters:

GET /api/Character

  • No request Route or Body required

Example Response:

[
  {
    "id": 0,
    "fullName": "string"
  }
]

Get a character by Id:

GET /api/Character/{characterId}

  • Request completed using Route int characterId

Example Response:

{
  "id": 0,
  "fullName": "string",
  "age": "string",
  "location": "string",
  "origin": "string",
  "abilities": "string",
  "abilitiesOrigin": "string",
  "aliases": "string",
  "status": "string",
  "movies": [
    {
      "id": 0,
      "title": "string"
    }
  ],
  "tvShows": [
    {
      "id": 0,
      "title": "string"
    }
  ]
}

Get a character by aliases:

GET /api/Character/Aliases/{aliases}

  • Request completed using Route string aliases

Example Response:

[
    {
        "id": 0,
        "fullName": "string",
        "aliases": "string"
    }
]

Get all characters with ability:

GET /api/Character/Abilities/{ability}

  • Request completed using Route string ability

Example Response:

[
  {
        "id": 0,
        "fullName": "string",
        "abilities": "string"
  }
]

Update a character:

PUT /api/Character/{characterId}}

  • Request completed using Route int characterId and Body

The following properties will be left unchanged if the corresponding values in the request body are sent as empty strings

Example Request:

{
  "fullName": "string",
  "age": "string",
  "location": "string",
  "origin": "string",
  "abilities": "string",
  "abilitiesOrigin": "string",
  "aliases": "string",
  "status": "string"
}

Delete a character:

DELETE /api/Character/{characterId}}

  • Request completed using Route int characterId
  • Response will be status 200 OK if successful

(back to top)

Movies


Create a new movie:

POST /api/Movie

  • Request completed using Body

Example Request:

{
  "title": "string",
  "releaseYear": 0
}

Get all movies:

GET /api/Movie

  • No request Route or Body required

Example Response:

[
  {
    "id": 0,
    "title": "string"
  }
]

Get a movie by Id:

GET /api/Movie/{movieId}

  • Request completed using Route int movieId

Example Response:

{
  "id": 0,
  "title": "string",
  "releaseYear": 0,
  "characters": [
    {
      "id": 0,
      "fullName": "string"
    }
  ]
}

Get a movie by title:

GET /api/Movie/{movieTitle}

  • Request completed using Route string movieTitle

Example Response:

{
  "id": 0,
  "title": "string",
  "releaseYear": 0,
  "characters": [
    {
      "id": 0,
      "fullName": "string"
    }
  ]
}

Update a movie:

PUT /api/Movie/{movieId}

  • Request completed using Route int movieId and Body

Example Request:

{
  "title": "string",
  "releaseYear": 0
}

Delete a movie:

DELETE /api/Movie/{movieId}

  • Request completed using Route int movieId
  • Response will be status 200 OK if successful

(back to top)

Movie Appearances


Create a new movie appearance:

POST /api/MovieAppearance

  • Request completed using Body

Example Request:

{
  "characterId": 0,
  "movieId": 0
}

Get all movie appearances:

GET /api/MovieAppearance

  • No request Route or Body required

Example Response:

[
  {
    "id": 0,
    "character": "string",
    "movie": "string"
  }
]

Get a movie appearance by Id:

GET /api/MovieAppearance/{movieAppearanceId}

  • Request completed using Route int movieAppearanceId

Example Response:

{
  "id": 0,
  "characterId": 0,
  "character": "string",
  "movieId": 0,
  "movie": "string"
}

Update a movie appearance:

PUT /api/MovieAppearance/{movieAppearanceId}

  • Request completed using Route int movieAppearanceId and Body

Example Request:

{
  "characterId": 0,
  "movieId": 0
}

Delete a movie appearance:

DELETE /api/MovieAppearance/{movieAppearanceId}

  • Request completed using Route int movieAppearanceId
  • Response will be status 200 OK if successful

(back to top)

Team Membership


Create a new team membership:

POST /api/TeamMembership

  • Request completed using Body

Example Request:

{
  "teamId": 0,
  "memberId": 0
}

Get all team memberships:

GET /api/TeamMembership

  • No request Route or Body required

Example Response:

[
  {
    "id": 0,
    "teamId": 0,
    "memberId": 0
  }
]

Get a team membership by Id:

GET /api/TeamMembership/{teamMembershipId}

  • Request completed using Route int teamMembershipId

Example Response:

{
  "id": 0,
  "teamId": 0,
  "memberId": 0,
  "team": "string",
  "member": "string"
}

Update a team membership:

PUT /api/TeamMembership/{teamMembershipId}

  • Request completed using Route int teamMembershipId and Body

Example Request:

{
  "teamId": 0,
  "memberId": 0
}

Delete a team membership:

DELETE /api/TeamMembership/{teamMembershipId}

  • Request completed using Route int teamMembershipId
  • Response will be status 200 OK if successful

(back to top)

Teams


Create a new team:

POST /api/Teams

  • Request completed using Body

Example Request:

{
  "name": "string"
}

Get all teams:

GET /api/Teams

  • No request Route or Body required

Example Response:

[
  {
    "id": 0,
    "name": "string"
  }
]

Get a team by Id:

GET /api/Teams/{teamId}

  • Request completed using Route int teamId

Example Response:

{
  "id": 0,
  "name": "string",
  "authority": "string",
  "alignment": "string",
  "members": [
    {
      "id": 0,
      "fullName": "string"
    }
  ]
}

Update a team:

PUT /api/Teams/{teamId}

  • Request completed using Route int teamId and Body

Example Request:

{
  "name": "string",
  "authority": "string",
  "alignment": "string"
}

Delete a team:

DELETE /api/Teams/{teamId}

  • Request completed using Route int teamId
  • Response will be status 200 OK if successful

(back to top)

TV Shows


Create a new TV show:

POST /api/TVShow

  • Request completed using Body

Example Request:

{
  "title": "string",
  "releaseYear": 0,
  "seasons": 0
}

Get all TV shows:

GET /api/TVShow

  • No request Route or Body required

Example Response:

[
  {
    "id": 0,
    "title": "string"
  }
]

Get a TV show by Id:

GET /api/TVShow/{tvShowId}

  • Request completed using Route int tvShowId

Example Response:

{
  "id": 0,
  "title": "string",
  "releaseYear": 0,
  "seasons": 0,
  "characters": [
    {
      "id": 0,
      "fullName": "string"
    }
  ]
}

Get a TV show by title:

GET /api/TVShow/{tvShowTitle}

  • Request completed using Route string tvShowTitle

Example Response:

{
  "id": 0,
  "title": "string",
  "releaseYear": 0,
  "seasons": 0,
  "characters": [
    {
      "id": 0,
      "fullName": "string"
    }
  ]
}

Update a TV show:

PUT /api/TVShow/{tvShowId}

  • Request completed using Route int tvShowId and Body

Example Request:

{
  "title": "string",
  "releaseYear": 0,
  "seasons": 0
}

Delete a TV show:

DELETE /api/tvShow/{tvShowId}

  • Request completed using Route int tvShowId
  • Response will be status 200 OK if successful

(back to top)

TV Show Appearances


Create a new TV show appearance:

POST /api/TVShowAppearance

  • Request completed using Body

Example Request:

{
  "characterId": 0,
  "tvShowId": 0
}

Get all TV show appearances:

GET /api/TVShowAppearance

  • No request Route or Body required

Example Response:

[
  {
    "id": 0,
    "character": "string",
    "tvShow": "string"
  }
]

Get a TV show appearance by Id:

GET /api/TVShowAppearance/{tvShowAppearanceId}

  • Request completed using Route int tvShowAppearanceId

Example Response:

{
  "id": 0,
  "characterId": 0,
  "character": "string",
  "tvShowId": 0,
  "tvShow": "string"
}

Update a TV show appearance:

PUT /api/TVShowAppearance/{tvShowAppearanceId}

  • Request completed using Route int tvShowAppearanceId and Body

Example Request:

{
  "characterId": 0,
  "tvShowId": 0
}

Delete a TV show appearance:

DELETE /api/TVShowAppearance/{tvShowAppearanceId}

  • Request completed using Route int tvShowAppearanceId
  • Response will be status 200 OK if successful

(back to top)

Users


Generate a new token:

POST /api/Token

  • Request completed using Body

Example Request:

{
  "username": "string",
  "password": "string"
}

Create a new user:

POST /api/User/Register

  • Request completed using Body

Example Request:

{
  "email": "[email protected]",
  "username": "string",
  "password": "string",
  "confirmPassword": "string"
}

Get all users:

GET /api/User

  • No request Route or Body required

Example Response:

[
  {
    "id": 0,
    "username": "string",
    "email": "string",
    "firstName": "string",
    "lastName": "string",
    "dateCreated": "2022-07-26T17:58:53.980Z"
  }
]

Get a user by Id:

GET /api/User/{userId}

  • Request completed using Route int userId

Example Response:

{
  "id": 0,
  "username": "string",
  "email": "string",
  "firstName": "string",
  "lastName": "string",
  "dateCreated": "2022-07-26T18:01:56.579Z"
}

Update a user:

PUT /api/User/{userId}

  • Request completed using Route int userId and Body

Example Request:

{
  "username": "string",
  "email": "[email protected]",
  "password": "string",
  "firstName": "string",
  "lastName": "string"
}

Delete a user:

DELETE /api/User/{userId}

  • Request completed using Route int userId
  • Response will be status 200 OK if successful

(back to top)

Resources

Below is a list of resources we would like to give credit to as each one played a role in the development of this API.

(back to top)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages