-
Notifications
You must be signed in to change notification settings - Fork 1
API Endpoints
Because Snakebite aspires to follow the best conventions for RESTful web services, all HTTP requests that typically sends a payload (i.e., POST, PUT and PATCH methods) should have their payload written in JSON.
As such, the following is needed:
In HTTP request's headers: Content-Type: application/json
Endpoint | Method | Description | Permissions* | Progress | Notes |
---|---|---|---|---|---|
/restaurants | GET | Get all restaurants. Possible to filter based on criteria | All Users | 100% | Filters undone |
/restaurants | POST | Create a new restaurant. Required fields listed below | Admin & Owners | 100% | - |
/restaurants/<id> | GET | Get details of restaurant (of supplied id) | All Users | 100% | - |
/restaurants/<id> | PATCH | Update particular details of restaurant (of id) | Admin & Owners | 0% | we are not using UPDATE. see this article for explanation |
/restaurants/<id> | DELETE | Delete this restaurant (of id) | Admin | 100% | - |
/tags | GET | Get all tags sorted in popularity / frequency | All | 100% | - |
Get all restaurants. You can set search criteria in the query parameters of the request URL, such as the following:
query param | description | notes |
---|---|---|
name |
restaurant name |
name=KFC searches for restaurants with names containing KFC
|
description |
restaurant description |
description=curry search for restaurants with curry word in description |
email |
restaurant email | searches for exact match in emails |
menus.name |
menu name |
menus.name=karaage searches for restaurants with menu names matching karaage
|
tags |
restaurant tags |
tags=chicken,curry searches for restaurants with both chicken and curry tags |
menus.tags |
menu tags |
menus.tags=breakfast,western searches for restaurants with menu(s) containing breakfast and western tags |
start |
pagination offset | defaults to 0 , if start=1 , results return from 2nd restaurant |
limit |
query size limit | defaults to 20 ; returns a maximum of 20 items by default |
retrieving all restaurants of email info@diya-dining.jp and has been tagged curry
GET /restaurants?tags=curry&email=info@diya-dining.jp
{
"count": 1,
"items": [
{
"geolocation": {
"lat": 35.6604935,
"lon": 139.7300985
},
"address": "ROPPONGI HILLS HILL SIDE B1 6-10-1 ROPPONGI, MINATO-KU",
"description": "The first Contemporary Indian dining restaurant in Tokyo",
"name": "Diya",
"_id": {
"$oid": "54d5b9be81b4b70009bc0bac"
},
"menus": [
{
"tags": [
"india"
],
"images": [
"https://drive.google.com/open?id=0BxDkA70TnFRFLWpwMURLcDFIN1E&authuser=1"
],
"currency": "JPY",
"name": "Diya's Course",
"price": 3500,
"rating": 0
},
{
"tags": [
"chicken"
],
"images": [
"https://drive.google.com/open?id=0BxDkA70TnFRFQ0NoeHRxNDdEdVU&authuser=1"
],
"currency": "JPY",
"name": "CHICKEN TIKKA MAKHANI",
"price": 1480,
"rating": 0
}
],
"email": "info@diya-dining.jp",
"tags": [
"curry",
"indian",
"lunch buffet"
]
}
]
}
Create a new restaurant with menus (optional, encouraged). If success, returns the saved details.
creating a new Yoshinoya Restaurant with 2 menus
POST / restaurants
{
"name": "Yoshinoya",
"address": "5-2-1 Tsukiji, Chuo-ku, Tokyo",
"geolocation": {
"lat": 35.663968,
"lon": 139.770473", // optional
},
"email": "steaks@gmail.com",
"tags": "beef, franchise, japanese", // optional
"menus": [
{
"name": "Gyudon",
"price": 300.00,
"currency": "JPY", // defauls to JPY nonetheless
"images": ["http://example.com/1.jpg"]
},
{
"name": "Curry Rice Set",
"price": 500.00,
"currency": "JPY",
"images": ["http://example.com/2.jpg", "http://example.com/3.jpg"]
}
]
}
{
"_id": "27342859401923012401", // with ID returned!
"name": "Yoshinoya",
"address": "5-2-1 Tsukiji, Chuo-ku, Tokyo",
"geolocation": {
"lat": 35.663968,
"lon": 139.770473", // optional
},
"email": "steaks@gmail.com",
"tags": "beef, franchise, japanese", // optional
"menus": [
{
"name": "Gyudon",
"price": 300.00,
"currency": "JPY", // defauls to JPY nonetheless
"images": ["http://example.com/1.jpg"]
},
{
"name": "Curry Rice Set",
"price": 500.00,
"currency": "JPY",
"images": ["http://example.com/2.jpg", "http://example.com/3.jpg"]
}
]
}
Get the details of a particular restaurant of ID :id
Get the details of restaurant with ID 27342859401923012401
GET / restaurants/27342859401923012401
{
"_id": "27342859401923012401", // with ID returned!
"name": "Yoshinoya",
"address": "5-2-1 Tsukiji, Chuo-ku, Tokyo",
"geolocation": {
"lat": 35.663968,
"lon": 139.770473", // optional
},
"email": "steaks@gmail.com",
"tags": "beef, franchise, japanese", // optional
"menus": [
{
"name": "Gyudon",
"price": 300.00,
"currency": "JPY", // defaults to JPY nonetheless
"images": ["http://example.com/1.jpg"]
},
{
"name": "Curry Rice Set",
"price": 500.00,
"currency": "JPY",
"images": ["http://example.com/2.jpg", "http://example.com/3.jpg"]
}
]
}
Delete the restaurant of ID :id
Deleting the Yoshinoya restaurant above
DELETE / restaurants/27342859401923012401
http status code -> 200
Get tags used in Snakebite, ordered by most frequently used Available query params:
query params | description | notes |
---|---|---|
start |
pagination offset | defaults to 0 , if start=1 , results return from 2nd restaurant |
limit |
query size limit | defaults to 20 ; returns a maximum of 20 items by default |
Get the 6th - 10th most frequently used tags (5 tags in total)
GET / tags?start=5&limit=5
{
"count": 5,
"items": [
[
"bar",
0.09090909090909091
],
[
"roppongi",
0.09090909090909091
],
[
"japanese food",
0.09090909090909091
],
[
"lunch buffet",
0.09090909090909091
],
[
"grill",
0.09090909090909091
]
]
}