---
title: "Get contract data variable"
method: GET
path: "/v2/data_var/{principal}/{contract_name}/{var_name}"
tags: ["Smart Contracts"]
---

# Get contract data variable

`GET /v2/data_var/{principal}/{contract_name}/{var_name}`

## Request

- Base URL: `http://localhost:20443`
- URL: `http://localhost:20443/v2/data_var/{principal}/{contract_name}/{var_name}`
- Auth: none required

Fetch a data variable from a smart contract.
Returns the raw hex-encoded value of the variable.

## Path parameters

- `var_name` ClarityName, required (unresolved $ref)

## Parameters

- `./components/parameters/standard-principal.yaml` (unresolved $ref)
- `./components/parameters/contract-name.yaml` (unresolved $ref)
- `./components/parameters/proof.yaml` (unresolved $ref)
- `./components/parameters/tip.yaml` (unresolved $ref)

## Response `200`

The data variable value

- ClarityData (unresolved $ref)

## Other responses

- `400`: Bad request
- `404`: Not found

## Changes

> 55 revisions in range; 3 not diffed.

- **2026-01-28** `30468ca2533f`: 1 info
  - for the `path` request parameter `var_name`, the type was generalized from `string` to no type
- **2026-01-14** `f7f733b4a1fc`: 1 info
  - for the `path` request parameter `var_name`, the type was generalized from no type to `string`
- **2026-01-14** `eb2153a4a3ad`: 1 info
  - for the `path` request parameter `var_name`, the type was generalized from `string` to no type
- **2025-12-18** `97e7080a8130`: 1 info
  - for the `path` request parameter `var_name`, the type was generalized from `string` to no type
- **2025-12-17** `db8094c96a6e`: 1 info
  - for the `path` request parameter `var_name`, the type was generalized from no type to `string`

[Operation history](https://skmtc.dev/stacks-network/apis/stacks-3-0-rpc-api/changes/v2/data_var/:principal/:contract_name/:var_name/get.md)

---

[API](https://skmtc.dev/stacks-network/apis/stacks-3-0-rpc-api.md) - [All operations](https://skmtc.dev/stacks-network/apis/stacks-3-0-rpc-api/llms.txt) - [OpenAPI document](https://skmtc.dev/stacks-network/apis/stacks-3-0-rpc-api/revisions/ec15793050b9?raw)
