This Challenge is part of VanHackathon Challenges May 2016 where we would have 48 hours to do some project. I chose do a projeto of BroadbandTV, a small RESTful API named Meal Nutrition API. That RESTful API would allow users to save recipes and to get their aggregate nutrition information based on the nutrition information of each ingredient, using the USDA Nutrient Database API (https://ndb.nal.usda.gov/ndb/doc/index).
After I lost the first 24 hours, i have dedicated the last 24 to complete the challenge, apart, of course, two hours to sleep (I'm not Superman :-D).
It was not my best job, but I managed to finish and find a solution to the proposed problem, working with little time.
About
I made this focused in the perspective of final user. Through of the requests, the users can do a register and then maneger their recipes.
SETUP
In this project, i used the laravel framework that has a simple way to setup. For setup this project in webserver, follow the steps below:
- Do the upload all of the content to web server
- Copy the "public" folder to "public_html" folder of the web server.
- In the file "index.php", check if the path on the lines 22 and 36 are setted correctly.
- Edit the file ".env" in the root of project with the credentials of the database.
- Import the SQL file "webservice.sql" to the database.
Resquest's examples
After of the user register the system show the api token. The token should be put in the html header as "api_token". Once this is done the user can access the system.
http://www.com.br/api/user
Method: get
Description: return the user data
http://www.com.br/api/user/save
Method: post
Parameters: name, email, password
Description: Register a new user and return the data of the user including token of access.
http://www.com.br/api/user/update
Method: put
Parameters: name, email, password
Description: The user can edit their own data.
http://www.com.br/api/user/delete
Method: delete
Description: The user can delete your own account
http://www.com.br/api/recipes
Method: get
Description: Show all recipes of user
http://www.com.br/api/recipes/{id}
Method: get
Description: Show a especific recipe (recipe name, foods and their nutritional info and the all nutrition of recipe)
http://www.com.br/api/recipes/save
Method: post
Parameters: name
Description: Create a new recipe
http://www.com.br/api/recipes/edit/{id}
Method: put
Parameters: name
Description: Edit a especific recipe
http://www.com.br/api/recipes/delete/{id}
Method: put
Parameters: name
Description: Delete a especific recipe
http://www.com.br/api/recipes/addfood
Method: post
Parameters: recipe_id (recipe id), food_id( food id from NDB), qty (quantity in grams of the food)
Description: Add a food in a recipe.
DEMO
I also put this webservice in my home page: http://marcosricardo.com.br. If you want, you can see it there.
You can use the Postman (or similar) to access and also you need of a access token. If you dont want to make a register (http://marcosricardo.com.br/api/user/save), you can use this token: 8LfZXFaB0Begs1p8FOZUZfGWQ0nwIPtzWiuUFmnCk26Yf43wPIehYzzjTHq8


Log in or sign up for Devpost to join the conversation.