Let's Use the API

M.Said's Restaurant API is perfect for any food-related project that requires restaurants, menus, and user data in JSON format. Check out the examples below to see how it works!

Restaurants

Get all restaurants

fetch('https://restaurant-app-api.runasp.net/api/Restaurant')
      .then(res => res.json())
      .then(json => console.log(json))

Filter by category

fetch('https://restaurant-app-api.runasp.net/api/Restaurant?category=Parsi Cuisine')
      .then(res => res.json())
      .then(json => console.log(json))

Filter by address and Restaurant Name

fetch('https://restaurant-app-api.runasp.net/api/Restaurant?address=hyderabad&name=Paradise Biryani')
      .then(res => res.json())
      .then(json => console.log(json))

The address may be a substring. The system performs a 'contains' operation to retrieve related addresses.

Get Restaurant by id

fetch('https://restaurant-app-api.runasp.net/api/Restaurant/4')
      .then(res => res.json())
      .then(json => console.log(json))

Get Restaurant menu

fetch('https://restaurant-app-api.runasp.net/api/Restaurant/5/menu')
      .then(res => res.json())
      .then(json => console.log(json))

Sort menu by price

fetch('https://restaurant-app-api.runasp.net/api/Restaurant/5/menu?sortbyprice=desc')
      .then(res => res.json())
      .then(json => console.log(json))

Prices sorted ascending with sortbyprice=asc, descending with sortbyprice=desc. If null, displayed in a random order.

Get all items

fetch('https://restaurant-app-api.runasp.net/api/Restaurant/items')
      .then(res => res.json())
      .then(json => console.log(json))

Search items by item name

fetch('https://restaurant-app-api.runasp.net/api/Restaurant/items?ItemName=fish')
      .then(res => res.json())
      .then(json => console.log(json))

Sort items by price

fetch('https://restaurant-app-api.runasp.net/api/Restaurant/items?sortbyprice=asc')
      .then(res => res.json())
      .then(json => console.log(json))

Prices sorted ascending with sortbyprice=asc, descending with sortbyprice=desc. If null, displayed in a random order.

Add a restaurant

fetch('https://restaurant-app-api.runasp.net/api/Restaurant', {
  method: "POST",
  body: JSON.stringify({ restaurantName: 'string', address: 'string', type: 'string', parkingLot: true })
})
  .then(res => res.json())
  .then(json => console.log(json))

The response is a temporary object only โ€” saving to the database is coming soon.

Add an item to a restaurant menu

fetch('https://restaurant-app-api.runasp.net/api/Restaurant/{Restaurant_id}/additem', {
  method: "POST",
  body: JSON.stringify({ itemName: "string", itemPrice: 0.00, itemDescription: "string", imageUrl: "string" })
})
  .then(res => res.json())
  .then(json => console.log(json))

The response is a temporary object only โ€” saving to the database is coming soon.

User

Get users

fetch('https://restaurant-app-api.runasp.net/api/User')
      .then(res => res.json())
      .then(json => console.log(json))

Get user code

fetch('https://restaurant-app-api.runasp.net/api/User/getusercode?UserEmail=tech@example.com&Password=string')
      .then(res => res.json())
      .then(json => console.log(json))

The user code is your unique API key. Required for all protected operations. Keep it secure.

Register new user

fetch('https://restaurant-app-api.runasp.net/api/User/register', {
  method: "POST",
  body: JSON.stringify({ userEmail: "user@bachelor.com", password: "sonicmaster" })
})
  .then(res => res.json())
  .then(json => console.log(json))

Delete user details

fetch('https://restaurant-app-api.runasp.net/api/User/{apikey}', { method: "DELETE" })
  .then(res => res.json())
  .then(json => console.log(json))

Replace {apikey} with your actual user code. Using the literal {apikey} will not work.

Update user details

fetch('https://restaurant-app-api.runasp.net/api/User/{apikey}', {
  method: "PUT",
  body: JSON.stringify(NewPassword)
})
  .then(res => res.json())
  .then(json => console.log(json))

The request body should be a string representing the new password.

Orders

Get orders

fetch('https://restaurant-app-api.runasp.net/api/Order?apikey={api key}')
      .then(res => res.json())
      .then(json => console.log(json))

Retrieves all master orders for the user associated with the given api key, including total price and user details.

Get orders by id

fetch('https://restaurant-app-api.runasp.net/api/Order/{master_id}?apikey={api key}')
      .then(res => res.json())
      .then(json => console.log(json))

Retrieves all individual orders within a specified master order. Each order has its own ID grouped under one master ID.

Make an order

fetch('https://restaurant-app-api.runasp.net/api/Order/{restaurant_id}/makeorder?apikey={api key}', {
  method: "POST",
  body: JSON.stringify({
    menuDTO: [
      { itemName: "Kofta Curry", quantity: 2 },
      { itemName: "Sheer Korma", quantity: 2 }
    ]
  })
})
  .then(res => res.json())
  .then(json => console.log(json))

Creates a master order (transaction). All individual item orders are grouped under one master order ID.

Delete master order

fetch('https://restaurant-app-api.runasp.net/api/Order/master/{master_ID}?apikey={api key}', { method: "DELETE" })
  .then(res => res.json())
  .then(json => console.log(json))

Delete single order

fetch('https://restaurant-app-api.runasp.net/api/Order/{order_ID}?apikey={api key}', { method: "DELETE" })
  .then(res => res.json())
  .then(json => console.log(json))