Logo

FAKE_API_MLB

Description

This open API can be used to retrieve details of MLB, such as the names of leagues, teams, and players. Additionally, it supports querying items grouped by specific criteria, like players grouped by team or teams grouped by leagues. It even allows for more advanced queries, such as filtering left or right-handed pitchers. For complete information, click on at link and review the swagger doc

CRUD PLAYER

Get All Players

You can access the list of players by using the /players endpoint.

Request

[GET] https://fake-mlb-api.onrender.com/players

Response

[
  {
     "bat": "R",
     "id": 1,
     "thw": "L","ht": "6\' 1\"",
     "birth_place": "Riverton, UT",
     "status": true,
     "updated_at": "2023-12-06T15:29:53.009827",
     "pos": "RP","name": "Tanner Banks",
     "age": 32,
     "wt": 210,
     "created_at": "2023-12-06T15:29:53.009777",
     "team_id": 1
  } ,
 //...
]

Get Single Player

You can get a single player by adding the id as a parameter: /players/<id>

Request

[GET] https://fake-mlb-api.onrender.com/players/1

Response

[
  {
     "bat": "R",
     "id": 1,
     "thw": "L","ht": "6\' 1\"",
     "birth_place": "Riverton, UT",
     "status": true,
     "updated_at": "2023-12-06T15:29:53.009827",
     "pos": "RP","name": "Tanner Banks",
     "age": 32,
     "wt": 210,
     "created_at": "2023-12-06T15:29:53.009777",
     "team_id": 1
  } ,
]

Create a Player

You can create a new player by sending an object like the following to /player
(Permission required)

Request

[POST] https://fake-mlb-api.onrender.com/players
#Body
{
   "bat": "R",
   "age": 25,
   "birth_place": "Miami, FL",
   "ht": "6' 3\"",
   "name": "Peter Gregory",
   "pos": "CF",
   "team_id": 5,
   "thw": "R",
   "wt": 210
}

Response

"Player Created"

Update a Player

You can update a product by sending an object like the following and adding the id as a parameter: /player/<id>
(Permission required)

Request

[PUT] https://fake-mlb-api.onrender.com/players/1
#Body
{
   "bat": "R",
   "age": 25,
   "birth_place": "Miami, FL",
   "ht": "6' 3\"",
   "name": "Peter Gregory New",
   "pos": "CF",
   "team_id": 5,
   "thw": "R",
   "wt": 210
}

Response

"Player Peter Gregory New has ben updeted"

Delete a Player

You can delete a Player by adding the id as a parameter: /products/<id>
(Permission required)

Request

[DELETE] https://fake-mlb-api.onrender.com/players/1

Response

Player Deleted

CRUD TEAM

Get All Teams

You can access the list of teams by using the /teams endpoint.

Request

[GET] https://fake-mlb-api.onrender.com/teams

Response

[
  {
     "name": "Chicago White Sox",
     "logo": "https://a.espncdn.com/combiner/i?img=/i/teamlogos/mlb/500/chw.png&h=200&w=200",
     "city": "Chicago",
     "league_id": 2,
     "id": 1,
     "updated_at": "2023-12-06T15:29:53.009827",
     "status": true,
  } ,
 //...
]

Get Single Team

You can get a single team by adding the id as a parameter: /teams/<id>

Request

[GET] https://fake-mlb-api.onrender.com/teams/1

Response

[
  {
     "name": "Chicago White Sox",
     "logo": "https://a.espncdn.com/combiner/i?img=/i/teamlogos/mlb/500/chw.png&h=200&w=200",
     "city": "Chicago",
     "league_id": 2,
     "id": 1,
     "updated_at": "2023-12-06T15:29:53.009827",
     "status": true,
  } ,
]

Create a Team

You can create a new team by sending an object like the following to /teams
(Permission required)

Request

[POST] https://fake-mlb-api.onrender.com/teams
#Body
{
   "city": "Kansas",
   "league_id": 2,
   "logo": "https://a.espncdn.com/i/headshots/mlb/players/full/38106.png",
    "name": "Kansas City Royals"
}

Response

"Team Created"

Update a Player

You can update a team by sending an object like the following and adding the id as a parameter: /team/<id>
(Permission required)

Request

