Git Product home page Git Product logo

animal-api's Introduction

Animal Shelter API

An API for an animal shelter - August 23, 2019

By Na Hyung Choi

Description

This API supports full CRUD functionality for an animal shelter database. The database contains a list of all animals at the shelter, with attributes such as species, gender, name, and spayed/neutered status. (For full schema and a sample request body for POST, please refer to the Swagger documentation. Setup instructions for it are below.)

In addition to basic CRUD methods, the API allows:

  • Optional query parameters for species and/or gender
  • Pagination of data
  • Retrieving a randomly selected animal
  • Automatic calculation of an animal's Age (in decimal years) when user creates an animal and inputs the Birthdate

Setup/Installation Requirements

  • This application requires MySQL.
  1. Clone this repository:

    $ git clone https://github.com/schoinh/animal-api.git
    
  2. Open the database context file (animal-api/Models/Animal_APIContext.cs) and replace EnvironmentVariables.MySQLKey with a string containing your MySQL password (ex: "abcd123").

  3. Log onto MySQL:

    $ mysql -u USERNAME -p PASSWORD
    
  4. Navigate to the project directory (Animal-API). Restore dependencies, update your local database, and run the API:

    $ dotnet restore
    $ dotnet ef database update
    $ dotnet run
    
  5. The API is now up and running. For full schema and a sample request body for POST, navigate to the Swagger documentation at http://localhost:5001.

Using the API

Basic CRUD

Endpoint HTTP Method Description
api/animals GET Return all animals, sorted by intake date (newest first). Optional query parameters: species, gender
api/animals/{id} GET Returns a specific animal
api/animals POST Creates a new animal
api/animals/{id} PUT Edits a specific animal
api/animals/{id} DELETE Deletes a specific animal

Pagination and Random Animal

Endpoint HTTP Method Description
api/animals/first GET Returns first page of animals (3 animals per page), sorted by intake date (newest first)
api/animals/next GET Returns next page of animals
api/animals/prev GET Returns previous page of animals
api/animals/random GET Returns a random animal

Example Call

http://localhost:5000/api/animals?species=Cat&gender=Male

Known Bugs

None at this time.

Technologies Used

  • C# / .NET Core
  • ASP.NET Core MVC
  • LINQ
  • MySQL
  • OpenAPI aka Swagger

Support and contact details

Please contact Na Hyung with questions and comments.

License

GNU GPLv3

Copyright (c) 2019 Na Hyung Choi

animal-api's People

Contributors

schoinh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.