# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
index = pc.preview.index(name="articles")
NAMESPACE = "example-namespace"
response = index.documents.fetch(
namespace=NAMESPACE,
ids=["doc1", "doc2"],
include_fields=["title", "body", "category"],
)
for doc_id, doc in response.documents.items():
print(doc_id, getattr(doc, "title", ""))
// Status: 200 OK
{
"documents": {
"doc1": {
"_id": "doc1",
"title": "Machine learning in 2024",
"body": "Machine learning models are revolutionizing natural language processing",
"category": "technology"
},
"doc2": {
"_id": "doc2",
"title": "Vector databases",
"body": "Vector databases enable fast similarity search across embeddings",
"category": "technology"
}
},
"namespace": "__default__",
"usage": { "read_units": 2 }
}
Documents
Fetch documents
Fetch documents from a namespace by their IDs. Returns the specified fields for each document.
POST
/
namespaces
/
{namespace}
/
documents
/
fetch
# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
index = pc.preview.index(name="articles")
NAMESPACE = "example-namespace"
response = index.documents.fetch(
namespace=NAMESPACE,
ids=["doc1", "doc2"],
include_fields=["title", "body", "category"],
)
for doc_id, doc in response.documents.items():
print(doc_id, getattr(doc, "title", ""))
// Status: 200 OK
{
"documents": {
"doc1": {
"_id": "doc1",
"title": "Machine learning in 2024",
"body": "Machine learning models are revolutionizing natural language processing",
"category": "technology"
},
"doc2": {
"_id": "doc2",
"title": "Vector databases",
"body": "Vector databases enable fast similarity search across embeddings",
"category": "technology"
}
},
"namespace": "__default__",
"usage": { "read_units": 2 }
}
Full-text search is in public
preview and uses API version
2026-01.alpha. APIs may continue to evolve before general availability.Fetch is ID-only. The endpoint does not accept a
filter parameter — text match operators ($match_phrase, $match_all, $match_any) and metadata filter expressions are rejected with a 400 error. To retrieve documents matching a metadata expression, use POST /namespaces/{namespace}/documents/search with a filter to get IDs, then fetch by ID.include_fields is optional. When omitted, all stored fields on each document are returned.
# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
index = pc.preview.index(name="articles")
NAMESPACE = "example-namespace"
response = index.documents.fetch(
namespace=NAMESPACE,
ids=["doc1", "doc2"],
include_fields=["title", "body", "category"],
)
for doc_id, doc in response.documents.items():
print(doc_id, getattr(doc, "title", ""))
// Status: 200 OK
{
"documents": {
"doc1": {
"_id": "doc1",
"title": "Machine learning in 2024",
"body": "Machine learning models are revolutionizing natural language processing",
"category": "technology"
},
"doc2": {
"_id": "doc2",
"title": "Vector databases",
"body": "Vector databases enable fast similarity search across embeddings",
"category": "technology"
}
},
"namespace": "__default__",
"usage": { "read_units": 2 }
}
Authorizations
Headers
Required date-based version header
Path Parameters
The namespace to fetch documents from.
Body
application/json
Response
A successful fetch response.
The response for the fetch_documents operation.
A map of document IDs to their fetched documents.
Show child attributes
Show child attributes
The namespace the documents were fetched from.
Example:
"my-namespace"
Usage information for the fetch_documents operation.
Show child attributes
Show child attributes
Example:
{ "read_units": 5 }Was this page helpful?
⌘I