[PUT] https://fake-mlb-api.onrender.com/teams/2
#Body
{
   "city": "Kansas",
   "league_id": 2,
   "logo": "https://a.espncdn.com/i/headshots/mlb/players/full/38106.png",
    "name": "Kansas City Royals"
}

Response

"Team: Kansas updated successfully"

Delete a Team

You can delete a Team by adding the id as a parameter: /team/<id>
(Permission required)

Request

[DELETE] https://fake-mlb-api.onrender.com/teams/2

Response

Team Deleted

CRUD LEAGUES

Get All Leagues

You can access the list of leagues by using the /leagues endpoint.

Request

[GET] https://fake-mlb-api.onrender.com/leagues

Response

[
  {
     "name": "National league",
     "id": 1,
     "status": true,
     "country": "United States",
  } ,
 //...
]

Get Single League

You can get a single league by adding the id as a parameter: /leagues/<id>

Request

[GET] https://fake-mlb-api.onrender.com/leagues/1

Response


  {
     "name": "National league",
     "id": 1,
     "status": true,
     "country": "United States",
  }

Create a Player

You can create a new league by sending an object like the following to /league
(Permission required)

Request


  {
     "name": "National league",
     "country": "United States"
  }

Response

"League National league Created"

Update a League

You can update a league by sending an object like the following and adding the id as a parameter: /leagues/<id>
(Permission required)

Request


  {
     "name": "National league New",
     "country": "United States"
  }

Response

"League National league New has ben updeted"

Delete a League

You can delete a League by adding the id as a parameter: /leagues/<id>
(Permission required)

Request

[DELETE] https://fake-mlb-api.onrender.com/leagues/1

Response

League Deleted

Create and update User

Create a User

You can create a new user by sending an object like the following to /user

Request

[POST] https://fake-mlb-api.onrender.com/users
#Body
{
   "email": "[email protected]",
   "first_name": "Peter",
   "last_name": "Gregory",
   "password": "SecurityPassword Ex4mpl3 !",
   "phone_number": 5555551234
}

Response

"User Peter Gregory Created"

Update a User

You can update a user password by sending an object like the following and adding the id as a parameter: /users/<id>
(Permission required)

Request

[PUT] https://fake-mlb-api.onrender.com/users
#Body
{
   "password": "SecurityPassword Ex4mpl3 ! New"
}

Response

"User: Peter Gregory updated successfully"

Auth with JWT

Authentication

You can do login by sending an object like the following to /auth/login.

Request

{
     "email": "[email protected]",
     "password": "SecurityPassword Ex4mpl3 !"
}

The response is an access JWT token, like this:

{

"eyJmdWxsX25hbWUiOiJOYXZvciBJdHVydmkiLCJlbWFpbCI6Im5hdm9yaXR1cnZpMzRAZ21haWwuY29tIiwiZ3JvdXBfaWQiOjQsImNyZWF0ZWRfYXQiOiIyMDIzLTEyLTA2VDE0OjQ0sdfHJkjhKJHhhkjHLM2OCIsInVwZGF0ZWRfYXQiOiIyMDIzLTEyLTA2VDE0OjQ0OjUzLjMxMjcwOCIsImZpcnN0X25hbWUiOiJOYXZvciIsImxhc3RfbmFtZSI6Ikl0dXJ2aSIsImlkIjo0LCJwYXNzd29yZCI6IiQyYiQxMiRzNG9ySUdBVDQxdVFSczF1cHNUa3VlVFBXam1oM21JdEFNcGVjbjlQWnpnNllZbzNGcUptMiIsInBob25lX251bWJlciI6MSwiZXhwIjoxNzAyMjY2MDI0fQ.QJ0G43NpN5H-bcGS3rmzqUIJlza1qeR2KdzVRo3M8vA,"

}

Schemas

Player

Attribute Type Description
id BIGINT Primary Key
name VARCHAR Name of player
pos VARCHAR Position of player in field
bat VARCHAR Left or right-handed stance batting
thw VARCHAR Left or right-handed pitching
age Integer Age of player
ht VARCHAR Height of player (ft ")
wt Integer Weith of player (lbs)
birth_place VARCHAR birth place of player

Team

Attribute Type Description
id INT Primary Key
name VARCHAR Name of team
logo VARCHAR url of image
city VARCHAR city of team

League

Attribute Type Description
id INT Primary Key
name VARCHAR Name of team
country VARCHAR Country of league