|| Bad Food API ||
___________________________
Initiated 12/11/2020.
Project Docs Β· Report Bug Β· Request Feature
This API is a database on allergies and intolerances in foods. Everyone seems to have some issue with food from illness to taste or texture. This won't help with the later but I hope it will give some insight to the former. I used many scientific websites and documentation to come up with the information contained in this database but as science changes, so does our understanding of information. This information is as good as I can research as of December of 2020. Thank you.
- There are no known bugs at this time.
- Visual Studio Code
- C#
- ASP.NET Core MVC
- MySQL 8.0.20
- Entity Framework Core 2.2.6
- Swagger - NSwag 13.3.0
- Postman
- On macOS Mojave or later
- Click here to download the .NET Core SDK from Microsoft Corp for macOS.
- On Windows 10 x64 or later
- Click here to download the 64-bit .NET Core SDK from Microsoft Corp for Windows.
Enter the command dotnet tool install -g dotnet-script
in Terminal for macOS or PowerShell for Windows.
Download and install the appropriate version of MySQL Workbench.
(Optional) Download and install Postman.
To view or edit the code, you will need an code editor or text editor. The popular open-source choices for an code editor are Atom and VisualStudio Code.
- Code Editor Download:
- Option 1: Atom
- Option 2: VisualStudio Code
- Click the download most applicable to your OS and system.
- Wait for download to complete, then install -- Windows will run the setup exe and macOS will drag and drop into applications.
- Optionally, create a GitHub Account
- Navigate to the BadFoodApi Repository here.
- Click 'Clone or download' to reveal the HTTPS url ending with .git and the 'Download ZIP' option.
- Open up your system Terminal or GitBash, navigate to your desktop with the command:
cd Desktop
, or whichever location suits you best. - Clone the repository to your desktop:
$ git clone https://github.com/mmanchee/BadFoodApi.git
- Run the command
cd BadFoodApi
to enter into the project directory. - View or Edit:
- Code Editor - Run the command
atom .
orcode .
to open the project in Atom or VisualStudio Code respectively for review and editing. - Text Editor - Open by double clicking on any of the files to open in a text editor.
- Code Editor - Run the command
- Navigate to the BadFoodApi Repository here.
- Click 'Clone or download' to reveal the HTTPS url ending with .git and the 'Download ZIP' option.
- Click 'Download ZIP' and unextract.
- Open by double clicking on any of the files to open in a text editor.
- Create a new file in the BadFoodApi/BadFoodApi directory named
appsettings.json
- Add in the following code snippet to the new appsettings.json file:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Port=3306;database=BadFoodApi;uid=root;pwd=YourPassword;"
}
}
- Change the server, port, and user id as necessary. Replace 'YourPassword' with relevant MySQL password (set at installation of MySQL).
- Navigate to BadFoodApi/BadFoodApi directory using the MacOS Terminal or Windows Powershell (e.g.
cd Desktop/BadFoodApi/BadFoodApi
). - Run the command
dotnet ef database update
to generate the database through Entity Framework Core. - (Optional) To update the database with any changes to the code, run the command
dotnet ef migrations add <MigrationsName>
which will use Entity Framework Core's code-first principle to generate a database update. After, run the previous commanddotnet ef database update
to update the database.
- Navigate to BadFoodApi/BadFoodApi directory using the MacOS Terminal or Windows Powershell (e.g.
cd Desktop/BadFoodApi/BadFoodApi
). - Run the command
dotnet run
to have access to the API in Postman or browser.
Search by Food Search by Issue Get Nutrition on a Food
Explore the API endpoints in Postman or a browser. You will not be able to utilize authentication in a browser.
To explore the Historical Football Stats api with NSwag, launch the project using dotnet run
with the Terminal or Powershell, and input the following URL into your browser: http://localhost:5003/swagger/index.html
In order to be authorized to use the POST, PUT, DELETE functionality of the API, please authenticate yourself through Postman.
- Open Postman and create a POST request using the URL:
http://localhost:5003/api/users/authenticate
- Add the following query to the request as raw data in the Body tab:
{
"UserName": "test",
"Password": "test"
}
- The token will be generated in the response. Copy and paste it as the Token parameter in the Authorization tab.
CORS is a W3C standard that allows a server to relax the same-origin policy. It is not a security feature, CORS relaxes security. It allows a server to explicitly allow some cross-origin requests while rejecting others. An API is not safer by allowing CORS. For more information or to see how CORS functions, see the Microsoft documentation.
https://localhost:5003/api/foods/
To use default, don't include limit
and start
or set them equal to zero.
Base URL: https://localhost:5003
Method | Location | Description |
---|---|---|
Food | ... | ... |
GET | /api/Foods | Full food List |
GET | /api/Foods/{id} | Food by id |
GET | /api/Foods/search | search by Name, Category, Sub Category, or Description |
GET | /api/Foods/FoodList | Accepts JSON string |
... | ... | ... |
Users | ... | ... |
POST | /Users/authenticate | ... |
GET | /Users | ... |
https://localhost:5003/api/Foods/2
{
"data": {
"foodId": 26,
"name": "ARTICHOKES",
"category": "VEG",
"subCat": "FLOWER",
"description": "ARTICHOKES,(GLOBE OR FRENCH),RAW",
"fdcId": 11007,
"caffeine": 0,
"egg": 0,
"fish": 0,
"fodmap": 3,
"fructose": 2,
"gluten": 0,
"histamine": 1,
"lactose": 0,
"lectin": 0,
"legume": 0,
"nut": 0,
"oxalte": 0,
"salicylates": 0,
"shellfish": 0,
"soy": 0,
"sulfites": 0,
"tryamine": 1
},
"succeeded": true,
"errors": null,
"message": ""
}
Author | GitHub | |
---|---|---|
Mike Manchee | mmanchee | mikemanchee@gmail.com |
If you have any feedback or concerns, please contact me.
This project is licensed under the MIT License. Copyright (C) 2020 Mike Manchee. All Rights Reserved.
MIT License
Copyright (c) 2020 **_Mike Manchee_**
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Information for this API Nutrition Data FoodData Central
Issue Data Food Allergens/ Mast Cell 360 Food Compatibility Healthline
Other Links JsonSerialization
"A school for tech careers... to help people learn the skills they need to get great jobs."
"...The Internet is becoming the town square for the global village of tomorrow..."
- Bill Gates
Return to Top