{"id":16760322,"url":"https://github.com/roccomuso/is-twitter","last_synced_at":"2025-09-14T05:31:18.276Z","repository":{"id":57277664,"uuid":"135562060","full_name":"roccomuso/is-twitter","owner":"roccomuso","description":"Verify that a request is from Twitter crawlers using DNS verification steps","archived":false,"fork":false,"pushed_at":"2018-05-31T09:29:58.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-02T00:06:00.990Z","etag":null,"topics":["bot","crawler","dns","ip","js","nodejs","twitter","verification"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/roccomuso.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":"2018-05-31T09:25:20.000Z","updated_at":"2019-05-13T21:20:02.000Z","dependencies_parsed_at":"2022-09-11T05:30:46.486Z","dependency_job_id":null,"html_url":"https://github.com/roccomuso/is-twitter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roccomuso%2Fis-twitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roccomuso%2Fis-twitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roccomuso%2Fis-twitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roccomuso%2Fis-twitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roccomuso","download_url":"https://codeload.github.com/roccomuso/is-twitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232954591,"owners_count":18602151,"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":["bot","crawler","dns","ip","js","nodejs","twitter","verification"],"created_at":"2024-10-13T04:23:07.404Z","updated_at":"2025-01-07T23:53:55.205Z","avatar_url":"https://github.com/roccomuso.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# is-twitter\n\n[![NPM Version](https://img.shields.io/npm/v/is-twitter.svg)](https://www.npmjs.com/package/is-twitter)\n[![Build Status](https://travis-ci.org/roccomuso/is-twitter.svg?branch=master)](https://travis-ci.org/roccomuso/is-twitter)\n![node](https://img.shields.io/node/v/is-twitter.svg)\n[![Dependency Status](https://david-dm.org/roccomuso/is-twitter.png)](https://david-dm.org/roccomuso/is-twitter)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n\u003e Verify that a request is from Twitter crawlers using Twitter's DNS verification steps\n\nYou may wish to verify that a web crawler accessing your server is Twitter  and not spammers or other bots scraping your site while claiming to be Twitterbot. Since you cannot rely on the `User-Agent` header which is easily spoofed, you need to use DNS look up to verify that the IP address belongs to Twitter. Twitter is usually scanning URLs to detect metadata.\n\n\n## Install\n\n`npm install --save is-twitter`\n\n## Example\n\n```javascript\nconst isTwitter = require('is-twitter')\n\nlet ip = '199.59.150.182'\nisTwitter(ip).then((outcome) =\u003e {\n  if (outcome) {\n    // it's twitter.\n  }\n}).catch(console.error)\n```\n\n### Example with express\n\n```javascript\napp.enable('trust proxy')\n\napp.use((req, res, next) =\u003e {\n  let ip = req.ip || req.connection.remoteAddress\n  isTwitter(ip).then(outcome =\u003e {\n    if (outcome) {\n      res.status(404).text('Nothing to scan') // block twitter crawler\n    } else {\n      next() // it's a user\n    }\n  })\n})\n```\n\n## Tests\n\n`npm test`\n\n## License\n\nMIT\n\n## Author\n\nRocco Musolino [@roccomuso](https://twitter.com/roccomuso)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froccomuso%2Fis-twitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froccomuso%2Fis-twitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froccomuso%2Fis-twitter/lists"}