Quick start¶
This walks through the whole flow with curl: create a project, add
documents, search them, and look at what was stored. It assumes the API
runs at localhost:8000 (Installation).
Tip
Every request here can also be sent from the interactive docs at http://localhost:8000/docs, which show every field of every request and response.
Authentication
Authentication is off by default, so these requests need no key. With
AUTH_ENABLED=true, add -H "Authorization: Bearer $PAGELORE_KEY" to
each one. See Authentication.
1. Create a project¶
A project is a set of documents with its own vector collection. It can set default chunking options and a keyword-search language for its documents.
curl -X POST localhost:8000/api/v1/projects -H 'Content-Type: application/json' \
-d '{"project_name": "handbook"}'
You can set defaults while creating it:
curl -X POST localhost:8000/api/v1/projects -H 'Content-Type: application/json' \
-d '{"project_name": "handbook",
"chunking": {"strategy": "recursive", "chunk_size": 800},
"text_search_language": "english"}'
2. Add documents¶
curl -X POST localhost:8000/api/v1/projects/1/documents \
-F files=@handbook.pdf -F files=@benefits.docx -F files=@policies.zip
ZIP and TAR archives are expanded, and each file inside becomes its own document.
curl -X POST localhost:8000/api/v1/projects/1/documents/url \
-H 'Content-Type: application/json' \
-d '{"urls": ["https://docs.example.com/"], "max_depth": 2}'
Links on the same host are followed up to two clicks away, and robots.txt is obeyed.
Every file gets its own result with a reason. One bad file never fails the rest:
| Status | Meaning |
|---|---|
indexed |
Extracted, chunked, embedded and searchable |
created |
Stored but not processed yet (process: false) |
duplicate |
The project already has this exact content |
skipped |
The key already exists and on_conflict is skip |
unchanged |
The web page or S3 object did not change since its import |
unsupported |
No loader reads this file type on this server |
rejected |
Refused: too large, an unsafe archive member, over a limit |
failed |
Processing failed; message says why |
Sync adds missing (the page or object is gone) and deleted (gone, and
deleted with delete_missing).
Large imports can run in the background. Send background=true and the
response comes back at once with a job_id. Poll the job until its
status is succeeded; its result then lists each file:
curl -X POST localhost:8000/api/v1/projects/1/documents \
-F files=@handbook.pdf -F background=true # → "job_id": 1
curl localhost:8000/api/v1/projects/1/jobs/1 # → "status": "running", "progress": {...}
A restart does not lose the job; see Background jobs.
3. Search¶
curl -X POST localhost:8000/api/v1/projects/1/retrieve -H 'Content-Type: application/json' \
-d '{"query": "How many vacation days do I get?", "mode": "hybrid", "top_k": 3}'
{
"query": "How many vacation days do I get?",
"mode": "hybrid",
"results": [
{
"rank": 1,
"score": 0.0163,
"file_name": "handbook.pdf",
"text": "Full-time employees receive 25 days of paid vacation per year...",
"citation": "handbook.pdf, page 12, Benefits > Vacation",
"metadata": {"page_start": 12, "page_end": 12, "page_unit": "page",
"headings": ["Benefits", "Vacation"]},
"vector_rank": 1, "keyword_rank": 2
// ids, chunk_index, ...
}
],
"documents": [{"document_id": 1, "file_name": "handbook.pdf", "hits": 2,
"best_score": 0.0163, "version": 1}],
"stats": {"candidates": 40, "duplicate": 1, "took_ms": 38.4},
"warnings": []
}
Pass each result's text and citation to your LLM, for example:
import httpx
hits = httpx.post("http://localhost:8000/api/v1/projects/1/retrieve",
json={"query": question, "mode": "hybrid", "top_k": 5}).json()["results"]
context = "\n\n".join(f"[{h['citation']}]\n{h['text']}" for h in hits)
prompt = f"Answer from these sources and cite them.\n\n{context}\n\nQuestion: {question}"
4. Look at what was stored¶
# Documents, with their status, version and metadata
curl 'localhost:8000/api/v1/projects/1/documents'
# One document's chunks in reading order, with their locations
curl 'localhost:8000/api/v1/projects/1/documents/1/chunks'
# Try other chunking options on a stored document, without changing it
curl -X POST localhost:8000/api/v1/projects/1/documents/1/preview \
-H 'Content-Type: application/json' -d '{"chunking": {"strategy": "semantic"}}'
5. Make search better¶
Once the basics work, these are the usual next steps:
- Hybrid search: combine meaning and exact keywords. Good for names, codes and rare terms.
- Reranking: rescore the best candidates with a cross-encoder.
- Small-to-big: search small chunks and return the larger passage around them.
- Contextual retrieval: let an LLM write a short context for each chunk.
- Evaluation: measure which of these helps on your own documents before you switch.