A significant portion of our responses may have icons available to represent the item. Whenever present, they will be returned as a short name in the iconId field of a record. To save response time on searches, the images themselves are not returned with each item; instead you can use this iconId to be formatted into our Icon CDN Path. The CDN provides fast delivery in most regions.
Note that icon's are not guaranteed; some icons are exact representations, while others may use inheritance and be representative but not explicit. An example of this might be that you could receive an icon of a bunch of bananas for an item called "Banana slices".
Icon CDN Path
You can format the IconID into our Icon CDN Path to serve your icon files.
In the case below, the iconId in the path is BEV0257
Note that all icons are available in 3 sizes based on the suffix used:
-90.jpg // 90 x 90(px) icon
-180.jpg // 180 x 180(px) icon
-360.jpg // 360 x 360(px) icon
These sizes should allow you to support speed on smaller list items such as search results, as well as having large variations for page views.
Example Icon Setup Code
Important Notes:
All examples assume you have previously executed a search or result api call, and have parsed the information into some model responseObject
Examples show only how to retrieve the correct URL for each icon
What you do with the icon URL varies per language/framework. Examples do not include requests to download the icon from the URL, or steps to place the URL into an <img> tag, etc.
React/JS
const BASE_URL = "https://storage.googleapis.com/passio-prod-env-public-cdn-data/label-icons/%s-%d.jpg";
const IconSmall = 90;
const IconMed = 180;
const IconLarge = 360;
// Your model for the response of the item in question
// (a search or result route response)
// Only iconId is shown for brevity
const responseObject = { iconId: "BEV0257" };
function getIconUrl(obj, size) {
return BASE_URL.replace("%s", obj.iconId).replace("%d", size);
}
// Example usage
console.log(getIconUrl(responseObject, IconSmall));
Python
BASE_URL = "https://storage.googleapis.com/passio-prod-env-public-cdn-data/label-icons/%s-%d.jpg"
IconSmall = 90
IconMed = 180
IconLarge = 360
# Your model for the response of the item in question
# (a search or result route response)
# Only iconId is shown for brevity
responseObject = {"iconId": "BEV0257"}
def get_icon_url(responseObject, size):
return BASE_URL % (responseObject["iconId"], size)
# Example usage
print(get_icon_url(responseObject, IconSmall))
Go
package main
import (
"fmt"
)
const (
BaseURL = "https://storage.googleapis.com/passio-prod-env-public-cdn-data/label-icons/%s-%d.jpg"
IconSmall = 90
IconMed = 180
IconLarge = 360
)
// Your model for the response of the item in question
// (a search or result route response)
// Only iconId is shown for brevity
type ResponseObject struct {
IconId string
}
func GetIconURL(obj ResponseObject, size int) string {
return fmt.Sprintf(BaseURL, obj.IconId, size)
}
func main() {
responseObject := ResponseObject{IconId: "BEV0257"}
fmt.Println(GetIconURL(responseObject, IconSmall))
}
Swift
let baseUrl = "https://storage.googleapis.com/passio-prod-env-public-cdn-data/label-icons/%@-%d.jpg"
let iconSmall: Int = 90
let iconMed: Int = 180
let iconLarge: Int = 360
// Your model for the response of the item in question
// (a search or result route response)
// Only iconId is shown for brevity
let responseObject = ["iconId": "BEV0257"]
func getIconUrl(responseObject: [String: String], size: Int) -> String {
if let iconId = responseObject["iconId"] {
return String(format: baseUrl, iconId, size)
}
return ""
}
// Example usage
print(getIconUrl(responseObject: responseObject, size: iconSmall))
Java
public class IconUrlFormatter {
private static final String BASE_URL = "https://storage.googleapis.com/passio-prod-env-public-cdn-data/label-icons/%s-%d.jpg";
private static final int IconSmall = 90;
private static final int IconMed = 180;
private static final int IconLarge = 360;
public static String getIconUrl(ResponseObject responseObject, int size) {
return String.format(BASE_URL, responseObject.getIconId(), size);
}
public static void main(String[] args) {
// init dummy response from API route
ResponseObject responseObject = new ResponseObject("BEV0257");
System.out.println(getIconUrl(responseObject, IconSmall));
}
}
// Your model for the response of the item in question
// (a search or result route response)
// Only iconId is shown for brevity
class ResponseObject {
private String iconId;
public ResponseObject(String iconId) {
this.iconId = iconId;
}
public String getIconId() {
return iconId;
}
}
Feel free to serve these directly to users from our CDN - thats what its there for!