# Data Feeds API Reference Source: https://docs.chain.link/data-feeds/api-reference When you use data feeds, retrieve the feeds through the `AggregatorV3Interface` and the proxy address. Optionally, you can call variables and functions in the `AccessControlledOffchainAggregator` contract to get information about the aggregator behind the proxy. ## AggregatorV3Interface Import this interface to your contract and use it to run functions in the proxy contract. Create the interface object by pointing to the proxy address. For example, on Sepolia you could create the interface object in the constructor of your contract using the following example: ```solidity /** * Network: Sepolia * Data Feed: ETH/USD * Address: 0x694AA1769357215DE4FAC081bf1f309aDC325306 */ constructor() { priceFeed = AggregatorV3Interface(0x694AA1769357215DE4FAC081bf1f309aDC325306); } ``` To see examples for how to use this interface, read the [Using Data Feeds](/data-feeds/price-feeds) guide. You can see the code for the [`AggregatorV3Interface` contract](https://github.com/smartcontractkit/chainlink/blob/contracts-v1.3.0/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol) on GitHub. ### Functions in AggregatorV3Interface | Name | Description | | ----------------------------------- | -------------------------------------------------------------------- | | [decimals](#decimals) | The number of decimals in the response. | | [description](#description) | The description of the aggregator that the proxy points to. | | [getRoundData](#getrounddata) | Get data from a specific round. | | [latestRoundData](#latestrounddata) | Get data from the latest round. | | [version](#version) | The version representing the type of aggregator the proxy points to. | #### decimals Get the number of decimals present in the response value. ```solidity function decimals() external view returns (uint8); ``` - `RETURN`: The number of decimals. #### description Get the description of the underlying aggregator that the proxy points to. ```solidity function description() external view returns (string memory); ``` - `RETURN`: The description of the underlying aggregator. #### getRoundData Get data about a specific round, using the `roundId`. ```solidity function getRoundData( uint80 _roundId ) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); ``` **Parameters:** - `_roundId`: The round ID **Return values:** - `roundId`: The round ID - `answer`: The answer for this round - `startedAt`: Timestamp of when the round started - `updatedAt`: Timestamp of when the round was updated - `answeredInRound`: Deprecated - Previously used when answers could take multiple rounds to be computed #### latestRoundData Get the data from the latest round. ```solidity function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) ``` **Return values:** - `roundId`: The round ID. - `answer`: The data that this specific feed provides. Depending on the feed you selected, this answer provides asset prices, reserves, and other types of data. - `startedAt`: Timestamp of when the round started. - `updatedAt`: Timestamp of when the round was updated. - `answeredInRound`: Deprecated - Previously used when answers could take multiple rounds to be computed #### version The version representing the type of aggregator the proxy points to. ```solidity function version() external view returns (uint256) ``` - `RETURN`: The version number. ## AccessControlledOffchainAggregator This is the contract for the aggregator. You can call functions on the aggregator directly, but it is a best practice to use the [AggregatorV3Interface](#aggregatorv3interface) to run functions on the proxy instead so that changes to the aggregator do not affect your application. Read the aggregator contract only if you need functions that are not available in the proxy. The aggregator contract has several variables and functions that might be useful for your application. Although aggregator contracts are similar for each data feed, some aggregators have different variables. Use the `typeAndVersion()` function on the aggregator to identify what type of aggregator it is and what version it is running. Always check the contract source code and configuration to understand how specific data feeds operate. For example, the [aggregator contract for BTC/USD on Arbitrum](https://arbiscan.io/address/0x942d00008D658dbB40745BBEc89A93c253f9B882#code) is different from the aggregators on other networks. For examples of the contracts that are typically used in aggregator deployments, see the [libocr repository](https://github.com/smartcontractkit/libocr/blob/master/contract/) on GitHub. ### Variables and functions in AccessControlledOffchainAggregator This contract imports `OffchainAggregator` and `SimpleReadAccessController`, which also include their own imports. The variables and functions lists include the publicly accessible items from these imported contracts. A simple way to read the variables or functions is to get the ABI from a blockchain explorer and point the ABI to the aggregator address. To do this in Remix, follow the [Using the ABI with AtAddress](https://remix-ide.readthedocs.io/en/latest/run.html#using-the-abi-with-ataddress) guide in the Remix documentation. As an example, you can find the ABI for the BTC/USD aggregator by viewing the [contract code in Etherscan](https://etherscan.io/address/0xAe74faA92cB67A95ebCAB07358bC222e33A34dA7#code). **Variables:** | Name | Description | | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | LINK | The address for the LINK token contract on a specific network. | | billingAccessController | The address for the billingAccessController, which limits access to the [billing configuration](https://github.com/smartcontractkit/libocr/blob/master/contract/OffchainAggregatorBilling.sol) for the aggregator. | | checkEnabled | A boolean that indicates if access is limited to addresses on the internal access list. | | maxAnswer | This value is no longer used on most Data Feeds. Evaluate if your use case for Data Feeds requires a custom circuit breaker and implement it to meet the needs of your application. See the [Risk Mitigation](/data-feeds/selecting-data-feeds#risk-mitigation) page for more information. | | minAnswer | This value is no longer used on most Data Feeds. Evaluate if your use case for Data Feeds requires a custom circuit breaker and implement it to meet the needs of your application. See the [Risk Mitigation](/data-feeds/selecting-data-feeds#risk-mitigation) page for more information. | | owner | The address that owns this aggregator contract. This controls which address can execute specific functions. | **Functions:** | Name | Description | | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [decimals](#decimals-1) | Return the number of digits of precision for the stored answer. Answers are stored in fixed-point format. | | [description](#description-1) | Return a description for this data feed. This is different depending on which feed you select. | | [getAnswer](#getanswer) | Deprecated - Do not use this function. | | [getBilling](#getbilling) | Retrieve the current billing configuration. | | [getRoundData](#getrounddata-1) | Get the full information for a specific aggregator round including the answer and update timestamps. Use this to get the full historical data for a round. | | [getTimestamp](#gettimestamp) | Deprecated - Do not use this function. | | [hasAccess](#hasaccess) | Check if an address has internal access. | | [latestAnswer](#latestanswer) | Deprecated - Do not use this function. | | [latestConfigDetails](#latestconfigdetails) | Return information about the current offchain reporting protocol configuration. | | [latestRound](#latestround) | Deprecated - Do not use this function. | | [latestRoundData](#latestrounddata-1) | Get the full information for the most recent round including the answer and update timestamps. | | [latestTimestamp](#latesttimestamp) | Deprecated - Do not use this function. | | [latestTransmissionDetails](#latesttransmissiondetails) | Get information about the most recent answer. | | [linkAvailableForPayment](#linkavailableforpayment) | Get the amount of LINK on this contract that is available to make payments to oracles. This value can be negative if there are outstanding payment obligations. | | [oracleObservationCount](#oracleobservationcount) | Returns the number of observations that oracle is due to be reimbursed for. | | [owedPayment](#owedpayment) | Returns how much LINK an oracle is owed for its observations. | | [requesterAccessController](#requesteraccesscontroller) | Returns the address for the access controller contract. | | [transmitters](#transmitters) | The oracle addresses that can report answers to this aggregator. | | [typeAndVersion](#typeandversion) | Returns the aggregator type and version. Many aggregators are `AccessControlledOffchainAggregator 3.0.0`, but there are other variants in production. The version is for the type of aggregator, and different from the contract `version`. | | [validatorConfig](#validatorconfig) | Returns the address and the gas limit for the validator contract. | | [version](#version-1) | Returns the contract version. This is different from the `typeAndVersion` for the aggregator. | #### decimals Return the number of digits of precision for the stored answer. Answers are stored in fixed-point format. ```solidity function decimals() external view returns (uint8 decimalPlaces); ``` #### description Return a description for this data feed. Usually this is an asset pair for a price feed. ```solidity function description() public view override checkAccess returns (string memory) { return super.description(); } ``` #### getAnswer