GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

RTCRtpReceiver: getStats() method

WebRTC

WebRTC

The RTCRtpReceiver method **`getStats()`** asynchronously requests an RTCStatsReport object which provides statistics about incoming traffic on the owning RTCPeerConnection, returning a Promise whose fulfillment handler will be called once the results are available.

## Syntax

```js-nolint
getStats()
```

### Parameters

None.

### Return value

A JavaScript Promise which is fulfilled once the statistics are available.
The promise's fulfillment handler receives as a parameter a RTCStatsReport object containing the collected statistics.

The returned statistics include those from all streams which are coming in through the `RTCRtpReceiver`, as well as any of their dependencies.

These might include, for example, statistics with [types](/docs/Web/API/RTCStatsReport#the_statistic_types): [`inbound-rtp`](/docs/Web/API/RTCInboundRtpStreamStats), [`candidate-pair`](/docs/Web/API/RTCIceCandidatePairStats), [`local-candidate`](/docs/Web/API/RTCIceCandidateStats), [`remote-candidate`](/docs/Web/API/RTCIceCandidateStats).

## Examples

This simple example obtains the statistics for an `RTCRtpReceiver` and updates an element's innerText to display the number of packets lost.

```js
receiver.getStats().then((stats) => {
document.getElementById("lost-packets").innerText = stats.packetsLost;
});
```

## Specifications

## Browser compatibility

## See also

- [WebRTC API](/docs/Web/API/WebRTC_API)
- RTCStatsReport
- RTCRtpSender.getStats()
- RTCPeerConnection.getStats()

source: MDN Web Docs mirror · page

Cite this

"RTCRtpReceiver: getStats() method". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpReceiver/getStats

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·