User agent parser library
  • Elixir 99.2%
  • PHP 0.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-13 11:44:09 +02:00
.github Bump GitHub OTP 28.x release 2026-04-30 13:32:45 +02:00
bench Update benchmark agent list 2025-08-04 16:21:26 +02:00
config Separate database/repository fixtures 2022-02-17 19:30:02 +01:00
lib Import upstream Blink engine version detection improvements 2026-08-13 11:44:09 +02:00
priv s/piwik/matomo-org/g 2018-02-16 09:52:27 +01:00
test Import upstream Blink engine version detection improvements 2026-08-13 11:44:09 +02:00
verify Update verification patches 2026-08-13 11:44:09 +02:00
.credo.exs extends credo coverage 2019-02-09 13:11:08 +01:00
.formatter.exs extends credo coverage 2019-02-09 13:11:08 +01:00
.gitignore Remove unnecessary .gitignore entry 2024-10-14 13:49:22 +02:00
CHANGELOG.md Import upstream client hint based version detection improvements 2026-08-13 11:44:08 +02:00
LICENSE adds license 2013-12-23 12:31:40 +01:00
mix.exs Replace hackney download adapter with :httpc 2026-07-26 18:24:57 +02:00
mix.lock Update dependencies 2026-08-13 11:41:42 +02:00
README.md Fix badge (#38) 2025-06-17 18:22:27 +02:00

UAInspector

CI Module Version Hex Docs Total Downloads License Last Updated

User agent parser library.

Package Setup

To use UAInspector with your projects, edit your mix.exs file and add the required dependencies:

defp deps do
  [
    # ...
    {:ua_inspector, "~> 3.0"},
    # ...
  ]
end

If you want to use a manual supervision approach (without starting the application) please look at the inline documentation of UAInspector.Supervisor.

Application Configuration

Out of the box the default database files will be stored in the :priv_dir of :ua_inspector. Both the database sources and path used can be changed.

For a detailed list of available configuration options please consult UAInspector.Config.

Basic Usage

Database Download

You need to obtain a copy of the configured databases by calling either mix ua_inspector.download from the command line or UAInspector.Downloader.download/0 from within your application.

Refer to UAInspector.Downloader for more details.

User Agent Parsing

iex> UAInspector.parse("Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53")
%UAInspector.Result{
  client: %UAInspector.Result.Client{
    engine: "WebKit",
    engine_version: "537.51.1",
    name: "Mobile Safari",
    type: "browser",
    version: "7.0"
  },
  device: %UAInspector.Result.Device{
    brand: "Apple",
    model: "iPad",
    type: "tablet"
  },
  os: %UAInspector.Result.OS{
    name: "iOS",
    platform: :unknown,
    version: "7.0.4"
  },
  user_agent: "Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53"
}

iex> UAInspector.parse("Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36")
%UAInspector.Result.Bot{
  category: "Search bot",
  name: "Googlebot",
  producer: %UAInspector.Result.BotProducer{
    name: "Google Inc.",
    url: "http://www.google.com"
  },
  url: "http://www.google.com/bot.html",
  user_agent: "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36"
}

Full documentation is available inline in the UAInspector module and at https://hexdocs.pm/ua_inspector.

Benchmark

Several (minimal) benchmark scripts are included. Please refer to the Mixfile or mix help output for their names.

Resources

Copyright (c) 2013 Marc Neudert

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

The parser databases are taken from the matomo-org/device-detector project. See there for detailed license information about the data contained.