A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/en-US/docs/Web/API/User-Agent_Client_Hints_API below:

User-Agent Client Hints API - Web APIs

User-Agent Client Hints API

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The User-Agent Client Hints API extends Client Hints to provide a way of exposing browser and platform information via User-Agent response and request headers, and a JavaScript API.

Concepts and Usage

Parsing the User-Agent string has historically been the way to get information about the user's browser or device. A typical user agent string looks like the following example, identifying Chrome 92 on Windows:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36

User agent Client Hints aims to provide this information in a more privacy-preserving way by enforcing a model where the server requests a set of information. The browser decides what to return. This approach means that a user-agent could provide settings that allow a user to hide some of the information that could fingerprint them from such requests.

In order to decide what to return, the information accessed via this API is split into two groups—low entropy and high entropy hints. Low entropy hints are those that do not give away much information, the API makes these easily accessible with every request. High entropy hints have the potential to give away more information and therefore are gated in such a way that the browser can make a decision as to whether to provide them. This decision could potentially be based on user preferences, or behind a permission request.

Use cases for User-Agent Client Hints

Potential use cases include:

Interfaces
NavigatorUAData

Provides properties and methods to access data about the user's browser and operating system.

Extensions to other interfaces
Navigator.userAgentData Read only

Returns a NavigatorUAData object, which gives access to information about the browser and operating system of the user.

WorkerNavigator.userAgentData Read only

Returns a NavigatorUAData object, which gives access to information about the browser and operating system of the user.

Examples Getting the brands

The following example prints the value of NavigatorUAData.brands to the console.

console.log(navigator.userAgentData.brands);
Returning high entropy values

In the following example a number of hints are requested using the NavigatorUAData.getHighEntropyValues() method. When the promise resolves, this information is printed to the console.

navigator.userAgentData
  .getHighEntropyValues([
    "architecture",
    "model",
    "platform",
    "platformVersion",
    "fullVersionList",
  ])
  .then((ua) => {
    console.log(ua);
  });
Specifications Browser compatibility api.NavigatorUAData api.Navigator.userAgentData api.WorkerNavigator.userAgentData See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4