This project was created for mod 3 of Turing School of Software and Design
- Expose an API that aggregates data from multiple external APIs
- Expose an API that requires an authentication token
- Expose an API for CRUD functionality
- Determine completion criteria based on the needs of other developers
- Test both API consumption and exposure, making use of at least one mocking tool (VCR, Webmock, etc).
If you would like to demo this API on your local machine:
- Ensure you have Ruby 2.7.4 and Rails 5.2.8 installed
- Fork and clone down this repo and navigate to the root folder
- Run
bundle install
- Run
bundle exec figaro install
- Register for an edamam app id and key
- Register for an unsplash key
- Register for a google api key and enable the youtube api
- Add the following variables to
config/application.yml
:edamam_app_id
edamam_app_key
unsplash_key
google_api_key
- Run
rails db:{drop,create,migrate,seed}
- To run the test suite, run
bundle exec rspec
- To demo endpoints in postman or other tool, run
rails s
and use base urlhttp://localhost:3000
to explore the available endpoints
Get Recipes By Country
- GET "/api/v1/recipes?country=country_name"
- Sample response body:
{ "data": [ { "id": null, "type": "recipe", "attributes": { "title": "Andy Ricker's Naam Cheuam Naam Taan Piip (Palm Sugar Simple Syrup)", "url": "https://www.seriouseats.com/recipes/2013/11/andy-rickers-naam-cheuam-naam-taan-piip-palm-sugar-simple-syrup.html", "country": "thailand", "image": "https://edamam-product-images.s3.amazonaws.com..." } }, { "id": null, "type": "recipe", "attributes": { "title": "THAI COCONUT CREMES", "url": "https://food52.com/recipes/37220-thai-coconut-cremes", "country": "thailand", "image": "https://edamam-product-images.s3.amazonaws.com..." } }, {...}, {...}, ... ] }
Get Recipes for Random Country
- GET "/api/v1/recipes"
- Sample response body:
{ "data": [ { "id": null, "type": "recipe", "attributes": { "title": "Andy Ricker's Naam Cheuam Naam Taan Piip (Palm Sugar Simple Syrup)", "url": "https://www.seriouseats.com/recipes/2013/11/andy-rickers-naam-cheuam-naam-taan-piip-palm-sugar-simple-syrup.html", "country": "thailand", "image": "https://edamam-product-images.s3.amazonaws.com..." } }, { "id": null, "type": "recipe", "attributes": { "title": "THAI COCONUT CREMES", "url": "https://food52.com/recipes/37220-thai-coconut-cremes", "country": "thailand", "image": "https://edamam-product-images.s3.amazonaws.com..." } }, {...}, {...}, ... ] }
Get Learning Resources By Country
- GET "/api/v1/learning_resources?country=country_name"
- Sample response body:
{ "data": { "id": null, "type": "learning_resource", "attributes": { "country": "laos", "video": { "title": "A Super Quick History of Laos", "youtube_video_id": "uw8hjVqxMXw" }, "images": [ { "alt_tag": "time lapse photography of flying hot air balloon", "url": "https://images.unsplash.com/photo-1540611025311-01df3cef54b5..." }, { "alt_tag": "aerial view of city at daytime", "url": "https://images.unsplash.com/photo-1570366583862-f91883984fde..." }, {...}, {...}, ... ] } }
Create A New User
- POST "/api/v1/users"
- Sample request body:
{ "name": "Athena Dao", "email": "athenadao@bestgirlever.com" }
- Sample response body:
{ "data": { "type": "user", "id": "1", "attributes": { "name": "Athena Dao", "email": "athenadao@bestgirlever.com", "api_key": "jgn983hy48thw9begh98h4539h4" } } }
Create a New Favorite
- POST "/api/v1/favorites"
- Sample request body:
{ "api_key": "jgn983hy48thw9begh98h4539h4", "country": "thailand", "recipe_link": "https://www.tastingtable.com/.....", "recipe_title": "Crab Fried Rice (Khaao Pad Bpu)" }
- Sample response body:
{ "success": "Favorite added successfully" }
Get User's Favorites
- GET "/api/v1/favorites/?api_key=user_api_key"
- Sample response body:
{ "data": [ { "id": "1", "type": "favorite", "attributes": { "recipe_title": "Recipe: Egyptian Tomato Soup", "recipe_link": "http://www.thekitchn.com/recipe-egyptian-tomato-soup-weeknight....", "country": "egypt", "created_at": "2022-11-02T02:17:54.111Z" } }, { "id": "2", "type": "favorite", "attributes": { "recipe_title": "Crab Fried Rice (Khaao Pad Bpu)", "recipe_link": "https://www.tastingtable.com/.....", "country": "thailand", "created_at": "2022-11-07T03:44:08.917Z" } } ] }