0% found this document useful (0 votes)
210 views60 pages

My Restaurant API Document

This document specifies the My Restaurant API for a food ordering application. The API allows users to get restaurant, user, and favorite food data. It includes documentation for endpoints to get all users, restaurants, a specific restaurant by ID, and favorite foods by Facebook ID and restaurant. Sample requests and responses are provided. The database schema includes tables for users, restaurants, menus, foods, orders, and more.

Uploaded by

José Francisco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
210 views60 pages

My Restaurant API Document

This document specifies the My Restaurant API for a food ordering application. The API allows users to get restaurant, user, and favorite food data. It includes documentation for endpoints to get all users, restaurants, a specific restaurant by ID, and favorite foods by Facebook ID and restaurant. Sample requests and responses are provided. The database schema includes tables for users, restaurants, menus, foods, orders, and more.

Uploaded by

José Francisco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

[EDMTDEV] MY RESTAURANT API

MY RESTAURANT API DOCUMENT


Author : eddydn aka LinhNTH
Version : 1.0
Last Update: 05/26/2019
YouTube: https://wWw.youtube.com/eddydn71

[email protected] 1
[EDMTDEV] MY RESTAURANT API

[email protected] 2
[EDMTDEV] MY RESTAURANT API

[email protected] 3
[EDMTDEV] MY RESTAURANT API

I. Introduction
This document is a document of the specification of the My Restaurant
project, a project of a long series of lectures designed to support food ordering from
a variety of combined restaurants.
All assets and documents used in the project are provided free of charge
by EddyDn in the teaching process. Any details can be tracked at
wWw.youtube.com/eddydn71
MyRestaurant project is a passionate project of EddyDn, built for the series
of mobile application development series on Android operating system, through this
series you will learn how:
- Write Backend with NodeJS (support MSSQL or MySQL)
- Write Frontend with Android Studio (Maybe have Kotlin version)
Main features of the application
- Splash Screen
- Login / Logout with Facebook Account Kit
- View multiple restaurant
- Search nearby restaurant on MAP (support by Backend)
- Multiple categories
- Category can be dynamic change for any restaurant
- Multiple foods
- Food can be dynamic change for any Category
- Room persistence + RxJava use for Cart (client save)
- Retrofit + RxJava use for API request
- Support Online Payment (Braintree)
- Each Restaurant can be have each Payment gateway
- API support both MySQL and MSSQL
- Notification between Client / Restaurant App
- Each restaurant will have each account to manager
- Food can be have size , addon

[email protected] 4
[EDMTDEV] MY RESTAURANT API

