8000 GitHub - aaronvbrown/ParkFinderAPI.Solution: An API with information about public recreation areas.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

aaronvbrown/ParkFinderAPI.Solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ParkFinderAPI

By Aaron Brown

An API with information about public recreation areas.

Technologies Used

Description

This API returns information about various recreation areas through an API.

Setup Requirements

  • You'll need the .NET SDK installed on your system to run the app. Downloads for the .NET SDK are available here.
  • Install dotnet-ef globally to enable databse migrations using the following command
    $ dotnet tool install --global dotnet-ef --version 6.0.0
  • For further database migration assistance, this lesson from learnhowtoprogram.com is helpful.
  • Clone the repository git clone https://github.com/aaronvbrown/ParkFinderAPI.Solution.git in the terminal
  • Navigate to this project's production directory "ParkFinderAPI"
  • Create a file appsettings.json, adding the following code. (Replace uid and pwd with your own username and password for MySQL)
    {
      "ConnectionStrings": {
        "DefaultConnection": "Server=localhost;Port=3306;database=aaron_brown;uid=[your-username];pwd=[your-password];"
      }
    }
  • Run dotnet ef database update from the command line to create a database locally that the project can use.
  • Run dotnet run in the command line to start the app
  • Run dotnet watch run in the command line to load in development mode with a watcher

API Documentation

Endpoints

The base URL is: https://localhost:5000

Request Structure

GET /api/{component}
POST /api/{component}
GET /api/{component}/{id}
PUT /api/{component}/{id}
DELETE /api/{component}/{id}

Available Components

  • Parks

Example Queries - Parks

http://localhost:5000/api/Parks (GET, POST) http://localhost:5000/api/Parks/1 (GET, PUT, DELETE)

Sample GET Index Response for http://localhost:5000/api/Parks:
[
  {
      "parkId": 1,
      "name": "Yellowstone",
      "state": "Montana",
      "type": "National Park"
  },
  {
      "parkId": 2,
      "name": "Crater Lake",
      "state": "Oregon",
      "type": "National Park"
  }
]
Sample POST Request http://localhost:5000/api/Parks

Request Body:

{
    "name": "Mt St Helens",
    "state": "Washington",
    "type": "National Monument"
}

Response Body:

{
    "parkId": 6,
    "name": "Mt St Helens",
    "state": "Washington",
    "type": "National Monument"
}
Sample GET Response for http://localhost:5000/api/Parks/1:
  {
      "parkId": 1,
      "name": "Yellowstone",
      "state": "Montana",
      "type": "National Park"
  }
Sample PUT Request http://localhost:5000/api/Parks/1

Request Body:

{
    "parkId":1,
    "name":"Yellowrock",
    "state":"Montana",
    "type":"National Park"
}

The API should return a Status 204 No Content response. Verify update results with a GET request for the appropriate parkId.

Query String Parameters

GET /api/{component}/?{parameter}={value}

Parameter Data Type Required/Optional Description
name string optional complete name of park (ex. {Crater Lake}, {Yellowstone})
state string optional complete name of state (ex. {Rhode Island}, {Oregon})
type string optional complete type of park (ex. {National Park}, {National Monument})
PageSize int optional number of results per page ( defaults to 2, max 3 )
PageNumber int optional page number requested (defaults to 1)

Filter results of the Parks index GET request using the above structure.

Example: http://localhost:5000/api/Parks/?type=National Park

Chain filters together using & to separate the key=value pairs:

Example: http://localhost:5000/api/Parks/?state=washington&PageNumber=2

Known Bugs

  • Pagination via the "pagination" branch is now working as of 12/3/2023.
  • Please report any bugs at the github repo issues page

Further Exploration

  • Pagination was implemented for this project.
  • The default page number returned is 1.
  • The default page size is 2 and the max page size is 3.

Attributions

License

MIT License

Copyright (c) 2023 Aaron Brown

About

An API with information about public recreation areas.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0