Client API vs. Indexing API
The split, and what each half is for
You'll be able to
- Explain the boundary between the Client API and the Indexing API
- Decide which API a given task belongs to
Read first
Day 5 Lab
- List read tasks: search, chat, autocomplete, recommendations โ these are Client API.
- List write tasks: register a datasource, push documents, push people and permissions โ these are Indexing API.
- Note the auth difference: Client calls are typically user-scoped; Indexing calls are admin/global-scoped.
- For each task on your roadmap, label it CLIENT or INDEXING before you write any code.
Working Example: Two Clients, Two Jobs
The Client API reads what is already indexed, scoped to a user. The Indexing API writes new content and its permissions, scoped to an admin token. Verified against developer_platform.
import os
from glean import Glean
# CLIENT API: read the graph as a specific user (honors their permissions).
read_client = Glean(
instance=os.environ["GLEAN_INSTANCE"],
api_token=os.environ["GLEAN_API_TOKEN"],
actas_user=os.environ["END_USER_EMAIL"],
)
hits = read_client.client.search.query(query="release notes", page_size=5)
# INDEXING API: write into the graph with an admin-scoped token.
index_client = Glean(
instance=os.environ["GLEAN_INSTANCE"],
api_token=os.environ["GLEAN_INDEXING_TOKEN"],
)
# index_client.indexing.documents.index(...) # covered on Day 6
If the task is "make something searchable," it is Indexing. If the task is "find or answer over what exists," it is Client. Verified against developer_platform.
Check for understanding
You need to push 10k support tickets into Glean so they're searchable. Which API, and why not the other?
Check yourself
1. Which set of languages does Glean ship typed Developer Platform clients for?
2. Why does a user-scoped token return different results for two different users running the same query?
3. In a Chat API response, what do the citations tell you?
4. You need to make 10,000 support tickets searchable in Glean. Which API do you use?
5. When pushing documents through the Indexing API, why must you include permission metadata?
In 10 seconds
โTwo APIs, one boundary. The Client API reads the graph โ search, chat, recommendations. The Indexing API writes to it โ datasources, documents, people. Reading is user-scoped; writing is admin-scoped.โ
The Indexing API