51黑料不打烊

Header - X-Device-Info header-x-device-info

NOTE
The content on this page is provided for information purposes only. Usage of this API requires a current license from 51黑料不打烊. No unauthorized use is permitted.

Overview overview

The X-Device-Info request header contains the client information (device, connection and application) related to the actual streaming device.

Syntax syntax

X-Device-Info: <device_information>
Header Type
Request header
Standard
No

Directives directives

<device_information>

The Base64-encoded value of the JSON element containing at least the attributes marked as required by the following table.

Presence
Key
Description
Restricted
Possible Values
primaryHardwareType
The device鈥檚 primary hardware type.

The values are restricted:

  • Camera
  • DataCollectionTerminal
  • Desktop
  • EmbeddedNetworkModule
  • eReader
  • GamesConsole
  • GeolocationTracker
  • Glasses
  • MediaPlayer
  • MobilePhone
  • PaymentTerminal
  • PluginModem
  • SetTopBox
  • TV
  • Tablet
  • WirelessHotspot
  • Wristwatch
  • Unknown
required
model
The device鈥檚 model name.
e.g. iPhone, SM-G930V, AppleTV, etc.
required
version
The device鈥檚 version.
e.g. 2.0.1, etc.
manufacturer
The device鈥檚 manufacturing company/organization.
e.g. Samsung, LG, ZTE, Huawei, Motorola, Apple, etc.
vendor
The device鈥檚 selling company/organisation.
e.g. Apple, Samsung, LG, Google, etc.
required
osName
The device鈥檚 Operating System (OS) name.

The values are restricted:

  • Android
  • Chrome OS
  • Linux
  • Mac OS
  • OS X
  • OpenBSD
  • Roku OS
  • Windows
  • iOS
  • tvOS
  • webOS
osFamily
The device鈥檚 Operating System (OS) group name.

The values are restricted:

  • Android
  • BSD
  • Linux
  • PlayStation OS
  • Roku OS
  • Symbian
  • Tizen
  • Windows
  • iOS
  • tvOS
  • macOS
  • webOS
osVendor
The device鈥檚 Operating System (OS) supplier.

The values are restricted:

  • Amazon
  • Apple
  • Google
  • LG
  • Microsoft
  • Mozilla
  • Nintendo
  • Nokia
  • Roku
  • Samsung
  • Sony
  • Tizen Project
required
osVersion
The device鈥檚 Operating System (OS) version.
e.g. 10.2, 9.0.1, etc.
browserName
The browser鈥檚 name.

The values are restricted:

  • Android Browser
  • Chrome
  • Edge
  • Firefox
  • Internet Explorer
  • Opera
  • Safari
  • SeaMonkey
  • Symbian Browser
browserVendor
The browser鈥檚 building company/organisation.

The values are restricted:

  • Amazon
  • Apple
  • Google
  • Microsoft
  • Motorola
  • Mozilla
  • Netscape
  • Nintendo
  • Nokia
  • Samsung
  • Sony Ericsson
browserVersion
The device鈥檚 browser version.
e.g. 60.0.3112
userAgent
The device鈥檚 user agent.
e.g. Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8
displayWidth
The device鈥檚 physical screen width.
displayHeight
The device鈥檚 physical screen height.
displayPpi
The device鈥檚 physical screen pixel density.
e.g. 294
diagonalScreenSize
The device鈥檚 physical screen diagonal dimension in inches.
e.g. 5.5, 10.1
connectionIp
The device鈥檚 IP used for sending HTTP requests.
e.g. 8.8.4.4
connectionPort
The device鈥檚 port used for sending HTTP requests.
e.g. 53124
required
connectionType
The network connection type.
e.g. WiFi, LAN, 3G, 4G, 5G
connectionSecure
The network connection security status.

The values are restricted:

  • true - in the case of a secure network
  • false - in the case of a public hot spot
applicationId
The application鈥檚 unique identifier.
e.g. REF30

Examples examples


// Device information
// {
//  "primaryHardwareType" : "MobilePhone",
//  "model":"SM-S901U",
//  "vendor":"samsung",
//  "version":"r0q",
//  "manufacturer":"samsung",
//  "osName":"Android",
//  "osVersion":"14"
// }