Software Requirements:
a. Backend NodeJS + MSSQL
- Microsoft SQL Server 2017
- Microsoft SQL Server Management 18.0 (If you want to work with
- Visual Studio 2019 (NodeJS development)
- Android Studio 3.4.1 (latest)

b. Backend NodeJS + MySQL


- XAMPP 7.3.5
- Visual Studio 2019 (NodeJS development)
- Android Studio 3.4 (latest)

[email protected] 5
[EDMTDEV] MY RESTAURANT API

I. Database
In this version , I will show you my own first design of Database

[email protected] 6
[EDMTDEV] MY RESTAURANT API

a. User
This table will contain basic information about the user

MSSQL

MySQL

[email protected] 7
[EDMTDEV] MY RESTAURANT API

b. Restaurant
This table will contain basic information about the restaurant ,
‘UserOwner’ is Id of RestaurantOwner user . This will help
restaurant can be manage by multiple user

MSSQL

MySQL

[email protected] 8
[EDMTDEV] MY RESTAURANT API

c. RestaurantOwner
This table will contain user , but this user owner restaurant or is
staff of restaurant

MSSQL

MySQL

[email protected] 9
[EDMTDEV] MY RESTAURANT API

d. Menu
This table will contain all information about Menu

MSSQL

MySQL

[email protected] 10
[EDMTDEV] MY RESTAURANT API

e. Food
This table will contain all information of Food

MSSQL

MySQL

[email protected] 11
[EDMTDEV] MY RESTAURANT API

f. Menu_Food
This table will help us can create multiple food for multiple menu

MSSQL

MySQL

g. Restaurant_Menu
This table will help us can create multiple menu for multiple
restaurant

MSSQL

MySQL

[email protected] 12
[EDMTDEV] MY RESTAURANT API

h. Size
This table will contain size of food (Some food have size like
Pizza)

MSSQL

MySQL

[email protected] 13
[EDMTDEV] MY RESTAURANT API

i. Addon
This table will contain addon of food (Some food can be choose
addon like Pizza with special sauce)

MSSQL

MySQL

[email protected] 14
[EDMTDEV] MY RESTAURANT API

j. Food_Size
This table will help food can be multiple size

MSSQL

MySQL

k. Food_Addon
This table will help food can be multiple addon

MSSQL

MySQL

[email protected] 15
[EDMTDEV] MY RESTAURANT API

l. Order
This table will contain all information about order of user

MSSQL

MySQL

[email protected] 16
[EDMTDEV] MY RESTAURANT API

m. OrderDetail
This table will contain all detail of order

MSSQL

MySQL

[email protected] 17
[EDMTDEV] MY RESTAURANT API

n. Favorite
This table will contain all information about Food Favorite of User

MSSQL

MySQL

[email protected] 18
[EDMTDEV] MY RESTAURANT API

II. API Document


All API need request to :
http://localhost:3000 => Main Endpoint on Computer
http://10.0.2.2:3000 => Main Endpoint on Emulator Android

Tool use for test:


- Google Chrome (Web Browser)
- AdvancedRestClient (Chrome Exentions)
- Postman (option)

GET ALL USER

Endpoin Method Query Body


t
/user GET key
fbid
Example: http://localhost:3000/user?key=YOUR_API_KEY&userPh
one=%2b0988888888
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing user_phone query in


url"}
Reason: Missing fbid in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result":[{"userPhone":"+84988353682","
name":"Eddy","address":"123444"}]}
- {"success":false,"message":"Empty"}

[email protected] 19
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

[email protected] 20
[EDMTDEV] MY RESTAURANT API

GET ALL RESTAURANT

Endpoint Method Query Body


/restaurant GET key
Example: http://localhost:3000/restaurant?key=YOUR_API_KEY
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

Example use in Advanced Rest Client

[email protected] 21
[EDMTDEV] MY RESTAURANT API

GET ALL RESTAURANT BY ID

Endpoint Method Query Body


/restaurant GET Key
ById restaurantId
Example: http://localhost:3000/restaurantById?key=YOUR_API_K
EY&restaurantId=1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing restaurantId field in


query","result":null}
Reason: Missing restaurantId in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 22
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

[email protected] 23
[EDMTDEV] MY RESTAURANT API

GET FAVORITES BY FBID

Endpoi Method Query Body


nt
/favorite GET Key
fbid
Example http://localhost:3000/favorite?key=YOUR_API_KEY&fbid
: =xxxx
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing restaurantId field in


query","result":null}
Reason: Missing fbid in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 24
[EDMTDEV] MY RESTAURANT API

Example use with Advanced Client

[email protected] 25
[EDMTDEV] MY RESTAURANT API

GET FAVORITES BY RESTAURANT

Endpoint Method Query Body


/favoriteByRes GET Key
taurant Fbid
restaurantId
Example: http://localhost:3000/
favoriteByRestaurant?key=YOUR_API_KEY&fbid=
xxxx&restaurantId=1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing fbid field in


query","result":null}
Reason: Missing fbid in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 26
[EDMTDEV] MY RESTAURANT API

Example use with Advanced Rest Client

[email protected] 27
[EDMTDEV] MY RESTAURANT API

GET NEARBY RESTAURANT

Endpoint Method Query Body


/nearbyrestaurant GET Key
Lat
Lng
Distance

Example: http://localhost:3000/
nearbyrestaurant?key=YOUR_API_KEY&lat=
30.328820&lng= -81.485750&distance=10
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing lat or lng field in


query","result":null}
Reason: Missing key Lat or Lng in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 28
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

[email protected] 29
[EDMTDEV] MY RESTAURANT API

GET ALL MENU BY RESTAURANT

Endpoint Method Query Body


/menu GET Key
restaurantId
Example: http://localhost:3000/
menu?key=YOUR_API_KEY& restaurantId=1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing restaurantId field in


query","result":null}
Reason: Missing key restaurantId in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 30
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

[email protected] 31
[EDMTDEV] MY RESTAURANT API

GET ALL FOOD BY MENU

Endpoint Method Query Body


/food GET Key
menuId
Example: http://localhost:3000/
food?key=YOUR_API_KEY& menuId=1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing menuId field in


query","result":null}
Reason: Missing key menuId in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 32
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

[email protected] 33
[EDMTDEV] MY RESTAURANT API

GET FAVORITE BY USER

Endpoint Method Query Body


/favorite GET Key
fbid
restaurantId
Example: http://localhost:3000/
food?key=YOUR_API_KEY&
fbid=xxx&restaurantId=1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing menuId field in


query","result":null}
Reason: Missing key foodName in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 34
[EDMTDEV] MY RESTAURANT API

[email protected] 35
[EDMTDEV] MY RESTAURANT API

GET LIST FAVORITE ID BY FBID AND RESTAURANT

Endpoint Method Query Body


/favoriteByRestaurant GET Key
fbid
restaurantId
Example: http://localhost:3000/
food?key=YOUR_API_KEY&
fbid=xxx&restaurantId=1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing menuId field in


query","result":null}
Reason: Missing key foodName in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 36
[EDMTDEV] MY RESTAURANT API

[email protected] 37
[EDMTDEV] MY RESTAURANT API

SEARCH FOOD BY NAME

Endpoint Method Query Body


/searchfood GET Key
foodName
Example: http://localhost:3000/
food?key=YOUR_API_KEY& menuId=1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing menuId field in


query","result":null}
Reason: Missing key foodName in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 38
[EDMTDEV] MY RESTAURANT API

[email protected] 39
[EDMTDEV] MY RESTAURANT API

GET FOOD BY ID

Endpoint Method Query Body


/foodById GET Key
foodId
Example: http://localhost:3000/
food?key=YOUR_API_KEY& foodId=1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing foodId field in


query","result":null}
Reason: Missing key foodId in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 40
[EDMTDEV] MY RESTAURANT API

[email protected] 41
[EDMTDEV] MY RESTAURANT API

GET ALL SIZE BY FOOD

Endpoint Method Query Body


/size GET Key
foodId
Example: http://localhost:3000/ size?key=YOUR_API_KEY&
foodId =1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing foodId field in


query","result":null}
Reason: Missing key foodId in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 42
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

[email protected] 43
[EDMTDEV] MY RESTAURANT API

GET ALL ADDON BY FOOD

Endpoint Method Query Body


/addon GET Key
foodId
Example: http://localhost:3000/addon?key=YOUR_API_KEY&
foodId =1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing foodId field in


query","result":null}
Reason: Missing key foodId in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 44
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

[email protected] 45
[EDMTDEV] MY RESTAURANT API

GET ALL ORDER BY USER

Endpoint Method Query Body


/order GET Key
orderPhone
Example: http://localhost:3000/order?key=YOUR_API_KEY&
orderPhone =%2B988888888
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing orderPhone field in


query","result":null}
Reason: Missing key orderPhone in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 46
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

[email protected] 47
[EDMTDEV] MY RESTAURANT API

GET ALL ORDER DETAIL BY ORDER

Endpoint Method Query Body


/orderdetail GET Key
orderId
Example: http://localhost:3000/
orderdetail?key=YOUR_API_KEY& orderId =54
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing orderId field in


query","result":null}
Reason: Missing key orderId in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}
- {"success":false,"message":"Empty"}

