A lightweight and efficient Twitter Search API built with Python, Django, and Django REST Framework. This project utilizes the Twitter Search API to fetch, store, filter, and export tweets related to trending events and hashtags.
- 🔍 Search Twitter - Fetch recent tweets based on trending hashtags or keywords.
- 🗄️ Store & Retrieve - Save tweets into a local SQLite database and retrieve them with flexible filtering options.
- 📤 Export to CSV - Export tweet data in CSV format for analysis.
- 🖥️ REST API Endpoints - Easily interact with tweet data using well-structured API endpoints.
Fetch tweets for high-traffic hashtags.
GET /search/?query=YourSearchQuery
Example: http://127.0.0.1:8000/search/?query=ElectionDay
Fetch tweets stored in the database with optional filtering.
GET /twitterSearch/
GET /twitterSearch/?search=YourKeyword
Example: http://127.0.0.1:8000/twitterSearch/?search=ko
Export stored tweets to CSV, selecting relevant columns.
GET /twitterDataExport/
Example: http://127.0.0.1:8000/twitterDataExport/
1️⃣ Clone the Repository
git clone https://github.com/yourusername/twitter-search-api.git
cd twitter-search-api
2️⃣ Create & Activate Virtual Environment
python -m venv env
source env/bin/activate # On Windows use `env\Scripts\activate`
3️⃣ Install Dependencies
pip install -r requirements.txt
4️⃣ Run Database Migrations
python manage.py migrate
5️⃣ Start the Development Server
python manage.py runserver
To connect to Twitter API, set up the following environment variables:
TWITTER_API_KEY=<Your_Twitter_API_Key>
TWITTER_API_SECRET_KEY=<Your_Twitter_API_Secret_Key>
TWITTER_ACCESS_TOKEN=<Your_Twitter_Access_Token>
TWITTER_ACCESS_TOKEN_SECRET=<Your_Twitter_Access_Token_Secret>
Run the test suite to verify functionality:
python manage.py test
We welcome contributions! 🎉 To contribute:
- Fork the repository.
- Create a new branch.
- Implement your changes.
- Submit a pull request.
Ensure that your code is well-documented and includes relevant tests.
If you find this project helpful, please consider:
- Starring the repository to show your support.
- Forking to contribute improvements.
- Following for updates on future projects.
Your engagement helps boost visibility and encourages further collaboration!
This project is licensed under the MIT License.
💙 Happy Coding! 🚀