Welcome to the documentation for the VibeShare social media app backend. This Flask-based backend is responsible for handling user data, posts, comments, likes, and more. Below, you'll find information on how to interact with the API, including available endpoints and their functionalities.
To use the VibeShare backend, follow the steps below:
- Clone the repository:
git clone <repository-url>
- Install dependencies:
pip install -r requirements.txt
- Set up Cloudinary account: Cloudinary and obtain API credentials (cloud_name, api_key, api_secret).
- Configure the Flask app by adding your Cloudinary credentials and SQLAlchemy database URI to the code.
cloudinary.config(
cloud_name = "your_cloud_name",
api_key = "your_api_key",
api_secret = "your_api_secret"
)
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "your_database_uri"
- Description: Retrieve user information by username.
- Request:
{
"username": "user123"
}
- Response:
{
"user": {
"state": true,
"name": "John Doe",
"username": "user123",
"pfp": "https://cloudinary.com/image.jpg"
}
}
- Description: Retrieve all posts.
- Response:
{
"posts": [
{
"name": "John Doe",
"username": "user123",
"text": "Hello, VibeShare!",
"pfp": "https://cloudinary.com/image.jpg",
"img": "https://cloudinary.com/post_image.jpg",
"likes": 5,
"post_id": 1
},
// ... other posts
],
"status": true
}
- Description: Like or unlike a post.
- Request:
{
"post_id": 1,
"user_email": "user@example.com"
}
- Response:
{
"status": true,
"message": "Post liked successfully"
}
- Description: Check if a user has liked a post.
- Request:
{
"post_id": 1,
"user_email": "user@example.com"
}
- Response:
{
"liked": true
}
- Description: Create a new post.
- Request:
{
"user": "John Doe",
"username": "user123",
"text": "New post on VibeShare!",
"img": "base64_encoded_image",
"pfp": "https://cloudinary.com/image.jpg"
}
- Response:
{
"status": true
}
- Description: Create a new user.
- Request:
{
"name": "John Doe",
"username": "user123",
"email": "user@example.com",
"pfp": "https://cloudinary.com/image.jpg"
}
- Response:
{
"status": true
}
- Description: Add a comment to a post.
- Request:
{
"text": "Great post!",
"post_id": 1,
"user_email": "user@example.com",
"name": "John Doe"
}
- Response:
{
"status": true,
"message": "Comment added successfully!"
}
- Description: Get comments for a specific post.
- Request:
{
"post_id": 1
}
- Response:
{
"status": true,
"message": "Post comments found",
"comments": [
{
"name": "John Doe",
"email": "user@example.com",
"text": "Great post!"
},
// ... other comments
]
}
- Description: Get featured users.
- Response:
{
"status": true,
"message": "Fetched users.",
"accounts": [
{
"name": "John Doe",
"username": "user123",
"img": "https://cloudinary.com/image.jpg"
},
// ... other featured users
]
}
- Description: Get details of a specific post.
- Request:
{
"post_id": 1
}
- Response:
{
"name": "John Doe",
"username": "user123",
"pfp": "https://cloudinary.com/image.jpg",
"img": "https://cloudinary.com/post_image.jpg",
"text": "Hello, VibeShare!",
"status": true,
"post_id": 1,
"likes": 5
}
- The base URL for the API is the root of your Flask application (e.g.,
http://localhost:5000/
). - All image URLs are assumed to be Cloudinary URLs.
- The API provides basic error handling, but additional error handling may be needed for production use.
Feel free to reach out for further assistance or clarification. Happy coding!