The Recommendations API returns ranked content items from your publisher’s collection or the Gloo affiliate network. It is optimized for recommendation UI patterns, not open-ended search.
Prerequisites
Before starting, ensure you have:- A Gloo AI Studio account
- Your Client ID and Client Secret from the API Credentials page
- Your Tenant (publisher) name from Organizations in Studio
- Content uploaded to the Data Engine (see Upload Files Tutorial)
- Authentication setup — Complete the Authentication Tutorial first
Working Code Sample
Follow along with complete working examples in all 6 languages (JavaScript, TypeScript, Python, PHP, Go, Java). Includes a proxy server and browser-based frontend for each language.Setup and testing instructions are provided later.
Understanding the Recommendations API
Three endpoints cover the main recommendation use cases:| Endpoint | Purpose |
|---|---|
POST /ai/v1/data/items/recommendations/base | Publisher-scoped ranked items — metadata only |
POST /ai/v1/data/items/recommendations/verbose | Publisher-scoped ranked items — includes full snippet text |
POST /ai/v1/data/affiliates/referenced-items | Cross-publisher discovery from the Gloo affiliate network |
Publisher Endpoints (base & verbose)
Both publisher endpoints share the same required parameters:| Parameter | Description |
|---|---|
query | The topic or question to match content against |
item_count | Number of items to return (1–50) |
certainty_threshold | Minimum relevance score (0–1). Default: 0.75 |
collection | Always "GlooProd" |
tenant | Your publisher (tenant) name |
Affiliate Endpoint
The affiliate endpoint searches across the full Gloo publisher network so nocollection or tenant is required:
| Parameter | Description |
|---|---|
query | The topic or question to match content against |
item_count | Number of items to return (1–50) |
certainty_threshold | Minimum relevance score. Default: 0.75 |
Response Structure
Publisher endpoints return an array of items. Each item includes auuids array with the matched snippet and its relevance metadata:
uuids[0].certainty— Relevance score (0–1, higher = more relevant)uuids[0].ai_title— AI-generated section title for the matched snippetuuids[0].item_summary— AI-generated summary of the itemuuids[0].snippet— Full snippet text (verbose endpoint only)
uuids, adding tradition and item_subtitle fields instead.
Step 1: Publisher Recommendations
Let’s fetch ranked content from your publisher’s collection. The base endpoint returns metadata only with no snippet text, making it ideal for clean list UIs.What You’ll See
A successful call returns up to 5 items with metadata such as the title, summary, and relevance score:Summary and Section may not appear for every item — they are AI-generated metadata that depends on how content was processed during ingestion. Older or minimally processed content may return only Title, Author, and Relevance.
Run the Cookbook Example
The cookbook includes a ready-to-run basic search script for each language:Step 2: Recommendations with Snippet Previews
The verbose endpoint adds full snippet text to each result. This is ideal for content preview cards where you want to show a passage alongside the title. The only change from Step 1 is the endpoint URL and readinguuids[0].snippet from the response.
What You’ll See
Same as Step 1, with aPreview line added for each item:
Run the Cookbook Example
Step 3: Affiliate Network Discovery
The affiliate endpoint surfaces content from across the entire Gloo publisher network and not just your own collection. Use this to power “Explore More” sections that introduce users to resources from other publishers. Two key differences from the publisher endpoints:- No
collectionortenantin the request — the search spans the full affiliate network - Flat response structure — items have
traditionanditem_subtitlefields instead ofuuids
What You’ll See
Run the Cookbook Example
You can try out the script in the cookbook to search the affiliate network.Try It: Frontend Example
The cookbook includes a browser-based frontend that connects to a proxy server, letting you visualize all three recommendation modes. The proxy server keeps your credentials secure on the server side.Architecture
POST /api/recommendations/base— Publisher recommendations (metadata only)POST /api/recommendations/verbose— Publisher recommendations (with snippet previews)POST /api/recommendations/affiliates— Affiliate network discovery
Start the Proxy Server
Each language includes a proxy server. Start one:http://localhost:3000 in your browser.
Publisher Recommendations
Enter a query, choose how many items to return, and optionally enable Verbose mode to show snippet previews alongside each result:
Affiliate Network Discovery
The Explore More panel fires automatically alongside your publisher results, surfacing related content from across the Gloo network:
The frontend is language-agnostic — the same HTML/JS works with any language’s
proxy server. This is one approach; customize for your branding and framework.
Complete Working Examples
View Complete Code
Clone or browse the complete working examples for all 6 languages (JavaScript,
TypeScript, Python, PHP, Go, Java) with setup instructions, proxy servers, and
a browser-based frontend.
What’s Included
Each language implementation provides:auth— Shared OAuth2 token management with automatic refreshconfig— Centralized configuration (URLs, env vars)recommend_base— Publisher recommendations CLI (metadata only)recommend_verbose— Publisher recommendations CLI (with snippet text)recommend_affiliates— Affiliate network discovery CLIserver— Proxy server exposing REST endpoints for the frontend
Troubleshooting
No Results Returned
certainty_thresholdtoo strict: The default0.75filters out lower-confidence matches. Lower it to0.5to broaden results.- Content not indexed: Test the same query in the Search Playground. If content appears there, your API parameters are correct.
- Wrong tenant: Results are scoped to your publisher. Verify the tenant name matches your publisher in Organizations.
403 Forbidden
- You can only access your own publisher’s content via the publisher endpoints.
- Verify your Client ID and Client Secret are correct and not expired.
- The affiliate endpoint has broader access — a 403 there indicates an authentication issue.
Affiliate Endpoint Returns Empty
- Not all content is available in the affiliate network. Publishers must opt in.
- Try a broader or different query to confirm the endpoint is working.
Authentication Errors
- Tokens expire. Implement token refresh logic (see Authentication Tutorial).
- Ensure you’re using
Bearer {token}in the Authorization header.
Next Steps
Base Recommendations API Reference
Endpoint docs for recommendation results that return item metadata only.
Verbose Recommendations API Reference
Endpoint docs for recommendation results that include snippet previews.
Affiliate Referenced Items API Reference
Explore cross-publisher affiliate discovery for related content.
Upload Files
Add more content to your Data Engine for richer recommendations.

