How to retrieve namespaces from the Pinecone index?

1 min read
After a couple of days of effort, I've successfully discovered how to retrieve namespaces from the Pinecone index. Here's the method that finally worked:
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({ apiKey: "YOUR_API_KEY" })
const index = pc.index("pinecone-index")
const stats = await index.describeIndexStats();
This code is pretty straightforward: it sets up a connection to the Pinecone database using your API key, then retrieves the stats for the index, which includes all the namespaces.
0
Subscribe to my newsletter
Read articles from Hamid Nawaz directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