[email protected] 48
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

[email protected] 49
[EDMTDEV] MY RESTAURANT API

CREATE OR UPDATE USER

Endpoint Method Query Body


/user POST Key
userPhone
userName
userAddress
fbid
Example: http://localhost:3000/user
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

{"success":false,"message":"Missing userPhone
- field in query","result":null}
Reason: Missing key userPhone
in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"Success”}

[email protected] 50
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

[email protected] 51
[EDMTDEV] MY RESTAURANT API

CREATE NEW ORDER NUMBER BY USER

Endpoint Method Query Body


/createOrder POST Key
orderFBID
orderPhone
orderName
orderAddress
orderDate
restaurantId
transactionId
cod
totalPrice
numOfItem
Example: http://localhost:3000/ createOrder
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

- {"success":false,"message":"Missing orderPhone field in


query","result":null}
Reason: Missing key orderPhone in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}

[email protected] 52
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

If COD = 1 (TRUE) , so we can don’t care about TransactionId , we can put it


NONE
If COD = 0 (FALSE) , we must add transactionId , transactionId will return from
Braintree when you make payment in app

[email protected] 53
[EDMTDEV] MY RESTAURANT API

ADD ORDER DETAIL FOR ORDER

Endpoint Method Query Body


/updateOrder POST Key
orderId
orderDetail
Example: http://localhost:3000/ updateOrder
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

{"success":false,"message":"Missing orderId
- field in query","result":null}
Reason: Missing key orderId
in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"Success”}

[email protected] 54
[EDMTDEV] MY RESTAURANT API

Example use in Advanced Rest Client

#Note: orderDetail field is an JSON object of all detail of Information


In this example I use :
[{"foodAddon":"[{\"extraPrice\":5.0,\"id\":2,\"name\":\"Special Sauce
02\"},{\"extraPrice\":5.0,\"id\":3,\"name\":\"Special Sauce
03\"}]","foodExtraPrice":14.0,"foodId":39,"foodImage":"http://10.0.2.2:3000/21_
mushroom_pizza.jpg","foodName":"MUSHROOM
PIZZA","foodPrice":25.0,"foodQuantity":2,"foodSize":"Large","restaurantId":1,"
userPhone":"+84988353682"}]
Parse it by JSON to understandable

[email protected] 55
[EDMTDEV] MY RESTAURANT API

[email protected] 56
[EDMTDEV] MY RESTAURANT API

CREATE NEW FAVORITE

Endpoint Method Query Body


/favorite POST Key
fbid
foodId
restaurantId
restaurantName
foodName
foodImage
price

Example: http://localhost:3000/ createOrder


Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

{"success":false,"message":"Missing fbid field in query","result":null}


Reason: Missing key fbid in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"result…}]}

[email protected] 57
[EDMTDEV] MY RESTAURANT API

[email protected] 58
[EDMTDEV] MY RESTAURANT API

DELETE Favorite

Endpoi Method Query Body


nt
/favorit DELETE Key
e fbid
foodId
restaurantId
Exampl http://localhost:3000/favorite?key=xxx&fbid=xxx&foodId=1
e: &restaurantId=1
Error:
- {"success":false,"message":"Wrong API","result":null}
Reason: Missing key (API key) in query

{"success":false,"message":"Missing orderId
- field in query","result":null}
Reason: Missing key orderId
in query

- {"success":false,"message":"…"}
Reason: error from server

Result:
- {"success":true,"Success”}

[email protected] 59
[EDMTDEV] MY RESTAURANT API

[email protected] 60

You might also like