# getMultipleAccounts

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://solana-mainnet.g.alchemy.com/v2/{apiKey}

Returns the account information for a list of Pubkeys.

Reference: https://www.alchemy.com/docs/chains/solana/solana-api-endpoints/get-multiple-accounts

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Pubkeys | string[] | Yes | An array of Pubkeys to query. |
| Configuration | object | No | Optional configuration object. |

## Result

**Account information** (object[]): An array of JSON objects containing account details.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "getMultipleAccounts",
  "params": [
    [
      "GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q",
      "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    ]
  ],
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://solana-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getMultipleAccounts",
  "params": [
    [
      "GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q",
      "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    ],
    {
      "commitment": "processed",
      "minContextSlot": 1,
      "dataSlice": {
        "length": 1,
        "offset": 1
      },
      "encoding": "base64"
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'getMultipleAccounts',
    params: [
      [
        'GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q',
        'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
      ],
      {
        commitment: 'processed',
        minContextSlot: 1,
        dataSlice: {length: 1, offset: 1},
        encoding: 'base64'
      }
    ]
  })
};

fetch('https://solana-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://solana-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getMultipleAccounts",
    "params": [
        ["GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q", "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"],
        {
            "commitment": "processed",
            "minContextSlot": 1,
            "dataSlice": {
                "length": 1,
                "offset": 1
            },
            "encoding": "base64"
        }
    ]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://solana-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getMultipleAccounts\",\n  \"params\": [\n    [\n      \"GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q\",\n      \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\"\n    ],\n    {\n      \"commitment\": \"processed\",\n      \"minContextSlot\": 1,\n      \"dataSlice\": {\n        \"length\": 1,\n        \"offset\": 1\n      },\n      \"encoding\": \"base64\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://solana-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getMultipleAccounts\",\n  \"params\": [\n    [\n      \"GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q\",\n      \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\"\n    ],\n    {\n      \"commitment\": \"processed\",\n      \"minContextSlot\": 1,\n      \"dataSlice\": {\n        \"length\": 1,\n        \"offset\": 1\n      },\n      \"encoding\": \"base64\"\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://solana-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getMultipleAccounts\",\n  \"params\": [\n    [\n      \"GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q\",\n      \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\"\n    ],\n    {\n      \"commitment\": \"processed\",\n      \"minContextSlot\": 1,\n      \"dataSlice\": {\n        \"length\": 1,\n        \"offset\": 1\n      },\n      \"encoding\": \"base64\"\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: getMultipleAccounts
description: Returns the account information for a list of Pubkeys.
params:
  - name: Pubkeys
    required: true
    description: An array of Pubkeys to query.
    schema:
      type: array
      items:
        title: Pubkey
        type: string
        description: Base-58 encoded public key.
  - name: Configuration
    required: false
    description: Optional configuration object.
    schema:
      title: GetMultipleAccounts Configuration
      type: object
      properties:
        commitment:
          title: Commitment Level
          type: string
          description: Configures the state commitment for querying.
          enum:
            - processed
            - confirmed
            - finalized
        minContextSlot:
          title: Minimum Context Slot
          type: integer
          description: The minimum slot that the request can be evaluated at.
        dataSlice:
          title: Data Slice
          type: object
          properties:
            length:
              type: integer
              description: Number of bytes to return.
            offset:
              type: integer
              description: Byte offset from which to start reading.
        encoding:
          default: base64
          title: Data Encoding
          type: string
          description: Encoding format for data.
          enum:
            - base58
            - base64
            - base64+zstd
            - jsonParsed
examples:
  - name: getMultipleAccounts example
    params:
      - name: Pubkeys
        value:
          - GwsPP9HHhCvEQeu3HTFzsVL6DEtnnYw4ALEtA3fMBC9Q
          - EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
result:
  name: Account information
  description: An array of JSON objects containing account details.
  schema:
    type: array
    items:
      title: Account Information
      type: object
      properties:
        lamports:
          type: integer
          description: Number of lamports assigned to this account.
        owner:
          title: Pubkey
          type: string
          description: Program owner of this account.
        data:
          title: Account Data
          type: array
          description: Account data in the specified encoding format.
          items:
            type: string
        executable:
          type: boolean
          description: Indicates if the account contains a program.
        rentEpoch:
          type: integer
          description: The epoch at which this account will next owe rent.
        size:
          type: integer
          description: The data size of the account.
```
