This page shows you how to use the [fetch]/reference/api/data-plane/fetch) operation to fetch records by ID from an index namespace. The returned records are complete, including all relevant dense vector, metadata, and sparse vector values.

Fetch records from the default namespace

To fetch records from the default namespace ("") in an index, specify the record IDs but no namespace:

from pinecone.grpc import PineconeGRPC as Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("pinecone-index")

index.fetch(["id-1", "id-2"])

# Returns:
# {'namespace': '',
#  'usage': {'readUnits': 1},
#  'vectors': {'id-1': {'id': 'id-1',
#                       'values': [0.568879, 0.632687092, 0.856837332, ...]},
#              'id-2': {'id': 'id-2',
#                       'values': [0.00891787093, 0.581895, 0.315718859, ...]}}}

Fetch records from a non-default namespace

To fetch records from a non-default namespace in an index, specify the record IDs and the namespace:

from pinecone.grpc import PineconeGRPC as Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("pinecone-index")

index.fetch(ids=["id-1", "id-2"], namespace="ns1")

# Returns:
# {'namespace': 'ns1',
#  'usage': {'readUnits': 1},
#  'vectors': {'id-1': {'id': 'id-1',
#                       'values': [0.568879, 0.632687092, 0.856837332, ...]},
#              'id-2': {'id': 'id-2',
#                       'values': [0.00891787093, 0.581895, 0.315718859, ...]}}}

Data freshness

Pinecone is eventually consistent, so there can be a slight delay before new or changed records are visible to queries. You can use the describe_index_stats operation to check data freshness.

Was this page helpful?