Skip to content

Independent Project # 12 for Epicodus. Week 6 of C#/.NET - Building an API

Notifications You must be signed in to change notification settings

DanielAdeyemi/ParksLookup.Solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 

Repository files navigation

Parks Lookup API (v 1.0 and 1.1)

📚 Epicodus Independent Project # 12 (Week 6 of C#) 04/02/2021

By Daniel Adeyemi

csharp dotnet MySQL

GitHub last commit (branch) GitHub language count Languages

Lake view

🚩 Description:

This is a custom API (versions 1.0 and 1.1) to lookup national and local parks by name, location etc .


🔧 Setup & Requirements

📋 Necessary Specifications

To run this project locally you will need:

  • ASP .NET Core : You can check if you have .NET Core by running dotnet --version in the command line. If you do not have .NET Core please find more information and download here
  • MySQL : You can download MySQL here and MySQL Workbench here

⚙️ Clone or Download

🌐 To Download:

  • Go to my GitHub repository, using following URL.
    • At the top of the repository, click Code Button then select "Download ZIP".
download zip gif

To clone (my prefered method):

  1. At the top of the repository, click Code Button and copy the URL.
  2. Open Terminal or GitBash and input the command: git clone https://github.com/DanielAdeyemi/ParksLookup.Solution.git
  3. To view the code, open the copied directory with Visual Studio Code or your preferred text editor by inputing the command code . in your terminal.

🧰 Database Setup Options

AppSettings:

  • After you have the project on your computer you will need to create a file in the root directory of the project called "appsettings.json".
  • Add the following snippet of code to the appsettings.json file:
{
    "Logging": {
    "LogLevel": {
      "Default": "Warning",
      "Microsoft": "Information",
      "System": "Information"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Port=3306;database=daniel_adeyemi;uid=[YOUR-ACCOUNT-NAME];pwd=[YOUR-PASSWORD];"
  }
}

*Please note you will need to replace YOUR-PASSWORD-HERE with the password you created for your MySQL server. *You may also need to update uid, port, or database name depending on your configurations.

Import Database using Entity Framework Core:

  • In the command line run cd Desktop/ParksLookup.Solution/ParksLookup to navigate to the "ParksLookup" folder.
  • Next, run dotnet ef database update to generate the database. You can confirm the database was created by checking MySQL workbench.

⚠️ Note: to make changed to the database you can run dotnet ef migrations add <MigrationName>

🛸 API Documentation

In order to explore the endpoints of this API, we suggest that you use Postman. Postman will allow you to make GET, POST, PUT, and DELETE requests with the ParksLookupApi. Base URL: http://localhost:5000

HTTP Request Structure:

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

Path Parameters:

Parameter Type Default Required Description
ParkName string none false Return matches by name.
Location string none false Return matches by location (check note below for comma separated locations such Portland, OR).
National bool none false Return all parks marked as National
Local bool none false Return all parks marked as Local

⚠️ Note: for comma-separated locations, such Portland, OR use following path:

?location=portland%2C%20or

Example Query:

http://localhost:5000/api/parks/?location=portland%2C%20or&local=true

Sample JSON Response:

[
  {
    "parkId": 1,
    "parkName": "Buike",
    "parkLocation": "Portland, OR",
    "national": false,
    "local": true
  }
]

Versions:

Version 1.0 of ParksLookup API was setup as default version in Startup.cs file. API also support 1.1 version. For additional information check table below:

Version Default Description query
1.0 true looks for parks by name, locations, national/state affilation. http://localhost:5000/api/parks/
1.1 false get route will display only national parks by default http://localhost:5000/api/parks/?v=1.1

🛠️ Technologies used:

  • C# 9
  • .NET Core v5.0
  • RESTful Routing, CRUD
  • MySQL MySQL Workbench
  • Entity Framework Core
  • MVC.Versioning 5.0.0
  • Postman
  • Git and GitHub

🖥️ View the project:

To view functionality you need to run dotnet run command from ParksLookup folder. After that you will see http://localhost:5000 and can need to open Postman and enter the API queries described above (see API Documentation for more details)

🐛 Known bugs:

No bugs as of 4/2/2021

🌟 Improvement opportunities:

  • build views
  • add more features(such as login etc) to make it more useful in real world.

📬 Contact Information

For any questions email author

📘 License and copyright:

© Daniel Adeyemi, 2021
⚖️ License: MIT

About

Independent Project # 12 for Epicodus. Week 6 of C#/.NET - Building an API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages