Cookbook
Cookbook
Extract organisations, products and dates
Collect every named entity on a page from the annotations, with descriptions resolved.
1 min read · Updated 20 Nov 2026
On this page
Send a URL with no question and the passages come back with their annotations. Collecting their canonical forms gives you the entities a page mentions, with descriptions such as the agreement resolved to what they refer to.
entities.py
import osfrom collections import defaultdictimport requestsAPI = "https://fluxsearch.io/api/v1"URL = ( "https://www.batterytechonline.com/design-manufacturing/" "how-catl-moved-sodium-ion-batteries-from-lab-chemistry-to-gwh-scale-reality")response = requests.post( f"{API}/lineage", headers={"Authorization": f"Bearer {os.environ['FLUX_API_KEY']}"}, json={"url": URL}, timeout=180,)response.raise_for_status()found = defaultdict(set)for passage in response.json()["results"]: for a in passage["annotations"]: if a["type"] == "time" and not a["canonical"]: continue found[a["type"]].add(a["canonical"] or a["text"])for kind in ("organisation", "product", "time"): names = sorted(found[kind]) print(f"{kind} ({len(names)}): {', '.join(names[:8])}")const API = "https://fluxsearch.io/api/v1";const URL = "https://www.batterytechonline.com/design-manufacturing/" + "how-catl-moved-sodium-ion-batteries-from-lab-chemistry-to-gwh-scale-reality";const KINDS = ["organisation", "product", "time"];type Annotation = { type: string; text: string; canonical: string | null };const response = await fetch(`${API}/lineage`, { method: "POST", headers: { Authorization: `Bearer ${process.env.FLUX_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ url: URL }),});if (!response.ok) throw new Error(`Flux ${response.status}: ${await response.text()}`);const { results } = (await response.json()) as { results: { annotations: Annotation[] }[] };const found = new Map(KINDS.map((k) => [k, new Set<string>()]));for (const passage of results) { for (const a of passage.annotations) { if (a.type === "time" && !a.canonical) continue; found.get(a.type)?.add(a.canonical ?? a.text); }}for (const kind of KINDS) { const names = [...found.get(kind)!].sort(); console.log(`${kind} (${names.length}): ${names.slice(0, 8).join(", ")}`);}What it prints
Output
organisation (5): CATL, CATL and HyperStrong’s 60-GWh sodium-ion agreement, CATL and energy storage integrator HyperStrong, HyperStrong, the American Physical Societyproduct (3): LFP, Naxtra Sodium-ion Battery, Naxtra sodiumtime (1): 2026How it works
- Without
queries, no relevance threshold applies. A long page still returns a capped number of passages, 25 of 74 for this article, so some entities can be missed. - Dates without a
canonicalform, such asApril of this year, are dropped. - Types come from a tagger and can be wrong. Check them before you store them as facts.