{"id":18318705,"url":"https://github.com/xdevplatform/autohook","last_synced_at":"2025-04-05T21:33:05.922Z","repository":{"id":35387603,"uuid":"194932849","full_name":"xdevplatform/autohook","owner":"xdevplatform","description":"Automatically setup and serve webhooks for the Twitter Account Activity API","archived":false,"fork":false,"pushed_at":"2022-03-11T17:49:10.000Z","size":8322,"stargazers_count":155,"open_issues_count":6,"forks_count":30,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-02T11:59:35.489Z","etag":null,"topics":["api","twitter","twitter-account-activity","twitter-api","webhook","webhook-server"],"latest_commit_sha":null,"homepage":"","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/xdevplatform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-02T20:48:39.000Z","updated_at":"2025-03-22T03:06:11.000Z","dependencies_parsed_at":"2022-08-08T08:00:32.647Z","dependency_job_id":null,"html_url":"https://github.com/xdevplatform/autohook","commit_stats":null,"previous_names":["xdevplatform/autohook"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2Fautohook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2Fautohook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2Fautohook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2Fautohook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xdevplatform","download_url":"https://codeload.github.com/xdevplatform/autohook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406076,"owners_count":20933803,"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":["api","twitter","twitter-account-activity","twitter-api","webhook","webhook-server"],"created_at":"2024-11-05T18:11:19.087Z","updated_at":"2025-04-05T21:33:04.201Z","avatar_url":"https://github.com/xdevplatform.png","language":"JavaScript","readme":"# Autohook 🎣\n\nAutohook configures and manages [Twitter webhooks](https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/guides/managing-webhooks-and-subscriptions) for you. Zero configuration. Just run and go!\n\n![Demo](https://github.com/twitterdev/autohook/raw/master/demo.gif)\n\n* 🚀 Spawns a server for you\n* ⚙️ Registers a webhook (it removes existing webhooks if you want, and you can add more than one webhook if your Premium subscription supports it)\n* ✅ Performs the CRC validation when needed\n* 📝 Subscribes to your current user's context (you can always subscribe more users if you need)\n* 🎧 Exposes a listener so you can pick up Account Activity events and process the ones you care about\n\n## Usage\n\nYou can use Autohook as a module or as a command-line tool.\n\n### Node.js module\n\n```js\nconst { Autohook } = require('twitter-autohook');\n\n(async ƛ =\u003e {\n  const webhook = new Autohook();\n  \n  // Removes existing webhooks\n  await webhook.removeWebhooks();\n  \n  // Listens to incoming activity\n  webhook.on('event', event =\u003e console.log('Something happened:', event));\n  \n  // Starts a server and adds a new webhook\n  await webhook.start();\n  \n  // Subscribes to a user's activity\n  await webhook.subscribe({oauth_token, oauth_token_secret});\n})();\n```\n\n### Command line\n\nStarting Autohook from the command line is useful when you need to test your connection and subscriptions.\n\nWhen started from the command line, Autohook simply provisions a webhook, subscribes your user (unless you specify `--do-not-subscribe-me`), and echoes incoming events to `stdout`.\n\n```bash\n# Starts a server, removes any existing webhook, adds a new webhook, and subscribes to the authenticating user's activity.\n$ autohook -rs\n\n# All the options\n$ autohook --help\n```\n\n## OAuth\n\nAutohook works only when you pass your OAuth credentials. You won't have to figure out OAuth by yourself – Autohook will work that out for you.\n\nYou can pass your OAuth credentials in a bunch of ways.\n\n## Dotenv (~/.env.twitter)\n\nCreate a file named `~/.env.twitter` (sits in your home dir) with the following variables:\n\n```bash\nTWITTER_CONSUMER_KEY= # https://developer.twitter.com/en/apps ➡️ Your app ID ➡️ Details ➡️ API key\nTWITTER_CONSUMER_SECRET= # https://developer.twitter.com/en/apps ➡️ Your app ID ➡️ Details ➡️ API secret key\nTWITTER_ACCESS_TOKEN= # https://developer.twitter.com/en/apps ➡️ Your app ID ➡️ Details ➡️ Access token\nTWITTER_ACCESS_TOKEN_SECRET= # https://developer.twitter.com/en/apps ➡️ Your app ID ➡️ Details ➡️ Access token secret\nTWITTER_WEBHOOK_ENV= # https://developer.twitter.com/en/account/environments ➡️ One of 'Dev environment label' or 'Prod environment label'\nNGROK_AUTH_TOKEN= # https://ngrok.com/ - (optional) Create a free account to get your auth token for stable tunnels\n```\n\nAutohook will pick up these details automatically, so you won't have to specify anything in code or via CLI.\n\n## Env variables\n\nUseful when you're deploying to remote servers, and can be used in conjunction with your dotenv file.\n\n```bash\n\n# To your current environment\nexport TWITTER_CONSUMER_KEY= # https://developer.twitter.com/en/apps ➡️ Your app ID ➡️ Details ➡️ API key\nexport TWITTER_CONSUMER_SECRET= # https://developer.twitter.com/en/apps ➡️ Your app ID ➡️ Details ➡️ API secret key\nexport TWITTER_ACCESS_TOKEN= # https://developer.twitter.com/en/apps ➡️ Your app ID ➡️ Details ➡️ Access token\nexport TWITTER_ACCESS_TOKEN_SECRET= # https://developer.twitter.com/en/apps ➡️ Your app ID ➡️ Details ➡️ Access token secret\nexport TWITTER_WEBHOOK_ENV= # https://developer.twitter.com/en/account/environments ➡️ One of 'Dev environment label' or 'Prod environment label'\nexport NGROK_AUTH_TOKEN= # https://ngrok.com/ - (optional) Create a free account to get your auth token for stable tunnels\n\n# To other services, e.g. Heroku\nheroku config:set TWITTER_CONSUMER_KEY=value TWITTER_CONSUMER_SECRET=value TWITTER_ACCESS_TOKEN=value TWITTER_ACCESS_TOKEN_SECRET=value TWITTER_WEBHOOK_ENV=value NGROK_AUTH_TOKEN=value\n```\n## Directly\n\nNot recommended, because you should always [secure your credentials](https://developer.twitter.com/en/docs/basics/authentication/guides/securing-keys-and-tokens.html).\n\n### Node.js\n\n```js\nnew Autohook({\n  token: 'value',\n  token_secret: 'value',\n  consumer_key: 'value',\n  consumer_secret: 'value',\n  ngrok_secret: 'value', // optional\n  env: 'env',\n  port: 1337\n});\n```\n\n### CLI\n\n```bash\n$ autohook \\\n  --token $TWITTER_ACCESS_TOKEN \\\n  --secret $TWITTER_ACCESS_TOKEN_SECRET \\\n  --consumer-key $TWITTER_CONSUMER_KEY \\\n  --consumer-secret $TWITTER_CONSUMER_SECRET \\\n  --env $TWITTER_WEBHOOK_ENV \\\n  --ngrok-secret $NGROK_AUTH_TOKEN # optional\n```\n\n## Install\n\n```bash\n# npm\n$ npm i -g twitter-autohook\n\n# Yarn\n$ yarn global add twitter-autohook\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxdevplatform%2Fautohook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxdevplatform%2Fautohook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxdevplatform%2Fautohook/lists"}