// BASE64-encoded
// ewogICJwcmltYXJ5SGFyZHdhcmVUeXBlIiA6ICJNb2JpbGVQaG9uZSIsCiAgIm1vZGVsIjoiU00tUzkwMVUiLAogICJ2ZW5kb3I
// iOiJzYW1zdW5nIiwKICAidmVyc2lvbiI6InIwcSIsCiAgIm1hbnVmYWN0dXJlciI6InNhbXN1bmciLAogICJvc05hbWUiOiJBbmRyb
// 2lkIiwKICAib3NWZXJzaW9uIjoiMTQiCn0=

X-Device-Info: ewogICJwcmltYXJ5SGFyZHdhcmVUeXBlIiA6ICJNb2JpbGVQaG9uZSIsCiAgIm1vZGVsIjoiU00tUzkwMVUiLAogICJ2ZW5kb3IiOiJzYW1zdW5nIiwKICAidmVyc2lvbiI6InIwcSIsCiAgIm1hbnVmYWN0dXJlciI6InNhbXN1bmciLAogICJvc05hbWUiOiJBbmRyb2lkIiwKICAib3NWZXJzaW9uIjoiMTQiCn0=

Cookbooks cookbooks

IMPORTANT
The code snippets and documentation resources are provided for referencing purposes.
The code snippets are not exhaustive and may require additional modifications to work in your project.
Regardless of your actual implementation, the X-Device-Info header must contain a value formatted as described in the Directives section.

Browsers browsers

For client applications running in a browser, the X-Device-Info header can be omitted as the browser will automatically send a minimal set of required information in the User-Agent header.

You can still use the X-Device-Info header to provide additional information about the device, connection, and application, in case your client application integrates a library or service that provides a device identification mechanism.

Mobile Devices mobile-devices

iOS & iPadOS ios-ipados

To build the X-Device-Info header for devices running , you may refer to the following documents and below code snippet:

  • Apple developer documentation for .
  • Apple developer documentation for .
  • Linux manual documentation for .
+ (NSString *)computeClientInformation {
        struct utsname u;
        uname(&u);

        NSString *hardware = [NSString stringWithCString:u.machine encoding:NSUTF8StringEncoding];

        UIDevice *device = [UIDevice currentDevice];

        NSString *deviceType;

        switch (UI_USER_INTERFACE_IDIOM()) {
            case UIUserInterfaceIdiomPhone:
                deviceType = @"MobilePhone";
                break;
            case UIUserInterfaceIdiomPad:
                deviceType = @"Tablet";
                break;
            case UIUserInterfaceIdiomTV:
                deviceType = @"TV";
                break;
            default:
                deviceType = @"Unknown";
        }

        CGRect screenRect = [[UIScreen mainScreen] bounds];
        NSNumber *screenWidth = @((float) screenRect.size.width);
        NSNumber *screenHeight = @((float) screenRect.size.height);

        Reachability *reachability = [Reachability reachabilityForInternetConnection];
        [reachability startNotifier];

        NetworkStatus status = [reachability currentReachabilityStatus];

        NSString *connectionType;

        if (status == NotReachable) {
            connectionType = @"notConnected";
        } else if (status == ReachableViaWiFi) {
            connectionType = @"WiFi";
        } else if (status == ReachableViaWWAN) {
            connectionType = @"cellular";
        }

        NSMutableDictionary *clientInformation = [@{
                @"type": deviceType,
                @"model": device.model,
                @"vendor": @"Apple",
                @"manufacturer": @"Apple",
                @"version": [hardware stringByReplacingOccurrencesOfString:device.model withString:@""],
                @"osName": device.systemName,
                @"osVersion": device.systemVersion,
                @"displayWidth": screenWidth,
                @"displayHeight": screenHeight,
                @"connectionType": connectionType,
                @"applicationId": @"REF30"
        } mutableCopy];

        NSError *error;
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:clientInformation options:NSJSONWritingPrettyPrinted error:&error];
        NSString *base64Encoded = [jsonData base64EncodedStringWithOptions:0];

        return base64Encoded;
}

The device information can be constructed the following way:

Key
Source
Value (example)
model
uname.machine
iPhone
vendor
hardcoded
Apple
manufacturer
hardcoded
Apple
version
uname.machine
8,1
displayWidth
UIScreen.mainScreen
320
displayHeight
UIScreen.mainScreen
568
osName
UIDevice.systemName
iOS
osVersion
UIDevice.systemVersion
10.2

The connection information can be constructed the following way:

