This FastAPI application generates social media posts using the OpenAI API. It provides endpoints for generating new posts based on user-defined topics, retrieving all posts, filtering posts for today, and grouping posts by their publish date.
- Python 3.x
- FastAPI
- Uvicorn
- OpenAI Python package
-
Clone the repository:
git clone https://github.com/cojocaru/publisher-api.git
-
Navigate to the project directory:
cd publisher-api
-
Install the required packages:
pip install -r requirements.txt
-
Set up the environment variables:
Create a
.env
file in the root directory and add your OpenAI API key:OPENAI_API_KEY=your_openai_api_key_here
-
Run the application:
uvicorn main:app --reload
To generate new posts (limit 20 leters for now), make a POST request to /generate-posts/
with the following JSON payload (the topic can be aslo URL):
{
"topic": "science",
"network": "linkedin",
"days": 7
}
To retrieve all generated posts, make a GET request to /get-all-posts/
.
To filter posts for today's date, make a GET request to /get-todays-posts/
.
To get posts organized by their publish date, make a GET request to /get-posts-grouped-by-day/
.
- Add database support for more robust data storage.
- Implement authentication for better security.
- Add rate-limiting to prevent abuse.
Contributions are welcome!