Skip to content

Search API

Alfredo Sequeida edited this page Feb 24, 2023 · 9 revisions
  • Do not use this endpoint for auto-completing search results, use the autocomplete search endpoint instead: /autocomplete/search.
  • Location should be set prior to making a requests to the search API endpoint. See the /set/location API endpoint for more information

Usage example

const options = {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  credentials: "include",
  body: JSON.stringify({
    query: "pizza",
    cookies: {..., "uev2.loc": ""}
  }),
};

fetch("localhost:8000/api/search", options)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));

Note: for the cookies object, ... means other cookies, note that the uev2.loc cookie is required to be part of those cookies. These cookies can be obtained from the /set/location API.

Response example

[
  {
    "service": "postmates",
    "stores": [
      {
        "id": "",
        "title": "",
        "location": { "latitude": 0, "longitude": 0 },
        "deliveryFee": 0,
        "estimatedDeliveryTime": 0,
        "rating": 0,
        "image": ""
      }
    ]
  },
  {"service": "grubhub", stores: [{},{},{}, ...]},
  ...
]

Notes

  • Errors that take place will replace the stores array with an errors object, an example can be found below:

    [
     {
       "service": "postmates",
       "stores": [{},{},{}, ...]
     }
     {
       "service": "grubhub",
       "error": {status: 403, statusText: "Unauthorized"}
     },
     ...
    ]   
  • Refer to example response for types

  • estimatedDeliveryTime is in minutes

  • deliveryFee is in USD

  • rating is out of 5 and depending on the platform it can be a float value

  • deliveryFee seem to be promotional values ie: $0 on your first order, so they should not be used to calculate final costs.

  • Some stores don't have ratings, if that's the case, a null rating will be returned

  • Doordash (Web API vs Mobile API)

    • Still doing research on the doordash mobile API tokens, they can be created, but compared to the tokens generated by the mobile app, tokens seem to be less stable (more rate limiting)
    • Compared to the web API, the mobile API does not provide location data for the search endpoint. But the mobile API is the better API to use since it allows location as part of the query, so we can search different locations. Here are some ideas if we need the location data from this endpoint (at the time of search):
      • Query both Web and Mobile endpoints and merge the data (this could be seen as a lot of queries to the Doordash API, resulting in their servers rate limiting us)
      • Make another call to get detailed information for all restaurants (same potential issue as above)
      • Pull the location data from another source like google maps API or something similar.
  • The following maps the supported search parameters to each service. As APIs continue to be developed, more parameters will be supported.

    Service query location
    Postmates
    Grubhub
    DoorDash

Clone this wiki locally