{"id":19874696,"url":"https://github.com/dxphilo/tweety-rs","last_synced_at":"2025-07-28T08:34:38.752Z","repository":{"id":255336691,"uuid":"849303699","full_name":"dxphilo/tweety-rs","owner":"dxphilo","description":" Rust crate for interacting with the Twitter API.","archived":false,"fork":false,"pushed_at":"2024-09-16T12:36:43.000Z","size":196,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-30T09:27:31.881Z","etag":null,"topics":["api","rust","twitter","twitter-api","twitter-bot"],"latest_commit_sha":null,"homepage":"https://docs.rs/tweety-rs","language":"Rust","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/dxphilo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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":"2024-08-29T11:02:47.000Z","updated_at":"2024-10-25T17:40:33.000Z","dependencies_parsed_at":"2024-08-29T11:24:43.208Z","dependency_job_id":"24d4dc1a-2139-47ea-9c45-d34990d4d819","html_url":"https://github.com/dxphilo/tweety-rs","commit_stats":null,"previous_names":["dxphilo/tweety-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxphilo%2Ftweety-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxphilo%2Ftweety-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxphilo%2Ftweety-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxphilo%2Ftweety-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dxphilo","download_url":"https://codeload.github.com/dxphilo/tweety-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224307268,"owners_count":17289776,"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","rust","twitter","twitter-api","twitter-bot"],"created_at":"2024-11-12T16:25:03.935Z","updated_at":"2025-05-02T10:31:35.961Z","avatar_url":"https://github.com/dxphilo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tweety-rs\n\n[![Crates.io](https://img.shields.io/crates/v/tweety-rs.svg)](https://crates.io/crates/tweety-rs)\n[![Docs.rs](https://docs.rs/tweety-rs/badge.svg)](https://docs.rs/tweety-rs)\n[![License](https://img.shields.io/crates/l/tweety-rs.svg)](https://github.com/dxphilo/tweety-rs/blob/main/LICENSE)\n\n**tweety-rs** is a Rust crate for interacting with the Twitter API. It provides a convenient interface for performing actions such as posting tweets, managing followers, sending direct messages, and more.\n\n## Features\n\n- Post and edit tweets\n- Manage followers and followings\n- Like and retweet posts\n- Fetch direct messages\n- Manage bookmarks\n- Upload media files\n- Search tweets and users\n- Hide replies to tweets\n\n## Installation\n\nRun the command:\n\n```\ncargo add tweety-rs\n```\n\nThen, in your `main.rs` or `lib.rs`:\n\n```rust\nuse crate tweety_rs;\n```\n\n## Authentication\n\nTo authenticate with the Twitter API, you will need the following credentials:\n\n- Consumer Key: Your application's consumer key (API key)\n- Consumer Key Secret: Your application's consumer secret (API secret key)\n- Access Token: Your access token\n- Access Token Secret: Your access token secret\n\nYou can obtain these from the [Twitter Developer portal](https://developer.x.com/en/portal/projects-and-apps).\n\n## Usage\nTo get started, you'll need to create a TweetyClient with your Twitter API credentials.\n\n### Example: how to post a tweet\n\n```rust\nuse tweety_rs::client::TweetyClient;\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let client = TweetyClient::new(\n        \"your_consumer_key\",\n        \"your_consumer_key_secret\",\n        \"your_access_token\",\n        \"your_access_token_secret\",\n    );\n\n    // Post a tweet\n    client.post_tweet(\"Hello, Twitter!\", None).unwrap();\n\n    Ok(())\n}\n```\n\n### Example: Tweeting with image\n\nMake a tweet with an image appended to your tweet.\n\n```rust\nuse tweety_rs::{\n    types::tweet::{Media, PostTweetParams},\n    TweetyClient,\n};\nuse tokio;\n\n#[tokio::main]\nfn main() {\n    let client = TweetyClient::new(\n        \"your_consumer_key\",\n        \"your_consumer_key_secret\",\n        \"your_access_token\",\n        \"your_access_token_secret\",\n    );\n\n    let path = Path::new(\u0026file_path); // path of the image to be uploaded\n\n    match client.upload_file(\u0026path).await {\n        Ok(value) =\u003e {\n            let media_string = value.to_string();\n            let message = format!(\"#{}\", self.file_content.1);\n\n            let params = PostTweetParams {\n                direct_message_deep_link: None,\n                for_super_followers_only: None,\n                geo: None,\n                media: Some(Media {\n                    media_ids: vec![media_string].into(),\n                    tagged_user_ids: None,\n                }),\n                poll: None,\n                quote_tweet_id: None,\n                reply: None,\n                reply_settings: None,\n            };\n\n            match client.post_tweet(\u0026message, Some(params)).await {\n                Ok(status_code) =\u003e {\n                    println!(\"Posted tweet: {:?}\", status_code);\n                }\n                Err(err) =\u003e {\n                    println!(\"Error posting tweet: {}\", err);\n                }\n            }\n        }\n        Err(err) =\u003e {\n            println!(\"Error uploading images{}\", err);\n        }\n    }\n}\n```\n\n\n### Example: Retweeting\n\n```rust\nuse tweety_rs::client::TweetyClient;\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let client = TweetyClient::new(\n        \"your_consumer_key\",\n        \"your_consumer_key_secret\",\n        \"your_access_token\",\n        \"your_access_token_secret\",\n    );\n\n    // Retweet a tweet by ID\n    client.retweet(\"1234567890\")?;\n\n    Ok(())\n}\n```\n\n### Example: Get Direct Message\n\nHere’s an example of how to use the `get_direct_messages` function:\n\n```rust\nuse tweety_rs::{client::TweetyClient,error::TweetyError,direct_messages::QueryParams};\nuse serde_json::Value;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), TweetyError\u003e {\n    // Create an instance of TweetyClient\n    let client = TweetyClient::new(\n        \"your_consumer_key\",\n        \"your_consumer_key_secret\",\n        \"your_access_token\",\n        \"your_access_token_secret\",\n    );\n\n    // Define query parameters\n    let params = QueryParams {\n        dm_event_fields: Some(vec![DMEventField::Id, DMEventField::Text]),\n        event_types: Some(vec![EventType::MessageCreate]),\n        expansions: Some(vec![Expansion::SenderId]),\n        max_results: Some(50),\n        media_fields: Some(vec![MediaField::Url, MediaField::Type]),\n        tweet_fields: Some(vec![TweetField::CreatedAt, TweetField::Text]),\n        user_fields: Some(vec![UserField::Username, UserField::Verified]),\n    };\n\n    // Fetch direct messages\n    match client.get_direct_messages(params).await {\n        Ok(response) =\u003e {\n            println!(\"Direct messages: {}\", response);\n        }\n        Err(e) =\u003e {\n            eprintln!(\"Error fetching direct messages: {:?}\", e);\n        }\n    }\n\n    Ok(())\n}\n```\n\n# ⚠️ Responses\n\nWe return the response together with the headers if that might be important to you. The structure is as show in the struct below:\n\n```rust\n    #[derive(Debug, Serialize, Deserialize)]\n    pub struct ResponseWithHeaders {\n        pub response: Value,\n        pub headers: HashMap\u003cString, String\u003e,\n    }\n```\n\n\n# ⚠️ Twitter API Rate Limits\n\nTwitter has a small window cap for the free tier, so it's important to be aware of the rate limits.\n\n  - **Free Access**: 50 requests every 24 hours. (Make a post, Delete and Get self info only).\n  - **Elevated Access**: 300 requests per 15-minute window per user (Most functionality).\n\nCheck out the [rate limits Documentation](https://developer.x.com/en/docs/x-api/rate-limits)\n\n## Modules\nThe crate is organized into several modules, each responsible for different aspects of the Twitter API:\n\n- bookmark - Manage bookmarks\n- client - Main client for interacting with the Twitter API\n- direct_messages - Handle sending and receiving direct messages\n- favourites - Manage favourites (likes)\n- followers - Manage followers\n- following - Manage followings\n- hide_replies - Hide replies to tweets\n- like - Like tweets\n- mentions - Manage mentions\n- retweets - Retweet tweets\n- search - Search tweets and users\n- tweet - Post and manage tweets\n- uploads - Upload media files\n- user - Manage user information\n\n### Common Issues\n\n- **Authentication Issues**: When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the [Twitter Developer Portal](https://developer.twitter.com/en/portal/dashboard).\n\n- **OAuth1 Permissions**: Your client app might not be configured with the appropriate OAuth1 app permissions for this endpoint.\n\n### Error Resolution\n\n- **Endpoint Access**: Some errors may indicate that you need to upgrade to the premium tier to access certain endpoints.\n\n\n\n## Bots using this Crate\n\n- [County Flags](https://twitter.com/DailyPexels)\n- [Kenya Shilling Rates](https://x.com/kshsrates)\n- [AI Bot](https://x.com/philip46906)\n\n## Contributing\nContributions are welcome! Please feel free to submit a pull request or open an issue on GitHub.\n\n## License\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Acknowledgments\nThis project is inspired by the desire to make interacting with Twitter's API easier and more Rust-idiomatic.\n\nIf you found it helpful consider giving it a star ⭐️.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxphilo%2Ftweety-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdxphilo%2Ftweety-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxphilo%2Ftweety-rs/lists"}