# sui_tryGetPastObject

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

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

Returns object details for a specified version. Note that nodes may prune older versions depending on their configuration, and retrieval is not guaranteed.


Reference: https://www.alchemy.com/docs/chains/sui/sui-api-endpoints/sui-try-get-past-object

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| object_id | string | Yes | The ID of the queried object. |
| version | integer | Yes | The specific version to query. No default is applied. |
| options | object | No | Options to specify which fields are returned in the object. |

## Result

**result** (object): The response describing the object version if found.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "sui_tryGetPastObject",
  "params": [
    "0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760",
    4,
    {
      "showType": true,
      "showOwner": true,
      "showPreviousTransaction": true,
      "showDisplay": false,
      "showContent": true,
      "showBcs": false,
      "showStorageRebate": true
    }
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "status": "VersionFound",
    "details": {
      "objectId": "0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760",
      "version": "4",
      "digest": "5VPAwDXy3BL72ehFc7gSJoz27ahMd6spUg5YwYc4ibcv",
      "type": "0x2::coin::Coin<0x2::sui::SUI>",
      "owner": {
        "AddressOwner": "0x3568c40e814d9d5396d23087a0fd641e91e0e00df6c012cded9ef9ba5e5bf042"
      },
      "previousTransaction": "5jQByoouHBwaico5pQB73GdbzerC2StjTiHh5garBjiV",
      "storageRebate": "100",
      "content": {
        "dataType": "moveObject",
        "type": "0x2::coin::Coin<0x2::sui::SUI>",
        "hasPublicTransfer": true,
        "fields": {
          "balance": "10000",
          "id": {
            "id": "0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760"
          }
        }
      }
    }
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://sui-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "sui_tryGetPastObject",
  "params": [
    "0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760",
    4,
    {
      "showType": true,
      "showOwner": true,
      "showPreviousTransaction": true,
      "showDisplay": false,
      "showContent": true,
      "showBcs": false,
      "showStorageRebate": true
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'sui_tryGetPastObject',
    params: [
      '0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760',
      4,
      {
        showType: true,
        showOwner: true,
        showPreviousTransaction: true,
        showDisplay: false,
        showContent: true,
        showBcs: false,
        showStorageRebate: true
      }
    ]
  })
};

fetch('https://sui-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://sui-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "sui_tryGetPastObject",
    "params": [
        "0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760",
        4,
        {
            "showType": True,
            "showOwner": True,
            "showPreviousTransaction": True,
            "showDisplay": False,
            "showContent": True,
            "showBcs": False,
            "showStorageRebate": True
        }
    ]
}
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://sui-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"sui_tryGetPastObject\",\n  \"params\": [\n    \"0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760\",\n    4,\n    {\n      \"showType\": true,\n      \"showOwner\": true,\n      \"showPreviousTransaction\": true,\n      \"showDisplay\": false,\n      \"showContent\": true,\n      \"showBcs\": false,\n      \"showStorageRebate\": true\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://sui-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"sui_tryGetPastObject\",\n  \"params\": [\n    \"0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760\",\n    4,\n    {\n      \"showType\": true,\n      \"showOwner\": true,\n      \"showPreviousTransaction\": true,\n      \"showDisplay\": false,\n      \"showContent\": true,\n      \"showBcs\": false,\n      \"showStorageRebate\": true\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://sui-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\": \"sui_tryGetPastObject\",\n  \"params\": [\n    \"0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760\",\n    4,\n    {\n      \"showType\": true,\n      \"showOwner\": true,\n      \"showPreviousTransaction\": true,\n      \"showDisplay\": false,\n      \"showContent\": true,\n      \"showBcs\": false,\n      \"showStorageRebate\": true\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: sui_tryGetPastObject
summary: Get object information for a specific past version
description: |
  Returns object details for a specified version. Note that nodes may prune older versions depending on their configuration, and retrieval is not guaranteed.
params:
  - name: object_id
    required: true
    description: The ID of the queried object.
    schema:
      type: string
  - name: version
    required: true
    description: The specific version to query. No default is applied.
    schema:
      type: integer
  - name: options
    required: false
    description: Options to specify which fields are returned in the object.
    schema:
      type: object
      properties:
        showType:
          type: boolean
        showOwner:
          type: boolean
        showPreviousTransaction:
          type: boolean
        showDisplay:
          type: boolean
        showContent:
          type: boolean
        showBcs:
          type: boolean
        showStorageRebate:
          type: boolean
result:
  name: result
  description: The response describing the object version if found.
  schema:
    type: object
    properties:
      status:
        type: string
        description: Status of the lookup, e.g. "VersionFound", "ObjectNotExists".
      details:
        description: Either object details or the object ID if not found.
        oneOf:
          - type: string
          - type: object
            properties:
              objectId:
                type: string
              version:
                type: string
              digest:
                type: string
              type:
                type: string
              owner:
                type: object
                properties:
                  AddressOwner:
                    type: string
              previousTransaction:
                type: string
              storageRebate:
                type: string
              content:
                type: object
                properties:
                  dataType:
                    type: string
                  type:
                    type: string
                  hasPublicTransfer:
                    type: boolean
                  fields:
                    type: object
                    properties:
                      balance:
                        type: string
                      id:
                        type: object
                        properties:
                          id:
                            type: string
examples:
  - name: Try get past object version
    params:
      - name: object_id
        value: '0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760'
      - name: version
        value: 4
      - name: options
        value:
          showType: true
          showOwner: true
          showPreviousTransaction: true
          showDisplay: false
          showContent: true
          showBcs: false
          showStorageRebate: true
    result:
      name: result
      value:
        status: VersionFound
        details:
          objectId: '0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760'
          version: '4'
          digest: 5VPAwDXy3BL72ehFc7gSJoz27ahMd6spUg5YwYc4ibcv
          type: 0x2::coin::Coin<0x2::sui::SUI>
          owner:
            AddressOwner: '0x3568c40e814d9d5396d23087a0fd641e91e0e00df6c012cded9ef9ba5e5bf042'
          previousTransaction: 5jQByoouHBwaico5pQB73GdbzerC2StjTiHh5garBjiV
          storageRebate: '100'
          content:
            dataType: moveObject
            type: 0x2::coin::Coin<0x2::sui::SUI>
            hasPublicTransfer: true
            fields:
              balance: '10000'
              id:
                id: '0x11af4b844ff94b3fbef6e36b518da3ad4c5856fa686464524a876b463d129760'
```
