{"id":18318715,"url":"https://github.com/xdevplatform/twitter-api-v2-sample-code","last_synced_at":"2025-05-13T22:02:30.198Z","repository":{"id":37076068,"uuid":"287069180","full_name":"xdevplatform/Twitter-API-v2-sample-code","owner":"xdevplatform","description":"Sample code for the Twitter API v2 endpoints","archived":false,"fork":false,"pushed_at":"2025-01-16T23:36:35.000Z","size":152,"stargazers_count":2949,"open_issues_count":99,"forks_count":1043,"subscribers_count":63,"default_branch":"main","last_synced_at":"2025-04-29T13:17:51.169Z","etag":null,"topics":["java","javascript","nodejs","python","ruby","twitter","twitter-api","twitter-api-v2"],"latest_commit_sha":null,"homepage":"https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api","language":"JavaScript","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":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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-12T17:00:53.000Z","updated_at":"2025-04-28T17:36:39.000Z","dependencies_parsed_at":"2022-08-08T19:01:43.185Z","dependency_job_id":"1b167893-a1c0-45b7-a362-78bbb289810c","html_url":"https://github.com/xdevplatform/Twitter-API-v2-sample-code","commit_stats":null,"previous_names":["xdevplatform/twitter-api-v2-sample-code"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2FTwitter-API-v2-sample-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2FTwitter-API-v2-sample-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2FTwitter-API-v2-sample-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdevplatform%2FTwitter-API-v2-sample-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xdevplatform","download_url":"https://codeload.github.com/xdevplatform/Twitter-API-v2-sample-code/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036807,"owners_count":22003652,"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":["java","javascript","nodejs","python","ruby","twitter","twitter-api","twitter-api-v2"],"created_at":"2024-11-05T18:11:22.396Z","updated_at":"2025-05-13T22:02:30.158Z","avatar_url":"https://github.com/xdevplatform.png","language":"JavaScript","readme":"# Twitter API v2 sample code [![v2](https://img.shields.io/endpoint?url=https%3A%2F%2Ftwbadges.glitch.me%2Fbadges%2Fv2)](https://developer.twitter.com/en/docs/twitter-api)\n\nSample code for the Twitter API v2 endpoints.\nIndividual API features have folders where you can find examples of usage in several coding languages (Java, Node.js, Python, R, and Ruby).\n\n* [Twitter API Documentation](https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api)\n\n## Prerequisites\n\n* Twitter API Essential Access ([sign up here](https://t.co/signup))\n* A Project and an App created [in the dashboard](https://developer.twitter.com/en/portal/dashboard)\n\n## Using the code samples\n\nIn order to run the samples in this repository you will need to set up some environment variables. You can find your credentials and bearer token in the App inside of your Project in the [dashboard of the developer portal](https://developer.twitter.com/en/portal/projects-and-apps).\n\nFor OAuth 1.0a samples, you will need to export your consumer key and secret in your terminal. Be sure to replace `\u003cyour_consumer_key\u003e` and `\u003cyour_consumer_secret\u003e` with your own credentials without the `\u003c \u003e`.\n\n```bash\nexport CONSUMER_KEY='\u003cyour_consumer_key\u003e'\nexport CONSUMER_SECRET='\u003cyour_consumer_secret\u003e'\n```\n\nFor samples which use bearer token authentication, you will need to export the bearer token. Be sure to replace  `\u003cyour_bearer_token\u003e` with your own bearer token without the `\u003c \u003e`.\n\n```bash\nexport BEARER_TOKEN='\u003cyour_bearer_token\u003e'\n```\n\n## Language-specific requirements\n\n### Java environment set up\n\nIf you use Homebrew, you can install a Java runtime using:\n\n```bash\nbrew cask install java\n```\n\nYou will also need to download the relevant JAR files referenced in the individual samples in order to build and run the code. If you use an IDE, it may be able to do this automatically for you.\n\n### JavaScript (Node.js) environment set up\n\nYou will need to have Node.js installed to run this code. All Node.js examples use `needle` as the HTTP client, which needs to be npm installed. For OAuth with user context requests, you'll need to install the `got` and `oauth-1.0a` packages.\n\n```bash\nnpm install needle\nnpm install got\nnpm install oauth-1.0a\n```\n\n### Python environment set up\n\nYou will need to have Python 3 installed to run this code. The Python samples use `requests==2.24.0` which uses `requests-oauthlib==1.3.0`.\n\n(Optionally) It is common and recommended not to install required package globally, but locally under project subfolder using `venv`:\n\n```bash\npython3 -m venv venv\nsource venv/bin/activate\n```\n\nYou can install these packages as follows:\n\n```bash\npip install requests\npip install requests-oauthlib\n```\n\n### Ruby environment set up\n\nYou will need to have Ruby (recommended: \u003e= 2.0.0) installed in order to run the code. The Ruby examples use `typhoeus` as the HTTP client, which needs to be gem installed. For OAuth with user context requests, you'll also need to install the `oauth` gem (see below).\n\n```bash\ngem install typhoeus\ngem install oauth\n```\n\n## Additional resources\n\nWe maintain a [Postman](https://getpostman.com) Collection which you can use for exercising individual API endpoints.\n\n* [Using Postman with the Twitter API](https://developer.twitter.com/en/docs/tutorials/postman-getting-started)\n* [Twitter API v2 on the Postman website](https://t.co/twitter-api-postman)\n\n## Support\n\n* For general questions related to the API and features, please use the v2 section of our [developer community forums](https://twittercommunity.com/c/twitter-api/twitter-api-v2/65).\n\n* If there's an bug or issue with the sample code itself, please create a [new issue](https://github.com/twitterdev/Twitter-API-v2-sample-code/issues) here on GitHub.\n\n## Contributing\n\nWe welcome pull requests that add meaningful additions to these code samples, particularly for languages that are not yet represented here.\n\nWe feel that a welcoming community is important and we ask that you follow Twitter's [Open Source Code of Conduct](https://github.com/twitter/.github/blob/main/code-of-conduct.md) in all interactions with the community.\n\n## License\n\nCopyright 2021 Twitter, Inc.\n\nLicensed under the Apache License, Version 2.0: https://www.apache.org/licenses/LICENSE-2.0\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxdevplatform%2Ftwitter-api-v2-sample-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxdevplatform%2Ftwitter-api-v2-sample-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxdevplatform%2Ftwitter-api-v2-sample-code/lists"}