Skip to main content
Pinecone Docs

Search documentation

Type to search this documentation.

On this pageOverview

Target an index

Target a Pinecone index by host URL (recommended for production) or by name for data operations like upsert, query, and fetch across SDKs.

This method is recommended for production:

Python
from pinecone.grpc import PineconeGRPC as Pineconepc = Pinecone(api_key="YOUR_API_KEY")index = pc.Index(host="INDEX_HOST")
JavaScript
import { Pinecone } from '@pinecone-database/pinecone';const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' });// For the Node.js SDK, you must specify both the index host and name.const index = pc.index("INDEX_NAME", "INDEX_HOST");
Java
import io.pinecone.clients.Index;import io.pinecone.configs.PineconeConfig;import io.pinecone.configs.PineconeConnection;public class TargetIndexByHostExample {    public static void main(String[] args) {        PineconeConfig config = new PineconeConfig("YOUR_API_KEY");        config.setHost("INDEX_HOST");        PineconeConnection connection = new PineconeConnection(config);        // For the Java SDK, you must specify both the index host and name.        Index index = new Index(connection, "INDEX_NAME");    }}
Go
package mainimport (    "context"    "fmt"    "log"    "github.com/pinecone-io/go-pinecone/v4/pinecone")func main() {    ctx := context.Background()    pc, err := pinecone.NewClient(pinecone.NewClientParams{        ApiKey: "YOUR_API_KEY",    })    if err != nil {        log.Fatalf("Failed to create Client: %v", err)    }    // This creates a new gRPC index connection, targeting the namespace "example-namespace"    idxConnectionNs1, err := pc.Index(pinecone.NewIndexConnParams{Host: "INDEX_HOST", Namespace: "example-namespace"})    if err != nil {        log.Fatalf("Failed to create IndexConnection for Host %v: %v", idx.Host, err)    }    // This reuses the gRPC index connection, targeting a different namespace	idxConnectionNs2 := idxConnectionNs1.WithNamespace("example-namespace2")}

You can get the unique DNS host for an index from the Pinecone console or the Pinecone API.

To get an index host from the Pinecone console:

  1. Open the Pinecone console.
  2. Select the project containing the index.
  3. Select the index.
  4. Copy the URL under HOST.

To get an index host from the Pinecone API, use the describe_index operation, which returns the index host as the host value:

Python
from pinecone.grpc import PineconeGRPC as Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")

pc.describe_index(name="docs-example")

# Response:
# {'deletion_protection': 'disabled',
#  'dimension': 1536,
#  'host': 'docs-example-4zo0ijk.svc.us-east1-aws.pinecone.io',
#  'metric': 'cosine',
#  'name': 'docs-example',
#  'spec': {'serverless': {'cloud': 'aws', 'region': 'us-east-1'}},
#  'status': {'ready': True, 'state': 'Ready'}}
JavaScript
import { Pinecone } from '@pinecone-database/pinecone';

const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' });

await pc.describeIndex('docs-example');

// Response:
// {
//    "name": "docs-example",
//    "dimension": 1536,
//    "metric": "cosine",
//    "host": "docs-example-4zo0ijk.svc.us-east1-aws.pinecone.io",
//    "deletionProtection": "disabled",
//    "spec": {
//       "serverless": {
//          "cloud": "aws",
//          "region": "us-east-1"
//       }
//    },
//    "status": {
//       "ready": true,
//       "state": "Ready"
//    }
// }
Java
import io.pinecone.clients.Pinecone;
import org.openapitools.db_control.client.model.*;

public class DescribeIndexExample {
    public static void main(String[] args) {
        Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
        IndexModel indexModel = pc.describeIndex("docs-example");
        System.out.println(indexModel);
    }
}

// Response:
// class IndexModel {
//     name: docs-example-java
//     dimension: 1536
//     metric: cosine
//     host: docs-example-4zo0ijk.svc.us-west2-aws.pinecone.io
//     deletionProtection: enabled
//     spec: class IndexModelSpec {
//         pod: null
//         serverless: class ServerlessSpec {
//             cloud: aws
//             region: us-east-1
//         }
//     }
//     status: class IndexModelStatus {
//         ready: true
//         state: Ready
//     }
// }
Go
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "log"

    "github.com/pinecone-io/go-pinecone/v4/pinecone"
)

func prettifyStruct(obj interface{}) string {
    bytes, _ := json.MarshalIndent(obj, "", "  ")
    return string(bytes)
}

func main() {
    ctx := context.Background()

    pc, err := pinecone.NewClient(pinecone.NewClientParams{
        ApiKey: "YOUR_API_KEY",
    })
    if err != nil {
        log.Fatalf("Failed to create Client: %v", err)
    }

    idx, err := pc.DescribeIndex(ctx, "docs-example")
    if err != nil {
        log.Fatalf("Failed to describe index \"%v\": %v", idx.Name, err)
    } else {
        fmt.Printf("index: %v\n", prettifyStruct(idx))
    }
}

// Response:
// index: {
// 	"name": "docs-example",
// 	"dimension": 1536,
// 	"host": "docs-example-govk0nt.svc.apw5-4e34-81fa.pinecone.io",
// 	"metric": "cosine",
//  "deletion_protection": "disabled",
// 	"spec": {
// 	  "serverless": {
// 		"cloud": "aws",
// 		"region": "us-east-1"
// 	  }
// 	},
// 	"status": {
// 	  "ready": true,
// 	  "state": "Ready"
// 	}
// }
curl
PINECONE_API_KEY="YOUR_API_KEY"

curl -i -X GET "https://api.pinecone.io/indexes/docs-example-curl" \
    -H "Api-Key: $PINECONE_API_KEY" \
    -H "X-Pinecone-Api-Version: 2026-07"

# Response:
# {
#    "name": "docs-example-curl",
#    "host": "docs-example-curl-4zo0ijk.svc.aped-4627-b74a.pinecone.io",
#    "status": {
#       "ready": true,
#       "state": "Ready"
#    },
#    "deployment": {
#       "deployment_type": "managed",
#       "region": "us-east-1",
#       "cloud": "aws",
#       "environment": "aped-4627-b74a"
#    },
#    "read_capacity": {
#       "mode": "OnDemand",
#       "status": {
#          "state": "Ready",
#          "current_shards": null,
#          "current_replicas": null
#       }
#    },
#    "schema": {
#       "fields": {
#          "chunk_text": {
#             "type": "string",
#             "description": null,
#             "full_text_search": {
#                "language": "en",
#                "stemming": false,
#                "stop_words": false
#             }
#          },
#          "embedding": {
#             "type": "dense_vector",
#             "description": null,
#             "dimension": 1536,
#             "metric": "cosine"
#          }
#       }
#    },
#    "deletion_protection": "disabled"
# }

This method is convenient for testing but isn't recommended for production:

Python
from pinecone.grpc import PineconeGRPC as Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")

index = pc.Index("docs-example")
JavaScript
import { Pinecone } from '@pinecone-database/pinecone';

const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' });

// For the Node.js SDK, you must specify both the index host and name.
const index = pc.index('docs-example');
Java
import io.pinecone.clients.Index;
import io.pinecone.clients.Pinecone;

public class GenerateEmbeddings {
    public static void main(String[] args) throws ApiException {
        Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
        Index index = pc.getIndexConnection("docs-example");
    }
}
Go
// It is not possible to target an index by name in the Go SDK. 
// You must target an index by host.
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu