An open API service indexing awesome lists of open source software.

https://github.com/dadananjesha/twitter-search-api

A minimum viable product written in Python using Django and the Django REST Framework with a sqlite database.
https://github.com/dadananjesha/twitter-search-api

django-application django-rest-framework dockerfile mvp mvt-architecture python3 sql sqlite3 twitter-api

Last synced: 2 months ago
JSON representation

A minimum viable product written in Python using Django and the Django REST Framework with a sqlite database.

Awesome Lists containing this project

README

          

# Twitter Search API (Django project)

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.

---

## ๐Ÿš€ Features

- ๐Ÿ” **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.

---

## ๐Ÿ“Œ API Endpoints

### 1๏ธโƒฃ **Trigger a Twitter Search**
Fetch tweets for high-traffic hashtags.
```bash
GET /search/?query=YourSearchQuery
```
**Example:** `http://127.0.0.1:8000/search/?query=ElectionDay`

### 2๏ธโƒฃ **Retrieve Stored Tweets**
Fetch tweets stored in the database with optional filtering.
```bash
GET /twitterSearch/
GET /twitterSearch/?search=YourKeyword
```
**Example:** `http://127.0.0.1:8000/twitterSearch/?search=ko`

### 3๏ธโƒฃ **Export Tweets to CSV**
Export stored tweets to CSV, selecting relevant columns.
```bash
GET /twitterDataExport/
```
**Example:** `http://127.0.0.1:8000/twitterDataExport/`

---

## ๐Ÿ“‚ Project Structure
![Project Structure](template/images/Project_Structure.jpg)

---

## ๐Ÿ› ๏ธ Installation

1๏ธโƒฃ **Clone the Repository**
```bash
git clone https://github.com/yourusername/twitter-search-api.git
cd twitter-search-api
```

2๏ธโƒฃ **Create & Activate Virtual Environment**
```bash
python -m venv env
source env/bin/activate # On Windows use `env\Scripts\activate`
```

3๏ธโƒฃ **Install Dependencies**
```bash
pip install -r requirements.txt
```

4๏ธโƒฃ **Run Database Migrations**
```bash
python manage.py migrate
```

5๏ธโƒฃ **Start the Development Server**
```bash
python manage.py runserver
```

---

## โš™๏ธ Environment Variables

To connect to Twitter API, set up the following environment variables:
```bash
TWITTER_API_KEY=
TWITTER_API_SECRET_KEY=
TWITTER_ACCESS_TOKEN=
TWITTER_ACCESS_TOKEN_SECRET=
```

---

## ๐Ÿงช Running Tests
Run the test suite to verify functionality:
```bash
python manage.py test
```

---

## ๐Ÿค Contributions

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.

---
## โญ๏ธ Call-to-Action

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!

---
## ๐Ÿ“ License

This project is licensed under the [MIT License](LICENSE).

---

๐Ÿ’™ **Happy Coding!** ๐Ÿš€