Key
Source
Value (example)
connectionType
[Reachability currentReachabilityStatus]
connectionSecure

The application information can be constructed the following way:

Key
Source
Value (example)
applicationId
hardcoded
REF30

Android android

To build the X-Device-Info header for devices running , you may refer to the following documents and below code snippet:

  • Android developer documentation for class.
private JSONObject computeClientInformation() {
     String LOGGING_TAG = "DefineClass.class";

     JSONObject clientInformation = new JSONObject();

     String connectionType;

     try {
          ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(CONNECTIVITY_SERVICE);
          NetworkInfo activeNetwork = cm.getActiveNetworkInfo();

          if (activeNetwork != null && activeNetwork.isConnectedOrConnecting()) {
              switch (activeNetwork.getType()) {
                    case ConnectivityManager.TYPE_WIFI: {
                        connectionType = "WIFI";
                        break;
                    }
                    case ConnectivityManager.TYPE_BLUETOOTH: {
                        connectionType = "BLUETOOTH";
                        break;
                    }
                    case ConnectivityManager.TYPE_MOBILE: {
                        connectionType = "MOBILE";
                        break;
                    }
                    case ConnectivityManager.TYPE_ETHERNET: {
                        connectionType = "ETHERNET";
                        break;
                    }
                    case ConnectivityManager.TYPE_VPN: {
                        connectionType = "VPN";
                        break;
                    }
                    case ConnectivityManager.TYPE_DUMMY: {
                        connectionType = "DUMMY";
                        break;
                    }
                    case ConnectivityManager.TYPE_MOBILE_DUN: {
                        connectionType = "MOBILE_DUN";
                        break;
                    }
                    case ConnectivityManager.TYPE_WIMAX: {
                        connectionType = "WIMAX";
                        break;
                    }
                    default:
                       connectionType = ConnectivityManager.EXTRA_OTHER_NETWORK_INFO;
              }
          } else {
                connectionType = ConnectivityManager.EXTRA_NO_CONNECTIVITY;
          }
     } catch (Exception e) {
          connectionType = "notAccessible";
     }

     try {
          clientInformation.put("model", Build.MODEL);
          clientInformation.put("vendor", Build.BRAND);
          clientInformation.put("manufacturer", Build.MANUFACTURER);
          clientInformation.put("version", Build.DEVICE);
          clientInformation.put("osName", "Android");
          clientInformation.put("osVersion", Build.VERSION.RELEASE);
          clientInformation.put("connectionType", connectionType);
          clientInformation.put("applicationId", "REF30");
     } catch (JSONException e) {
          Log.e(LOGGING_TAG, e.getMessage());
     }

     return Base64.encodeToString(clientInformation.toString().getBytes(), Base64.NO_WRAP);
}

The device information can be constructed the following way:

Key
Source
Value (example)
model
Build.MODEL
GT-I9505
vendor
Build.BRAND
samsung
manufacturer
Build.MANUFACTURER
samsung
version
Build.DEVICE
jflte
displayWidth
DisplayMetrics.widthPixels
600
displayHeight
DisplayMetrics.heightPixels
800
osName
hardcoded
Android
osVersion
Build.VERSION.RELEASE
5.0.1

The connection information can be constructed the following way:

Key
Source
Value (example)
connectionType
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> getSystemService(Context.CONNECTIVITY_SERVICE).getActiveNetworkInfo().getType()
"WIFI","BLUETOOTH","MOBILE","ETHERNET","VPN","DUMMY","MOBILE_DUN","WIMAX","notAccessible"
connectionSecure

The application information can be constructed the following way:

Key
Source
Value (example)
applicationId
hardcoded
REF30

TV Connected Devices tv-connected-devices

tvOS tvos

To build the X-Device-Info header for devices running , you may refer to the following documents and below code snippet:

  • Apple developer documentation for .
  • Apple developer documentation for .
  • Linux manual documentation for .
