{"id":13485165,"url":"https://github.com/omrilotan/isbot","last_synced_at":"2025-05-14T04:08:44.980Z","repository":{"id":35374399,"uuid":"39637454","full_name":"omrilotan/isbot","owner":"omrilotan","description":"🤖/👨‍🦰 Detect bots/crawlers/spiders using the user agent string","archived":false,"fork":false,"pushed_at":"2025-04-25T11:08:02.000Z","size":3523,"stargazers_count":1016,"open_issues_count":0,"forks_count":80,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-06T22:38:49.225Z","etag":null,"topics":["crawlers","user-agent","user-agent-analysis","user-agent-parser","web-crawlers"],"latest_commit_sha":null,"homepage":"https://isbot.js.org/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omrilotan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-07-24T14:07:44.000Z","updated_at":"2025-04-29T11:36:36.000Z","dependencies_parsed_at":"2024-10-03T09:52:47.555Z","dependency_job_id":"772763d7-953a-41e8-bf04-b8402dc1255e","html_url":"https://github.com/omrilotan/isbot","commit_stats":{"total_commits":294,"total_committers":44,"mean_commits":6.681818181818182,"dds":0.6496598639455782,"last_synced_commit":"30f08d9ab569ec523adfec99743d441dd668c119"},"previous_names":["gorangajic/isbot"],"tags_count":122,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omrilotan%2Fisbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omrilotan%2Fisbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omrilotan%2Fisbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omrilotan%2Fisbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omrilotan","download_url":"https://codeload.github.com/omrilotan/isbot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745051,"owners_count":21957316,"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":["crawlers","user-agent","user-agent-analysis","user-agent-parser","web-crawlers"],"created_at":"2024-07-31T17:01:48.581Z","updated_at":"2025-05-14T04:08:39.943Z","avatar_url":"https://github.com/omrilotan.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# isbot 🤖/👨‍🦰\n\n[![](https://img.shields.io/npm/v/isbot?style=flat-square)](https://www.npmjs.com/package/isbot) [![](https://img.shields.io/circleci/build/github/omrilotan/isbot?style=flat-square)](https://circleci.com/gh/omrilotan/isbot) [![](https://img.shields.io/github/last-commit/omrilotan/isbot?style=flat-square)](https://github.com/omrilotan/isbot/graphs/commit-activity) [![](https://img.shields.io/npm/dt/isbot?style=flat-square)](https://www.npmjs.com/package/isbot) [![](https://data.jsdelivr.com/v1/package/npm/isbot/badge)](https://www.jsdelivr.com/package/npm/isbot)\n\n[![](./page/isbot.svg)](https://isbot.js.org)\n\nIdentify bots, crawlers, and spiders using the user agent string.\n\n## Usage\n\nInstall\n\n```sh\nnpm i isbot\n```\n\nStraightforward usage\n\n```ts\nimport { isbot } from \"isbot\";\n\n// Request\nisbot(request.headers.get(\"User-Agent\"));\n\n// Nodejs HTTP\nisbot(request.getHeader(\"User-Agent\"));\n\n// ExpressJS\nisbot(req.get(\"user-agent\"));\n\n// Browser\nisbot(navigator.userAgent);\n\n// User Agent string\nisbot(\n  \"Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\",\n); // true\n\nisbot(\n  \"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36\",\n); // false\n```\n\nUse JSDeliver CDN you can import to the browser directly\n\n\u003e See specific versions and instructions [https://www.jsdelivr.com/package/npm/isbot](https://www.jsdelivr.com/package/npm/isbot)\n\nESM\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { isbot } from \"https://cdn.jsdelivr.net/npm/isbot@5/+esm\";\n  isbot(navigator.userAgent);\n\u003c/script\u003e\n```\n\nUMD\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/isbot@5\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  // isbot is now global\n  isbot(navigator.userAgent);\n\u003c/script\u003e\n```\n\n## All named imports\n\n| import              | Type                             | Description                                                                  |\n| ------------------- | -------------------------------- | ---------------------------------------------------------------------------- |\n| isbot               | _(string?): boolean_             | Check if the user agent is a bot                                             |\n| isbotNaive          | _(string?): boolean_             | Check if the user agent is a bot using a naive pattern (less accurate)       |\n| getPattern          | (): _RegExp_                     | The regular expression used to identify bots                                 |\n| list                | _string[]_                       | List of all individual pattern parts                                         |\n| isbotMatch          | _(string?): string \\| null_      | The substring matched by the regular expression                              |\n| isbotMatches        | _(string?): string[]_            | All substrings matched by the regular expression                             |\n| isbotPattern        | _(string?): string \\| null_      | The regular expression used to identify bot substring in the user agent      |\n| isbotPatterns       | _(string?): string[]_            | All regular expressions used to identify bot substrings in the user agent    |\n| createIsbot         | _(RegExp): (string?): boolean_   | Create a custom isbot function                                               |\n| createIsbotFromList | _(string[]): (string?): boolean_ | Create a custom isbot function from a list of string representation patterns |\n\n## Example usages of helper functions\n\nCreate a custom `isbot` that does not consider Chrome Lighthouse user agent as bots.\n\n```ts\nimport { createIsbotFromList, isbotMatches, list } from \"isbot\";\n\nconst ChromeLighthouseUserAgentStrings: string[] = [\n  \"mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/537.36 (khtml, like gecko) chrome/94.0.4590.2 safari/537.36 chrome-lighthouse\",\n  \"mozilla/5.0 (linux; android 7.0; moto g (4)) applewebkit/537.36 (khtml, like gecko) chrome/94.0.4590.2 mobile safari/537.36 chrome-lighthouse\",\n];\nconst patternsToRemove = new Set\u003cstring\u003e(\n  ChromeLighthouseUserAgentStrings.map(isbotMatches).flat(),\n);\nconst isbot: (ua: string) =\u003e boolean = createIsbotFromList(\n  list.filter(\n    (record: string): boolean =\u003e patternsToRemove.has(record) === false,\n  ),\n);\n```\n\nCreate a custom isbot that considers another pattern as a bot, which is not included in the package originally.\n\n```ts\nimport { createIsbotFromList, list } from \"isbot\";\n\nconst isbot = createIsbotFromList(list.concat(\"shmulik\"));\n```\n\n## Definitions\n\n- **Bot.** Autonomous program imitating or replacing some aspect of a human behaviour, performing repetitive tasks much faster than human users could.\n- **Good bot.** Automated programs who visit websites in order to collect useful information. Web crawlers, site scrapers, stress testers, preview builders and other programs are welcomed on most websites because they serve purposes of mutual benefits.\n- **Bad bot.** Programs which are designed to perform malicious actions, ultimately hurting businesses. Testing credential databases, DDoS attacks, spam bots.\n\n## Clarifications\n\n### What does \"isbot\" do?\n\nThis package aims to identify \"Good bots\". Those who voluntarily identify themselves by setting a unique, preferably descriptive, user agent, usually by setting a dedicated request header.\n\n### What doesn't \"isbot\" do?\n\nIt does not try to recognise malicious bots or programs disguising themselves as real users.\n\n### Why would I want to identify good bots?\n\nRecognising good bots such as web crawlers is useful for multiple purposes. Although it is not recommended to serve different content to web crawlers like Googlebot, you can still elect to\n\n- Flag pageviews to consider with **business analysis**.\n- Prefer to serve cached content and **relieve service load**.\n- Omit third party solutions' code (tags, pixels) and **reduce costs**.\n\n\u003e It is not recommended to **whitelist** requests for any reason based on user agent header only. Instead, other methods of identification can be added such as [reverse dns lookup](https://www.npmjs.com/package/reverse-dns-lookup).\n\n## How `isbot` maintains accuracy\n\n`isbot` is an asset when it can most accurately identify bots by the user agent string. It uses expansive and regularly updated lists of user agent strings to create a regular expression that matches bots and only bots.\n\nAnd above everything else, it is maintained by a community of contributers who help keep the list up to date.\n\n### Fallback\n\nThe pattern uses lookbehind methods which are not supported in all environments. A fallback is provided for environments that do not support lookbehind. The fallback is less accurate. The test suite includes a percentage of false positives and false negatives which is deemed acceptable for the fallback: 1% false positive and 75% bot coverage.\n\n## Data sources\n\nWe use external data sources on top of our own lists to keep up to date\n\n### Crawlers user agents\n\n- [user-agents.net](https://user-agents.net/bots)\n- [monperrus/crawler-user-agents](https://github.com/monperrus/crawler-user-agents/blob/master/crawler-user-agents.json)\n- [Kikobeats/top-crawler-agents](https://github.com/Kikobeats/top-crawler-agents/blob/master/index.json)\n- [myip.ms](https://www.myip.ms/files/bots/live_webcrawlers.txt)\n- [matomo.org](https://github.com/matomo-org/device-detector/blob/master/Tests/fixtures/bots.yml)\n- A Manual list\n\n### Non bot user agents\n\n- [user-agents npm package](https://www.npmjs.com/package/user-agents)\n- A Manual list\n\nMissing something? Please [open an issue](https://github.com/omrilotan/isbot/issues/new/choose)\n\n## Major releases breaking changes ([full changelog](./CHANGELOG.md))\n\n### [**Version 5**](https://github.com/omrilotan/isbot/releases/tag/v5.0.0)\n\nRemove named export \"pattern\" from the interface, instead use \"getPattern\" method\n\n### [**Version 4**](https://github.com/omrilotan/isbot/releases/tag/v4.0.0)\n\nRemove `isbot` function default export in favour of a named export.\n\n```ts\nimport { isbot } from \"isbot\";\n```\n\n### [**Version 3**](https://github.com/omrilotan/isbot/releases/tag/v3.0.0)\n\nRemove testing for node 6 and 8\n\n### [**Version 2**](https://github.com/omrilotan/isbot/releases/tag/v2.0.0)\n\nChange return value for isbot: `true` instead of matched string\n\n### [**Version 1**](https://github.com/omrilotan/isbot/releases/tag/v1.0.0)\n\nNo functional change\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomrilotan%2Fisbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomrilotan%2Fisbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomrilotan%2Fisbot/lists"}