files/en-us/web/api/rtcicecandidatestats/index.md
{{APIRef("WebRTC")}}
The RTCIceCandidateStats dictionary of the WebRTC API is used to report statistics related to an {{domxref("RTCIceCandidate")}}.
The statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCPeerConnection.getStats()")}} until you find a report with the type of local-candidate.
ip and only accepted IP addresses.
Corresponds to {{domxref("RTCIceCandidate.address")}}.RTCIceCandidate.type, indicating what kind of candidate the object provides statistics for.tcp or udp) used to transmit data on the port.
Corresponds to {{domxref("RTCIceCandidate.protocol")}}.The following properties are common to all WebRTC statistics objects.
<!-- RTCStats -->"local-candidate", indicating the type of statistics that the object contains.Given a variable myPeerConnection, which is an instance of {{domxref("RTCPeerConnection")}}, the code below uses await to wait for the statistics report, and then iterates it using RTCStatsReport.forEach().
It then filters the dictionaries for just those reports that have the type of local-candidate and logs the result.
const stats = await myPeerConnection.getStats();
stats.forEach((report) => {
if (report.type === "local-candidate") {
// Log the ICE candidate information
console.log(report);
}
});
{{Specifications}}
{{Compat}}