{"id":18318706,"url":"https://github.com/xdevplatform/extract-usernames-from-tweet-replies","last_synced_at":"2025-04-05T21:33:04.663Z","repository":{"id":39974619,"uuid":"440249311","full_name":"xdevplatform/extract-usernames-from-tweet-replies","owner":"xdevplatform","description":"Python script to pull replies to a specific Tweet and extract user mentions","archived":false,"fork":false,"pushed_at":"2022-11-18T01:01:18.000Z","size":21,"stargazers_count":27,"open_issues_count":0,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T11:59:35.565Z","etag":null,"topics":["python","twitter","twitter-api","twitter-api-v2"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xdevplatform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-20T17:13:18.000Z","updated_at":"2025-03-15T15:55:12.000Z","dependencies_parsed_at":"2022-09-23T01:51:38.288Z","dependency_job_id":null,"html_url":"https://github.com/xdevplatform/extract-usernames-from-tweet-replies","commit_stats":null,"previous_names":["xdevplatform/extract-usernames-from-tweet-replies"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2Fextract-usernames-from-tweet-replies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2Fextract-usernames-from-tweet-replies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2Fextract-usernames-from-tweet-replies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2Fextract-usernames-from-tweet-replies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xdevplatform","download_url":"https://codeload.github.com/xdevplatform/extract-usernames-from-tweet-replies/tar.gz/refs/heads/main","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":["python","twitter","twitter-api","twitter-api-v2"],"created_at":"2024-11-05T18:11:20.078Z","updated_at":"2025-04-05T21:33:04.400Z","avatar_url":"https://github.com/xdevplatform.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Retrieve Tweet replies\n\nThis Python script pulls all direct replies to a specified Tweet, extracts user [mentions](https://help.twitter.com/en/using-twitter/mentions-and-replies) from the replies, and returns a list of usernames ordered by most to least frequently mentioned in the replies.\n\nThis script uses v2 of the Twitter API, and more specifically:\n\n* [Search Tweets](https://developer.twitter.com/en/docs/twitter-api/tweets/search/introduction)\n* [Tweets lookup](https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/introduction)\n\nAdditional details on how to run this code, including instructions on how to replace the full-archive search endpoint with the recent search endpoint, are available [here](https://dev.to/twitterdev/retrieve-a-list-of-user-mentions-from-a-thread-of-tweet-replies-4ib6).\n\n## Requirements\n\n* Twitter developer account.\n* Developer Project and App with access to the v2 full-archive search endpoint: [GET /2/tweets/search/all](https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-all).\n\nYou can read more about getting access to all of the above in [Twitter's developer docs](https://developer.twitter.com/en/docs/twitter-api/getting-started/getting-access-to-the-twitter-api).\n\n## Authentication \u0026 set up\n\nRename `.env_example` to `.env` and add the credentials for your developer App in between the `\"\"`.\n\n```text\nTWITTER_CONSUMER_KEY=\"\"\nTWITTER_CONSUMER_SECRET=\"\"\nTWITTER_ACCESS_TOKEN=\"\"\nTWITTER_ACCESS_TOKEN_SECRET=\"\"\nTWITTER_BEARER_TOKEN=\"\"\n```\n\nDon't forget to add `.env` to your `.gitignore` file to keep your credentials secure.\n\nYou will also need to install the `requests` and `python-dotenv` Python modules:\n\n```shell\n$ pip3 install requests python-dotenv\n```\n\n## Running the script\n\n```shell\n$ python3 replies.py -t \u003cTWEET-ID\u003e\n```\n\n|Flags|   |   |   |\n|---|---|---|---|\n|`-t`|Tweet ID|Required|ID of the Tweet for which you want to pull data.|\n|`-h`|Help|Optional|View a list of available flags and a description for each of these.|\n|`-s`|Start time|Optional|The oldest UTC timestamp from which the replies will be provided. Format: YYYY-MM-DDTHH:mm:ssZ; for example: 2021-12-04T01:30:00Z. If unspecified, will default to returning replies from up to 30 days ago.|\n|`-e`|End time|Optional|The newest, most recent UTC timestamp to which the replies will be provided. Format: YYYY-MM-DDTHH:mm:ssZ; for example: 2021-12-04T01:30:00Z. If unspecified, will default to [now - 30 seconds].|\n|   |   |   |   |\n\nRun the following command to see a list of available flags:\n```\n$ python3 replies.py -h\n```\n\n## Output\n\n### Returned in the command line interface\n\n* Ordered dictionary containing: a list of all usernames present in the replies and the number of times each username was mentioned. Note: the username who authored the original Tweet is not included.\n* Number of replies to the Tweet.\n* Number of usernames mentioned in these replies.\n* Total request count made to the Search API to get these replies.\n\n### Returned in a new file\n\n* `replies.txt` containing a list of Tweet IDs for the replies.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxdevplatform%2Fextract-usernames-from-tweet-replies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxdevplatform%2Fextract-usernames-from-tweet-replies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxdevplatform%2Fextract-usernames-from-tweet-replies/lists"}