Skip to main content
DocsAPI ReferenceMarketplace API
Back to docs

Marketplace API

Public content browsing, clone, reviews, facets

api
marketplace

Marketplace API Reference

Base path: /api/marketplace

The marketplace enables public content discovery, filtering, and cloning. Teachers can browse content published by other users, inspect curriculum metadata and quality scores, and clone content into their own library.


Endpoints

GET /api/marketplace/public-contents/facets

Return distinct filter values available across all public content. Use these values to populate filter dropdowns in the UI.

Auth: Authenticated user (JWT, authMiddleware)

Response (200):

{
  "success": true,
  "data": {
    "subjects": ["Mathematics", "Science", "English"],
    "grades": ["5th Grade", "8th Grade", "10th Grade"],
    "difficulties": ["easy", "medium", "hard"],
    "languages": ["en", "tr", "fr"],
    "frameworks": ["MEB 2024", "Common Core"]
  }
}

All arrays are sorted alphabetically and have null/empty values filtered out.

Errors:

StatusErrorCause
500Failed to load filtersInternal error

GET /api/marketplace/public-contents

Browse public content from other users with optional search and curriculum filters. Results are enriched with H5P metadata, curriculum data, quality scores, and author information.

Auth: Authenticated user (JWT, authMiddleware)

Query Parameters:

ParamTypeDefaultConstraints
searchstring--max 500 chars, free-text search
contentTypestring--max 100 chars, H5P content type filter
frameworkCodestring--max 50 chars
gradeCodestring--max 50 chars
subjectCodestring--max 100 chars
difficultyenum--easy, medium, hard
languagestring--max 10 chars
sortByenumnewestnewest, popular, quality
offsetinteger0min 0
limitinteger201-50

Response (200):

{
  "success": true,
  "data": [
    {
      "id": "42",
      "title": "Quadratic Equations Quiz",
      "mainLibrary": "H5P.QuestionSet",
      "contentTypeSlug": "question-set",
      "authorId": "uuid",
      "authorName": "Teacher A",
      "viewCount": 128,
      "publishedAt": "2025-01-10T08:00:00.000Z",
      "curriculum": {
        "frameworkName": "MEB 2024",
        "stageName": "Middle School",
        "gradeName": "8th Grade",
        "subjectName": "Mathematics",
        "topicNames": ["Equations"],
        "difficulty": "medium",
        "language": "tr"
      },
      "quality": {
        "overallScore": 92,
        "dimensions": {}
      }
    }
  ],
  "total": 47
}

Enrichment details:

  • Content owned by the authenticated user is excluded from results.
  • Content that cannot be read from H5P storage is silently excluded.
  • curriculum is null if the content has no curriculum metadata attached.
  • quality is null if no quality assessment has been performed.
  • authorName falls back to "Anonymous" if the author record is missing.

Errors:

StatusErrorCause
400Validation error: ...Invalid query parameters
500Failed to list public contentsInternal error

POST /api/marketplace/public-contents/:contentId/clone

Clone a public content item into the authenticated user's own library. Creates a full copy of the H5P content, ownership record, and curriculum metadata.

Auth: Teacher (JWT, teacherAuthMiddleware)

URL Parameters:

ParamTypeDescription
contentIdstringH5P content ID to clone

Request Body: None.

Process:

  1. Verifies the source content exists and has visibility: public.
  2. Checks the user's subscription quota (content limit).
  3. Copies H5P content (parameters + metadata) via h5pEditor.saveOrUpdateContent.
  4. Records ownership for the new content as private.
  5. Copies curriculum metadata from the source content to the clone.
  6. Increments the user's content usage counter.
  7. Increments the source content's viewCount (fire-and-forget).

Response (201):

{
  "success": true,
  "data": {
    "contentId": "99"
  }
}

Errors:

StatusErrorCause
401User not foundJWT valid but user not in DB
403Content limit reachedUser's subscription content quota exceeded
404Content not found or not publicContent ID does not exist or is not public
500Failed to clone contentInternal error

Referral System

The marketplace includes a referral service (referralService) for user acquisition. While the referral endpoints are defined in the referral service layer, they share the marketplace domain.

Referral Types

interface Referral {
  id: string;
  referrerId: string;
  referredEmail: string;
  referralCode: string;
  status: "pending" | "converted" | "expired";
  rewardType: "extra_credits" | "plan_discount";
  createdAt: Date;
  convertedAt: Date | null;
}

Referral Constants

ConstantValueDescription
PLATFORM_COMMISSION_RATE0.3Platform commission rate (30%)
DEFAULT_CURRENCYusdDefault currency
DEFAULT_PAGE_LIMIT20Default pagination limit
MAX_PAGE_LIMIT100Maximum pagination limit
MIN_RATING1Minimum review rating
MAX_RATING5Maximum review rating
REFERRAL_CODE_LENGTH8Generated referral code length (hex characters)
REFERRAL_EXTRA_CREDITS5AI generation credits awarded per successful referral

Referral Flow

  1. Generate link: Each user gets a unique referral code stored in creatiq_users.referral_code. The link format is {APP_URL}/login?ref={CODE}.
  2. Convert: When a new user signs up via a referral link, the referral is recorded as converted. The referrer receives REFERRAL_EXTRA_CREDITS (5) additional AI generation credits.
  3. Stats: Referrers can view their total, converted, and pending referral counts along with total rewards earned.

Data Model

Public Content List Item

FieldTypeDescription
idstringH5P content ID
titlestringContent title from H5P metadata
mainLibrarystringH5P library name (e.g., H5P.QuestionSet)
contentTypeSlugstringSlugified content type (e.g., question-set)
authorIdstringAuthor's user ID
authorNamestringAuthor's display name
viewCountintegerNumber of views/clones
publishedAtISO 8601When the content was published
curriculumobject or nullCurriculum metadata (see curriculum API)
qualityobject or nullQuality assessment summary
Back to docsdocs/product/api/marketplace.md