{"id":20617745,"url":"https://github.com/chermenin/kotlin-user-agents","last_synced_at":"2025-04-15T11:33:24.033Z","repository":{"id":44553417,"uuid":"306006732","full_name":"chermenin/kotlin-user-agents","owner":"chermenin","description":"selwin/python-user-agents port to Kotlin","archived":false,"fork":false,"pushed_at":"2023-09-25T12:32:18.000Z","size":93,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T19:37:46.435Z","etag":null,"topics":["browser-detection","kotlin","kotlin-library","user-agent","user-agent-detection","user-agent-parser"],"latest_commit_sha":null,"homepage":"https://code.chermenin.ru/kotlin-user-agents/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chermenin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-21T11:46:55.000Z","updated_at":"2025-01-17T11:19:00.000Z","dependencies_parsed_at":"2023-01-24T02:45:43.341Z","dependency_job_id":null,"html_url":"https://github.com/chermenin/kotlin-user-agents","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chermenin%2Fkotlin-user-agents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chermenin%2Fkotlin-user-agents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chermenin%2Fkotlin-user-agents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chermenin%2Fkotlin-user-agents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chermenin","download_url":"https://codeload.github.com/chermenin/kotlin-user-agents/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249060990,"owners_count":21206433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser-detection","kotlin","kotlin-library","user-agent","user-agent-detection","user-agent-parser"],"created_at":"2024-11-16T12:05:50.743Z","updated_at":"2025-04-15T11:33:23.994Z","avatar_url":"https://github.com/chermenin.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Kotlin User Agents\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/chermenin/kotlin-user-agents/gradle.yml)](https://github.com/chermenin/kotlin-user-agents/actions/workflows/gradle.yml)\n[![GitHub Packages](https://img.shields.io/github/v/release/chermenin/kotlin-user-agents)](https://github.com/chermenin/kotlin-user-agents/packages/)\n\nIt's a Kotlin port of the [selwin](//github.com/selwin)'s [Python library](//github.com/selwin/python-user-agents) that provides an easy way to identify/detect devices like mobile phones, tablets and their capabilities by parsing user agent strings. The goal is to reliably detect whether:\n\n- User agent is a mobile, tablet or PC based device\n- User agent has touch capabilities (has touch screen)\n\n### Installation\n\nBefore using the library you have to add something similar to the following block to dependencies:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eru.chermenin\u003c/groupId\u003e\n    \u003cartifactId\u003ekotlin-user-agents\u003c/artifactId\u003e\n    \u003cversion\u003ex.y.z\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Usage\n\nHere is an example how to use this library:\n\n```kotlin\n// iPhone's user agent string\nval uaString = \"Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3\"\nval ua = UserAgent.parse(uaString)\n\n// Accessing user agent's browser attributes\nua.browser                      // Browser(family=Mobile Safari, version=Version(major=5, minor=1, patch=null, patchMinor=null))\nua.browser.family               // \"Mobile Safari\"\nua.browser.version              // Version(major=5, minor=1, patch=null, patchMinor=null)\nua.browser.version.toString()   // \"5.1\"\n\n// Accessing user agent's operating system properties\nua.os                      // OS(family=iOS, version=Version(major=5, minor=1, patch=null, patchMinor=null))\nua.os.family               // \"iOS\"\nua.os.version              // Version(major=5, minor=1, patch=null, patchMinor=null)\nua.os.version.toString()   // \"5.1\"\n\n// Getting user agent's device type\nua.device   // \"iPhone\"\n\n// Viewing a pretty string version\nua.toString()   // \"iPhone / iOS 5.1 / Mobile Safari 5.1\"\n\n// And a few other attributes\nua.isMobile()         // true\nua.isTablet()         // false\nua.isTouchCapable()   // true\nua.isPC()             // false\nua.isBot()            // false\n```\n\nThe same if to use the library in Java:\n\n```java\n// iPhone's user agent string\nString uaString = \"Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3\";\nUserAgent ua = UserAgent.Companion.parse(uaString);\n\n// Accessing user agent's browser attributes\nua.getBrowser();                          // Browser(family=Mobile Safari, version=Version(major=5, minor=1, patch=null, patchMinor=null))\nua.getBrowser().getFamily();              // \"Mobile Safari\"\nua.getBrowser().getVersion();             // Version(major=5, minor=1, patch=null, patchMinor=null)\nua.getBrowser().getVersion().toString();  // \"5.1\"\n\n// Accessing user agent's operating system properties\nua.getOs();                          // OS(family=iOS, version=Version(major=5, minor=1, patch=null, patchMinor=null))\nua.getOs().getFamily();              // \"iOS\"\nua.getOs().getVersion();             // Version(major=5, minor=1, patch=null, patchMinor=null)\nua.getOs().getVersion().toString();  // \"5.1\"\n\n// Getting user agent's device type\nua.getDevice();  // \"iPhone\"\n\n// Viewing a pretty string version\nua.toString();  // \"iPhone / iOS 5.1 / Mobile Safari 5.1\"\n\n// And a few other attributes\nua.isMobile();        // true\nua.isTablet();        // false\nua.isTouchCapable();  // true\nua.isPC();            // false\nua.isBot();           // false\n```\n\n#### Caching version\n\nIf you need to parse a lot of user agent strings, and they can be repeated you can use the version with a cache:\n\n```kotlin\nval parser = CachedUserAgentParser(initialEntries = 1000, maxEntries = 3000)\nval ua = parser.parse(uaString)\n...\n```\n\n### Changelog\n\n#### Version 0.2.2 \u003csub\u003e\u003csup\u003e`2022-02-08`\u003c/sup\u003e\u003c/sub\u003e\n- Some fixes for mobile OS and browsers\n\n#### Version 0.2.1 \u003csub\u003e\u003csup\u003e`2021-03-30`\u003c/sup\u003e\u003c/sub\u003e\n- Fixes for BlackBerry devices\n\n#### Version 0.2.0 \u003csub\u003e\u003csup\u003e`2020-10-29`\u003c/sup\u003e\u003c/sub\u003e\n- Added caching version of the parser\n\n#### Version 0.1.0 \u003csub\u003e\u003csup\u003e`2020-10-21`\u003c/sup\u003e\u003c/sub\u003e\n- Initial version (fully corresponds to the `python-user-agents` version 2.2.0)\n\n### License\n\nCopyright © 2020 Alex Chermenin  \nLicensed under the MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchermenin%2Fkotlin-user-agents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchermenin%2Fkotlin-user-agents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchermenin%2Fkotlin-user-agents/lists"}