API University is a sample project that provides a RESTful API for managing universities, faculties, and courses. It is built with ASP.NET Core and uses Entity Framework Core to interact with a SQL Server database. This project is meant to serve as an example of how to build a modern web API with the .NET framework and best practices.
- NodeJS version 18.16.0 or later
- Visual Studio Code (optional)
- Clone this repository:
git clone https://github.com/pedroalejandropt/api-university.git
- Open the folder project
api-university
- Run the project
npm run server
- The API will be available at
http://localhost:5000/api
The API provides endpoints for managing universities, faculties, and courses. All requests require a JSON payload in the request body and return a JSON response.
GET /api/universities
: Retrieves a list of all universitiesGET /api/universities/{id}
: Retrieves a single university by IDPOST /api/universities
: Creates a new universityPUT /api/universities/{id}
: Updates an existing universityDELETE /api/universities/{id}
: Deletes a university by IDGET /api/universities/{id}/faculties
: Retrieves a list of all faculties for a universityGET /api/faculties/{id}
: Retrieves a single faculty by IDPOST /api/faculties
: Creates a new facultyPUT /api/faculties/{id}
: Updates an existing facultyDELETE /api/faculties/{id}
: Deletes a faculty by IDGET /api/faculties/{id}/courses
: Retrieves a list of all courses for a facultyGET /api/courses/{id}
: Retrieves a single course by IDPOST /api/courses
: Creates a new coursePUT /api/courses/{id}
: Updates an existing courseDELETE /api/courses/{id}
: Deletes a course by ID
POST /api/universities
{
"name": "University of Example",
"address": "123 Main St",
"city": "Exampleville",
"state": "EX",
"zip": "12345"
}
Response:
{
"id": 1,
"name": "University of Example",
"address": "123 Main St",
"city": "Exampleville",
"state": "EX",
"zip": "12345"
}
PUT /api/faculties/1
{
"name": "New Faculty Name"
}
Response:
{
"id": 1,
"name": "New Faculty Name",
"universityId": 1
}