Understanding RapidAPI Integration in Android Development

I’m trying to work with RapidAPI in my Android project but I’m confused about their sample code. Can anyone explain what these components mean?

Here’s the example they provided:

HashMap<String, Parameter> requestData = new HashMap<String, Parameter>();

requestData.put("ParamKey1", new Parameter("info", "ParamValue1"));
requestData.put("ParamKey2", new Parameter("info", "ParamValue2"));

try {
    HashMap<String, Object> result = apiClient.execute("ServiceName", "MethodName", requestData);
    if(result.get("success") != null) { }
}

I don’t understand what ParamKey1 and ParamKey2 represent, what the “info” string does, or how ParamValue1 and ParamValue2 should be used.

I want to implement this code for a recipe API call:

HttpResponse<JsonNode> apiResponse = Unirest.get("https://recipe-api-service.p.mashape.com/food/find?category=vegan&exclude=nuts&detailed=true&allergies=dairy&premium=false&count=5&start=0&search=pasta&meal=dinner")
.header("X-Mashape-Key", "YourKeyHere")
.header("X-Mashape-Host", "recipe-api-service.p.mashape.com")
.asJson();

How do I convert this into the HashMap format they’re showing?

I ran into the same confusion when I started with RapidAPI’s docs. That HashMap stuff is from their old SDK - you don’t need it anymore. Your Unirest setup is the modern approach and way better. If you really want to understand the HashMap thing: it just breaks down URL parameters. So “category” becomes a ParamKey with “vegan” as the value, “exclude” maps to “nuts”, etc. The “info” parameter was just a data type classifier in their old system. Honestly though, stick with your Unirest code. It’s cleaner and easier to maintain. Just make sure you’re handling the JsonNode response correctly and you’re set.

the rapidapi sample uses their old sdk format, but your unirest code’s a different approach. just stick with unirest for your recipe api - don’t bother converting to hashmap. paramkey would be stuff like “category” and “exclude” with values like “vegan” and “nuts”, but honestly unirest’s way cleaner.

Those HashMap parameters are essentially query parameters from your URL expressed as key-value pairs. For your recipe API, ParamKey1 would be “category” with ParamValue1 as “vegan”, and ParamKey2 could be “exclude” with ParamValue2 as “nuts”. The “info” string is likely a type indicator for parameters in the RapidAPI SDK. However, I recommend sticking with your Unirest implementation as it is simpler and offers better support. Your current code is structured correctly and should work for making API calls to the recipe service.