Call the Getty Images API from Zoho Creator with Deluge

Search the Getty Images API from Zoho Creator

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.

Before you start

  • A Getty API key and secret, obtained through your Getty account representative.
  • Nothing else — the flow below is self-contained.

Deluge function

// ============================================
// 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 "";
}

Notes

  • Both headers, every call. The bearer token alone is not enough; Getty also wants the Api-Key header, and omitting it returns a 403 that reads like a permissions problem rather than a missing header.
  • Cache the token. A client-credentials token is valid for a while — minting a new one per search wastes calls against your rate limit. Store it with an expiry, as the RingCentral and Docusign scripts in this library do.
  • Search results are comps, not licensed assets. 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.
  • If you cannot get a key, the practical alternatives with open APIs are Unsplash and Pexels. Both are free, both have straightforward developer signup, and both use the same shape of request as the function above.

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 →

    • Related Articles

    • Read Text and Label Images with Google Cloud Vision from Zoho Creator

      Photograph a receipt, get the text. Upload a product shot, get keywords for search. Cloud Vision does the hard part; Deluge only has to build a small JSON body and read the answer back. Still current, with one meaningful improvement. The endpoint ...
    • Cloudinary Image Management from Zoho Creator

      Creator stores images perfectly well, but it will not resize them, crop to a face, convert to WebP or serve them from a CDN. Cloudinary does all of that from the URL. Upload once from Deluge and every variant you ever need is a query string away. ...
    • Send Faxes with the RingCentral API from Zoho Creator

      This function sends a fax from a Zoho Creator record through the RingCentral API: it authenticates, caches the access token so you are not re-authenticating on every call, pulls a PDF from a Creator report, and posts it to RingCentral as a multipart ...
    • Send Documents for Signature with the Docusign API from Zoho Creator

      This function takes a Zoho Creator record, renders it to PDF, and sends it to a client for signature through Docusign — writing the envelope ID back onto the record so you can track it. Authentication runs through a Creator OAuth connection, so Zoho ...
    • Create a Zoho Meeting from Zoho Creator

      Book a session from the record that needs it. This function creates a Zoho Meeting from a Creator record and stores both the participant join link and the host start link back on the row, so the meeting lives alongside the work it belongs to. Do not ...