sdevikar
sdevikar

Reputation: 437

How to get restaurant menus from Locu API

I have looked at several APIs for acquiring restaurant menu for a particular location and determined that Locu API works best for me.

I was trying the basic example listed on locu website:

curl -X POST https://api.locu.com/v2/venue/search/ -d '{"fields":["name","menu_items","location","categories","description"],"menu_item_queries":[{"price":{"$lt":6},"name":"burrito"}],"venue_queries":[{"location":{"locality":"San Francisco"}}],"api_key":"MY_API_KEY"}'

Where, MY_API_KEY is the API_KEY that I received when I signed up. As long as I include "menu_items" parameter, I keep getting the response:

{"status": "error", "http_status": 400, "error": "The requested \"menu_items\" field is either invalid or your account does not have permissions to access it."}

I did not come across any documentation regarding what I need to do in order to get the permissions for querying "menu_items". If anyone could point me in the right direction, I will really appreciate that.

I have already gone through some relatively old questions on here and they did not address this particular issue.

Also, there doesn't seem to be a tag for Locu api here. I am going to try and tag the question with some generic tags. Please excuse me for that.

Upvotes: 2

Views: 1979

Answers (2)

Kruthika Kumar
Kruthika Kumar

Reputation: 1

`

  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.net.HttpURLConnection;
  import java.net.MalformedURLException;
  import java.net.URL;

public class NetClientGet {


public static void main(String[] args) {

  try{
      String result;
      URL url = new URL("https://api.locu.com/v1_0/venue/search/?api_key=" +apiKey);
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("GET");
      conn.setRequestProperty("Accept", "application/json");

      if (conn.getResponseCode() != 200) {
        throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(
        (conn.getInputStream())));

    String output;
    System.out.println("Output from Server .... \n");
    while ((output = br.readLine()) != null) {
        System.out.println(output);} 
   }           
    conn.disconnect();

  } catch (MalformedURLException e) {

    e.printStackTrace();

  } catch (IOException e) {

    e.printStackTrace();

  }
 }
}`

Upvotes: -1

apod
apod

Reputation: 568

I know this is an old question, but I've found that the solution is to request the "menus" field in a venue search. The API will return the "menu_items" as sub-objects of the menus.

Upvotes: 2

Related Questions