A simple node.js web server that fetches data from a third-party (Swiggy) API and exposes it to a client (instafood) app.
- List all restaurants for the given location (lat & lng)
-
API Endpoint:
/api/restaurants
-
HTTP Method:
GET
-
Query Parameters:
lat (required)
: latitude of the location to search for restaurantslng (required)
: longitude of the location to search for restaurants -
Response Format:
JSON
-
URL:
https://instafood.onrender.com/api/restaurants?lat=:latquery&lng=:lngquery
-
Example Request:
https://instafood.onrender.com/api/restaurants?lat=12.9351929&lng=77.62448069999999
-
Explanation : This API fetches the restaurant data for the given location from Swiggy API and exposes it to the clients. The response format of this API is same as Swiggy API enpoint.
-
Usage : In react app , you can hit this API like mentioned below
fetch(`https://instafood.onrender.com/api/restaurants?lat=${latitude}&lng=${longitude}`)
Example :
const response = await fetch("https://instafood.onrender.com/api/restaurants?lat=12.9351929&lng=77.62448069999999")
const data = await response.json();
- List all menu items for the given restaurant Id (menuId)
-
API Endpoint:
/api/menu
-
HTTP Method:
GET
-
Query Parameters:
lat
(required) : latitude of the location to search for restaurants.lng
(required) : longitude of the location to search for restaurants.menuId
(required): ID of the restaurant's menu. -
Response Format:
JSON
-
URL:
https://instafood.onrender.com/api/restaurants?lat=:latquery&lng=:lngquery&menuId=:menuId
-
Example Request:
https://instafood.onrender.com/api/menu?lat=12.9351929&lng=77.62448069999999&menuId=113657
-
Explanation : This API fetches the restaurant data in json format for the given location from Swiggy API and exposes it to the clients. The response format of this API is same as Swiggy API enpoint.
-
Usage : In react app , you can hit this API like mentioned below
fetch(`https://instafood.onrender.com/api/restaurants?lat=${latitude}&lng=${longitude}&menuId=${menuId}`)
Example :
const response = await fetch("https://instafood.onrender.com/api/menu?lat=12.9351929&lng=77.62448069999999&menuId=113657")
const data = await response.json();
You need to write the following commands on the terminal screen (in vscode) so that you can run this project locally.
git clone "https://github.com/HarshithaSolai/instafood-server.git"
Go to the project directory
cd instafood-server
Install dependencies
npm install
Start the server
npm start
This server should now be running on localhost
.
Note : Push your code into your Github Repostory
- Create an account in "https://render.com/" using Github
- Click on
New +
and selectweb services
- Connect to the repository ( node server) which you want to deploy
- Now, your server will be deployed in few minutes and a url to access your server will be provided.
If you have any suggestions to improve this node server, please feel free to raise a PR.