If your team licenses stock photography from Getty, searching it from inside the app where the work happens beats alt-tabbing to a browser. The API is a straightforward search endpoint — the awkward part is getting access to it at all.
Read this before you start: API access is gated. There is no self-serve signup for the Getty Images API any more. Keys are issued against a license agreement, and Getty's own documentation directs you to contact your account representative. If you are not already a Getty customer, this script is not something you can run — that is a business constraint, not a technical one, and no amount of code works around it. The auth flow also changed: it is now two-part, an OAuth2 bearer token plus an Api-Key header on every call, and the old api.gettyimages.com/oauth2/token path returns 403. Tokens come from authentication.gettyimages.com now.
// ============================================
// GETTY IMAGES — SEARCH (OAuth2 + Api-Key)
// ============================================
string Getty.searchImages(string phrase)
{
API_KEY = "YOUR_GETTY_API_KEY";
API_SECRET = "YOUR_GETTY_API_SECRET";
// 1. Token. Note the host: authentication.gettyimages.com,
// NOT api.gettyimages.com/oauth2 - that path now returns 403.
authBody = Map();
authBody.put("grant_type","client_credentials");
authBody.put("client_id",API_KEY);
authBody.put("client_secret",API_SECRET);
authResp = invokeurl
[
url : "https://authentication.gettyimages.com/oauth2/token"
type : POST
parameters : authBody
headers: {"Content-Type":"application/x-www-form-urlencoded"}
];
token = authResp.getJSON("access_token");
if(token == null)
{
info "Getty auth failed: " + authResp.toString();
return "";
}
// 2. Search. Both headers are required.
headerMap = Map();
headerMap.put("Api-Key",API_KEY);
headerMap.put("Authorization","Bearer " + token);
searchResp = invokeurl
[
url : "https://api.gettyimages.com/v3/search/images?phrase="
+ zoho.encryption.urlEncode(phrase) + "&page_size=5"
type : GET
headers : headerMap
];
images = searchResp.getJSON("images");
if(images == null || images.size() == 0)
{
info "No results or error: " + searchResp.toString();
return "";
}
first = images.get(0);
info "Asset id: " + first.getJSON("id") + " title: " + first.getJSON("title");
// display_sizes carries the preview/comp URIs
sizes = first.getJSON("display_sizes");
if(sizes != null && sizes.size() > 0)
{
return sizes.get(0).getJSON("uri");
}
return "";
}Api-Key header, and omitting it returns a 403 that reads like a permissions problem rather than a missing header.display_sizes gives preview URIs suitable for review. Downloading a licensed, watermark-free file is a separate call and consumes against your agreement — do not wire it to anything automatic.This script is part of the free Creator Scripts Deluge Library.
All 39 Deluge scripts, the full Zoho Creator course, and every downloadable asset are now free. Get free access →