+ (NSString *)computeClientInformation {
        struct utsname u;
        uname(&u);

        NSString *hardware = [NSString stringWithCString:u.machine encoding:NSUTF8StringEncoding];

        UIDevice *device = [UIDevice currentDevice];

        NSString *deviceType;

        switch (UI_USER_INTERFACE_IDIOM()) {
            case UIUserInterfaceIdiomPhone:
                deviceType = @"MobilePhone";
                break;
            case UIUserInterfaceIdiomPad:
                deviceType = @"Tablet";
                break;
            case UIUserInterfaceIdiomTV:
                deviceType = @"TV";
                break;
            default:
                deviceType = @"Unknown";
        }

        CGRect screenRect = [[UIScreen mainScreen] bounds];
        NSNumber *screenWidth = @((float) screenRect.size.width);
        NSNumber *screenHeight = @((float) screenRect.size.height);

        Reachability *reachability = [Reachability reachabilityForInternetConnection];
        [reachability startNotifier];

        NetworkStatus status = [reachability currentReachabilityStatus];

        NSString *connectionType;

        if (status == NotReachable) {
            connectionType = @"notConnected";
        } else if (status == ReachableViaWiFi) {
            connectionType = @"WiFi";
        } else if (status == ReachableViaWWAN) {
            connectionType = @"cellular";
        }

        NSMutableDictionary *clientInformation = [@{
                @"type": deviceType,
                @"model": device.model,
                @"vendor": @"Apple",
                @"manufacturer": @"Apple",
                @"version": [hardware stringByReplacingOccurrencesOfString:device.model withString:@""],
                @"osName": device.systemName,
                @"osVersion": device.systemVersion,
                @"displayWidth": screenWidth,
                @"displayHeight": screenHeight,
                @"connectionType": connectionType,
                @"applicationId": @"REF30"
        } mutableCopy];

        NSError *error;
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:clientInformation options:NSJSONWritingPrettyPrinted error:&error];
        NSString *base64Encoded = [jsonData base64EncodedStringWithOptions:0];

        return base64Encoded;
}

The device information can be constructed the following way:

Key
Source
Value (example)
model
uname.machine
AppleTV
vendor
hardcoded
Apple
manufacturer
hardcoded
Apple
version
uname.machine
8,1
displayWidth
UIScreen.mainScreen
1920
displayHeight
UIScreen.mainScreen
1080
osName
UIDevice.systemName
tvOS
osVersion
UIDevice.systemVersion
10.2

The connection information can be constructed the following way:

Key
Source
Value (example)
connectionType
[Reachability currentReachabilityStatus]
connectionSecure

The application information can be constructed the following way:

Key
Source
Value (example)
applicationId
hardcoded
REF30

Fire OS fireos

To build the X-Device-Info header for devices running , you may refer to the following documents:

  • Android developer documentation for class.
  • Amazon developer documentation for .

The device information can be constructed the following way:

Key
Source
Value (example)
model
Build.MODEL
AFTM
vendor
Build.BRAND
Amazon
manufacturer
Build.MANUFACTURER
Amazon
version
Build.DEVICE
montoya
displayWidth
DisplayMetrics.widthPixels
displayHeight
DisplayMetrics.heightPixels
osName
hardcoded
Android
osVersion
Build.VERSION.RELEASE
5.1.1

The connection information can be constructed the following way:

Key
Source
Value (example)
connectionType
connectionSecure

The application information can be constructed the following way:

Key
Source
Value (example)
applicationId
hardcoded
REF30

Roku OS rokuos

To build the X-Device-Info header for devices running , you may refer to the following documents:

  • Roku developer documentation for .

The device information can be constructed the following way:

Key
Source
Value (example)
model
hardcoded
鈥凌辞办耻鈥
vendor
ifDeviceInfo.GetModelDetails().VendorName
鈥淪harp鈥, 鈥凌辞办耻鈥
manufacturer
ifDeviceInfo.GetModelDetails().VendorName
鈥淪harp鈥, 鈥凌辞办耻鈥
version
ifDeviceInfo.GetModelDetails().ModelNumber
鈥5303齿鈥
displayWidth
ifDeviceInfo.GetDisplaySize().w
1920
displayHeight
ifDeviceInfo.GetDisplaySize().h
1080
osName
hardcoded
鈥凌辞办耻鈥
osVersion
ifDeviceInfo.getVersion()

The connection information can be constructed the following way:

Key
Source
Value (example)
connectionType
ifDeviceInfo.GetConnectionType()
鈥淲ifiConnection鈥, 鈥淲iredConnection鈥
connectionSecure
hardcoded
true if connection is wired

The application information can be constructed the following way:

Key
Source
Value (example)
applicationId
hardcoded
REF30
recommendation-more-help
3f5e655c-af63-48cc-9769-2b6803cc5f4b