{"id":15616379,"url":"https://github.com/silviucpp/erluap","last_synced_at":"2025-09-06T14:35:32.603Z","repository":{"id":41280930,"uuid":"104208827","full_name":"silviucpp/erluap","owner":"silviucpp","description":"Erlang implementation of ua-parser (user agent parser)","archived":false,"fork":false,"pushed_at":"2025-03-01T21:04:32.000Z","size":45,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-05T10:49:31.592Z","etag":null,"topics":["erlang","parser","user-agent"],"latest_commit_sha":null,"homepage":"","language":"Erlang","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/silviucpp.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-09-20T11:48:47.000Z","updated_at":"2025-03-01T21:04:19.000Z","dependencies_parsed_at":"2025-04-28T13:08:26.397Z","dependency_job_id":"7d915b77-5a3d-4bd0-8ca3-6aa72d109151","html_url":"https://github.com/silviucpp/erluap","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/silviucpp/erluap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Ferluap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Ferluap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Ferluap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Ferluap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silviucpp","download_url":"https://codeload.github.com/silviucpp/erluap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Ferluap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262834799,"owners_count":23371851,"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":["erlang","parser","user-agent"],"created_at":"2024-10-03T07:07:31.938Z","updated_at":"2025-06-30T19:08:16.507Z","avatar_url":"https://github.com/silviucpp.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://app.travis-ci.com/silviucpp/erluap.svg?branch=master)](https://travis-ci.com/github/silviucpp/erluap)\n[![GitHub](https://img.shields.io/github/license/silviucpp/erluap)](https://github.com/silviucpp/erluap/blob/master/LICENSE)\n[![Hex.pm](https://img.shields.io/hexpm/v/erluap)](https://hex.pm/packages/erluap)\n\n# erluap - Erlang User-Agent Parser\n\nThis is the Erlang implementation of [ua-parser][1]. It provides a NIF wrapper around [uap-cpp][2] for efficient user-agent parsing.\n\n## Getting Started\n\n### Dependencies\n\nEnsure the following dependencies are installed before compiling:\n\n- `re2`\n- `yaml-cpp` (0.5 API)\n\n##### MacOS Installation\n\nYou can install the required dependencies using Homebrew:\n\n```bash\nbrew install re2 yaml-cpp\n```\n\n##### Ubuntu Installation\n\nOn Ubuntu, install the dependencies using APT:\n\n```bash\nsudo apt-get install libyaml-cpp-dev libre2-dev\n```\n\n### Integration\n\nTo add it as a dependency in your project, include the following in your `rebar.config`:\n\n```erlang\n{deps, [\n  {erluap, \".*\", {git, \"https://github.com/silviucpp/erluap.git\", \"master\"}}\n]}.\n```\n\n### Updating User-Agent Regexes\n\nThe user-agent regex definitions are sourced from [uap-core][3]. To update them, modify `UAP_CORE_REV` inside `build_deps.sh` and rebuild.\n\n---\n\n## API\n\n### Parsing as records\n\nerluap returns parsed data as records. The structures are defined in `erluap.hrl`:\n\n```erlang\n-record(device, {\n    device_type   :: device_type(),\n    family :: value(),\n    model :: value(),\n    brand :: value()\n}).\n\n-record(agent, {\n    family :: value(),\n    version_major :: value(),\n    version_minor :: value(),\n    version_patch :: value(),\n    version_patch_minor :: value()\n}).\n```\n\nThe `parse/1` function returns a tuple `{Device::#device{}, Os::#agent{}, Browser::#agent{}}`:\n\n```erlang\nerluap:parse(\u003c\u003c\"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148\"\u003e\u003e).\n\n{{device,mobile,\u003c\u003c\"iPhone\"\u003e\u003e,\u003c\u003c\"iPhone\"\u003e\u003e,\u003c\u003c\"Apple\"\u003e\u003e},\n {agent,\u003c\u003c\"iOS\"\u003e\u003e,\u003c\u003c\"12\"\u003e\u003e,\u003c\u003c\"2\"\u003e\u003e,null,null},\n {agent,\u003c\u003c\"Mobile Safari UI/WKWebView\"\u003e\u003e,null,null,null,null}}\n```\n\n### Parsing as proplist\n\nerluap can also return parsed data as a proplist using `erluap:parse_as_proplist/1`:\n\n```erlang\nerluap:parse_as_proplist(\u003c\u003c\"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148\"\u003e\u003e).\n\n[{device,[{device_type,mobile},\n          {family,\u003c\u003c\"iPhone\"\u003e\u003e},\n          {model,\u003c\u003c\"iPhone\"\u003e\u003e},\n          {brand,\u003c\u003c\"Apple\"\u003e\u003e}]},\n {os,[{family,\u003c\u003c\"iOS\"\u003e\u003e},\n      {version_major,\u003c\u003c\"12\"\u003e\u003e},\n      {version_minor,\u003c\u003c\"2\"\u003e\u003e},\n      {version_patch,null},\n      {version_patch_minor,null}]},\n {browser,[{family,\u003c\u003c\"Mobile Safari UI/WKWebView\"\u003e\u003e},\n           {version_major,null},\n           {version_minor,null},\n           {version_patch,null},\n           {version_patch_minor,null}]}]\n```\n\n### Detecting Crawlers (Spiders)\n\nTo check if a user-agent is a web crawler (spider), verify if the device family is `\u003c\u003c\"Spider\"\u003e\u003e` or use the helper function:\n\n```erlang\nerluap:is_spider(UserAgent).\n```\n\n---\n\n## Running Tests\n\nTo execute the test suite run:\n\n```bash\nmake ct\n```\n\n---\n\n[1]: https://github.com/ua-parser\n[2]: https://github.com/ua-parser/uap-cpp\n[3]: https://github.com/ua-parser/uap-core\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilviucpp%2Ferluap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilviucpp%2Ferluap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilviucpp%2Ferluap/lists"}