Base URL: http://localhost:8080
Content-Type: application/json
Every response from this API follows a consistent wrapper structure. This makes it easy to handle errors in your React fetch or axios logic.
{
"status": boolean, // true if successful, false otherwise
"data": any | null, // the payload (array of Ideas or single Idea)
"error": string | null // error message if status is false
}Adds a new idea to the database.
- Endpoint:
POST /post-idea - Rate Limit: 6 requests per second (burst capacity of 24). If exceeded, returns
429 Too Many Requests. - Max Body Size: 1MB.
The id is server-generated, so you should not send it from the frontend.
| Field | Type | Description |
|---|---|---|
| title | string | The title of the idea. Cannot Be Empty |
| content | string | Detailed description. Cannot Be Empty |
| tags | string[] | An array of strings (e.g., ["web", "go"]). Can Be Empty |
Example:
{
"title": "Build a React App",
"content": "Create a frontend for my Go API.",
"tags": ["react", "frontend", "learning"]
}- Success (200 OK):
{"status": true} - Rate Limited (429):
{"status": false, "error": "rate limit exceeded..."} - Error (500):
{"status": false, "error": "internal server error"}
Retrieves ideas based on ID, tags, or a general random list.
- Endpoint:
GET /ideas - Query Parameters:
id(int): If provided, returns a specific idea. Overwrites other parameters.tags(string): A comma-separated list (e.g.,react,go).limit(int): The number of results to return. Defaults to1.
If you pass an id, the API returns an array containing that single idea.
Example: GET /ideas?id=5
Success Response:
{
"status": true,
"data": [
{
"id": 5,
"title": "Build a React App",
"content": "...",
"tags": ["react", "learning"]
}
]
}If you pass tags, the API returns ideas that contain all of the specified tags, ordered randomly.
Example: GET /ideas?tags=react,frontend&limit=10
If no id or tags are provided, the API returns a random selection of ideas up to the limit.
Example: GET /ideas?limit=5
If you are using TypeScript in your React project, you can use these definitions:
interface Idea {
id: number;
title: string;
content: string;
tags: string[];
}
interface ApiResponse<T> {
status: boolean;
data?: T;
error?: string;
}- URLSearchParams: Use the
URLSearchParamsweb API to build yourGET /ideasqueries safely, especially when handling multiple tags. - Handling the Data Shape: Note that
GET /ideasalways returns an array in thedatafield, even when you are fetching a single idea byid. In your React state, you'll likely want to doresult.data[0]when fetching by ID. - Error Handling: Check
response.okfirst, but then checkdata.statusto see if the backend logic failed (like a DB error).