> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pinecone.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch vectors

> The `fetch` operation looks up and returns vectors, by ID, from a single namespace. The returned vectors include the vector data and/or metadata.
For on-demand indexes, since vector values are retrieved from object storage, fetch operations may have increased latency. If you only need metadata or IDs, consider using the query operation with `includeValues` set to `false` instead.
For guidance and examples, see [Fetch data](https://docs.pinecone.io/guides/manage-data/fetch-data).

<RequestExample>
  ```python Python theme={null}
  # pip install "pinecone[grpc]"
  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="example-namespace")
  ```

  ```javascript JavaScript theme={null}
  // npm install @pinecone-database/pinecone
  import { Pinecone } from '@pinecone-database/pinecone'

  const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' })
  const index = pc.index('pinecone-index')

  const fetchResult = await index.namespace('example-namespace').fetch(['id-1', 'id-2']);
  ```

  ```java Java theme={null}
  import io.pinecone.clients.Index;
  import io.pinecone.clients.Pinecone;
  import io.pinecone.proto.FetchResponse;

  import java.util.Arrays;
  import java.util.List;

  public class FetchExample {
      public static void main(String[] args) {
          Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
          Index index = pc.getIndexConnection("pinecone-index");
          List<String> ids = Arrays.asList("id-1", "id-2");
          FetchResponse fetchResponse = index.fetch(ids, "example-namespace");
          System.out.println(fetchResponse);
      }
  }
  ```

  ```shell curl theme={null}
  PINECONE_API_KEY="YOUR_API_KEY"
  INDEX_HOST="INDEX_HOST"

  curl -X GET "https://$INDEX_HOST/vectors/fetch?ids=id-1&ids=id-2&namespace=example-namespace" \
    -H "Api-Key: $PINECONE_API_KEY" \
    -H "X-Pinecone-Api-Version: 2024-04"
  ```
</RequestExample>


## OpenAPI

````yaml https://raw.githubusercontent.com/pinecone-io/pinecone-api/refs/heads/main/2024-04/data_2024-04.oas.yaml get /vectors/fetch
openapi: 3.0.3
info:
  title: Pinecone Data Plane API
  description: >-
    Pinecone is a vector database that makes it easy to search and retrieve
    billions of high-dimensional vectors.
  version: 2024-04
  contact:
    name: Pinecone Support
    url: https://support.pinecone.io
    email: support@pinecone.io
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
servers:
  - url: https://{index_host}
    variables:
      index_host:
        default: unknown
        description: host of the index
security:
  - ApiKeyAuth: []
tags:
  - name: Data Plane
externalDocs:
  description: More Pinecone.io API docs
  url: https://docs.pinecone.io/introduction
paths:
  /vectors/fetch:
    get:
      tags:
        - Data Plane
      summary: Fetch vectors
      description: >-
        The `fetch` operation looks up and returns vectors, by ID, from a single
        namespace. The returned vectors include the vector data and/or metadata.

        For on-demand indexes, since vector values are retrieved from object
        storage, fetch operations may have increased latency. If you only need
        metadata or IDs, consider using the query operation with `includeValues`
        set to `false` instead.

        For guidance and examples, see [Fetch
        data](https://docs.pinecone.io/guides/manage-data/fetch-data).
      operationId: fetch
      parameters:
        - name: ids
          description: The vector IDs to fetch. Does not accept values containing spaces.
          in: query
          required: true
          explode: true
          schema:
            type: array
            items:
              type: string
        - name: namespace
          in: query
          required: false
          schema:
            type: string
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FetchResponse'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/rpcStatus'
components:
  schemas:
    FetchResponse:
      type: object
      properties:
        vectors:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Vector'
          title: >-
            The fetched vectors, in the form of a map between the fetched ids
            and the fetched vectors
        namespace:
          type: string
          example: example-namespace
          description: The namespace of the vectors.
        usage:
          $ref: '#/components/schemas/Usage'
      description: The response for the `fetch` operation.
      example:
        vectors:
          id-1:
            id: id-1
            values:
              - 1
              - 1.5
          id-2:
            id: id-2
            values:
              - 2
              - 1
        namespace: example-namespace
        usage:
          readUnits: 1
    rpcStatus:
      type: object
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/protobufAny'
    Vector:
      type: object
      properties:
        id:
          type: string
          example: example-vector-1
          description: This is the vector's unique id.
          maxLength: 512
          minLength: 1
          required:
            - id
        values:
          type: array
          example:
            - 0.1
            - 0.2
            - 0.3
            - 0.4
            - 0.5
            - 0.6
            - 0.7
            - 0.8
          items:
            type: number
            format: float
          description: This is the vector data included in the request.
          maxLength: 20000
          minLength: 1
          required:
            - values
        sparseValues:
          $ref: '#/components/schemas/SparseValues'
        metadata:
          type: object
          example:
            genre: documentary
            year: 2019
          description: This is the metadata included in the request.
      required:
        - id
        - values
    Usage:
      type: object
      properties:
        readUnits:
          type: integer
          format: int64
          example: 5
          description: The number of read units consumed by this operation.
    protobufAny:
      type: object
      properties:
        typeUrl:
          type: string
        value:
          type: string
          format: byte
    SparseValues:
      type: object
      description: >-
        Vector sparse data. Represented as a list of indices and a list of 
        corresponded values, which must be with the same length.
      properties:
        indices:
          type: array
          description: The indices of the sparse data.
          example:
            - 1
            - 312
            - 822
            - 14
            - 980
          items:
            type: integer
            format: int64
          maxLength: 1000
          minLength: 1
          required:
            - indices
        values:
          type: array
          description: >-
            The corresponding values of the sparse data, which must be with the
            same length as the indices.
          example:
            - 0.1
            - 0.2
            - 0.3
            - 0.4
            - 0.5
          items:
            type: number
            format: float
          maxLength: 1000
          minLength: 1
          required:
            - values
      required:
        - indices
        - values
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: Api-Key
      description: >-
        An API Key is required to call Pinecone APIs. Get yours from the
        [console](https://app.pinecone.io/).
      in: header

````