5.5 KiB

OnlyPrompt API

This file documents the backend endpoints used by the frontend. The backend is a helper service for server communication, authentication and shared data persistence.

Base URL in local Docker setup:

http://localhost:1801

Authentication uses a jwt cookie set by the login endpoint. Protected endpoints require a logged-in user.

Auth

Register

POST /api/v1/auth/register
Content-Type: application/json

Request:

{
  "displayName": "Isabelle",
  "userName": "its_isabelle",
  "email": "isabelle@test.com",
  "password": "1234"
}

Response: created user data or validation errors.

Login

POST /api/v1/auth/login
Content-Type: application/json

Request:

{
  "userNameOrEmail": "isabelle@test.com",
  "password": "1234"
}

Response: sets the auth cookie.

Current User

GET /api/v1/auth/me

Response:

{
  "id": "uuid",
  "userName": "its_isabelle",
  "email": "isabelle@test.com",
  "roles": ["User"]
}

Logout

POST /api/v1/auth/logout

Deletes the auth cookie and redirects to login.

Profiles

Current Profile

GET /api/v1/profiles/self

Response:

{
  "displayName": "Isabelle",
  "slug": "its_isabelle",
  "bio": "AI creator",
  "avatarUrl": "data:image/png;base64,...",
  "specialities": null,
  "averageRating": 0,
  "subscribers": 0
}

Creator List

GET /api/v1/profiles?sort=popular&limit=50&search=belle

Query parameters:

  • sort: popular, prompts, new, rating
  • limit: number of creators
  • search: optional search term

Response: list of creator cards including follow state and avatar URL.

Public Profile

GET /api/v1/profiles/{creatorId}

Used by public creator profiles. The response contains display name, slug, bio, avatar URL, average rating and subscriber count.

Update Profile

PUT /api/v1/profiles
Content-Type: application/json

Request:

{
  "displayName": "Belle",
  "userName": "lady_belle",
  "slug": "lady_belle",
  "bio": "Prompt creator",
  "avatarUrl": "data:image/png;base64,...",
  "specialities": null,
  "isPublic": true
}

Updates profile data used on My Profile, Community and the topbar.

Prompts

List Prompts

GET /api/v1/prompts?sortBy=date&ascending=false&limit=50&search=cat

Used by Marketplace. Supports sorting, search and category filtering. The marketplace excludes prompts created by the logged-in user.

Response items include prompt title, description, creator id, creator name, creator avatar, example image, price, like/save counts, average rating, review count and access state.

Feed

GET /api/v1/feed?sortBy=date&ascending=false&limit=20

Used by Dashboard. Returns prompt cards from followed creators, excluding the logged-in user's own prompts.

Create Prompt

POST /api/v1/prompts
Content-Type: application/json

Request:

{
  "title": "Luxury Cat Portrait",
  "description": "Create a premium cat portrait prompt.",
  "content": "Write the full prompt instructions here.",
  "category": "art",
  "subscriptionTier": null,
  "slug": null,
  "exampleOutput": "Example output text",
  "exampleImageUrl": "data:image/png;base64,...",
  "price": null
}

Response: created prompt. The frontend redirects to /post-detail?id={id}.

Own Prompts

GET /api/v1/prompts/mine

Used by My Profile to show prompts created by the logged-in user.

Update Prompt

PUT /api/v1/prompts/{id}
Content-Type: application/json

Request body uses the same editable fields as prompt creation. Used by the edit prompt flow.

Prompt Detail

GET /api/v1/prompts/{id}

Response includes:

  • title and description
  • prompt content if accessible
  • category
  • creator information
  • price or free state
  • example output
  • example image
  • average rating and review count
  • like/save state and counts

Paid prompts return no detail content for users without access.

Likes and Saves

PUT /api/v1/prompts/{id}/likes
DELETE /api/v1/prompts/{id}/likes
PUT /api/v1/prompts/{id}/saves
DELETE /api/v1/prompts/{id}/saves

Used by Dashboard, prompt detail and profile tabs to store user interactions.

Reviews

GET /api/v1/prompts/{id}/reviews
PUT /api/v1/prompts/{id}/reviews

PUT request:

{
  "comment": "Helpful prompt",
  "rating": 5
}

Used on the prompt detail page. Users can review prompts created by other users. Each user can have one review per prompt; submitting again updates the existing review. Reviews are displayed with username, star rating and comment.

Categories

Minimal Categories

GET /api/v1/categories/minimal

Used by Create New and Marketplace filters.

Response:

[
  {
    "name": "Art",
    "slug": "art"
  }
]

Default categories are created automatically when the backend starts.

Subscriptions

Follow or Subscribe to Creator

GET /api/v1/subscriptions/{creatorId}
PUT /api/v1/subscriptions/{creatorId}
DELETE /api/v1/subscriptions/{creatorId}

Used by Community and public profiles to read follow state, follow creators or unfollow creators.

Error Handling

Common response codes used by the frontend:

  • 200 OK: request succeeded
  • 400 Bad Request: validation error or invalid request data
  • 401 Unauthorized: user is not logged in and should be redirected to login
  • 404 Not Found: requested prompt, profile or subscription was not found

The frontend handles failed requests with visible error states or redirects to login for unauthorized users.