|
| 1 | +import type { EndpointProps } from "~/components/docs/api-endpoint-card"; |
| 2 | + |
| 3 | +/** Search + Skill endpoint definitions for the API reference page. */ |
| 4 | + |
| 5 | +export const SEARCH_ENDPOINTS: EndpointProps[] = [ |
| 6 | + { |
| 7 | + id: "search-get", |
| 8 | + method: "GET", |
| 9 | + path: "/api/search?q=<query>", |
| 10 | + auth: "Optional", |
| 11 | + description: "Search skills via hybrid keyword + semantic engine. Authenticated users get personalized favorite boost.", |
| 12 | + params: [ |
| 13 | + { name: "q", type: "string", required: true, description: "Search query" }, |
| 14 | + { name: "category", type: "string", required: false, description: "Filter by category" }, |
| 15 | + { name: "is_paid", type: "string", required: false, description: '"true" or "false"' }, |
| 16 | + { name: "limit", type: "number", required: false, description: "Max results (max 100)", default: "20" }, |
| 17 | + ], |
| 18 | + responseExample: `{ |
| 19 | + "results": [ |
| 20 | + { |
| 21 | + "id": "uuid", |
| 22 | + "name": "Skill Name", |
| 23 | + "slug": "skill-name", |
| 24 | + "description": "...", |
| 25 | + "category": "development", |
| 26 | + "avg_rating": 8.5, |
| 27 | + "install_count": 1200, |
| 28 | + "github_stars": 450, |
| 29 | + "final_score": 0.82, |
| 30 | + "rrf_score": 0.031, |
| 31 | + "semantic_rank": 2, |
| 32 | + "keyword_rank": 5 |
| 33 | + } |
| 34 | + ], |
| 35 | + "count": 1 |
| 36 | +}`, |
| 37 | + notes: ['Returns empty results if no "q" param provided.'], |
| 38 | + errors: [ |
| 39 | + { status: 400, body: "Query parameter is required", cause: "Missing or non-string query" }, |
| 40 | + { status: 500, body: "Search failed", cause: "Internal error" }, |
| 41 | + ], |
| 42 | + }, |
| 43 | + { |
| 44 | + id: "search-post", |
| 45 | + method: "POST", |
| 46 | + path: "/api/search", |
| 47 | + auth: "Optional", |
| 48 | + description: "Same search via JSON body. Preferred for API integrations.", |
| 49 | + params: [ |
| 50 | + { name: "query", type: "string", required: true, description: "Search query" }, |
| 51 | + { name: "category", type: "string", required: false, description: "Filter by category" }, |
| 52 | + { name: "is_paid", type: "boolean", required: false, description: "Filter free/paid" }, |
| 53 | + { name: "limit", type: "number", required: false, description: "Max results (max 100)", default: "20" }, |
| 54 | + ], |
| 55 | + requestExample: `{ |
| 56 | + "query": "kubernetes deploy", |
| 57 | + "category": "devops", |
| 58 | + "is_paid": false, |
| 59 | + "limit": 20 |
| 60 | +}`, |
| 61 | + responseExample: `Same as GET /api/search`, |
| 62 | + errors: [ |
| 63 | + { status: 400, body: "Query parameter is required", cause: "Missing or non-string query" }, |
| 64 | + { status: 500, body: "Search failed", cause: "Internal error" }, |
| 65 | + ], |
| 66 | + }, |
| 67 | +]; |
| 68 | + |
| 69 | +export const SKILL_ENDPOINTS: EndpointProps[] = [ |
| 70 | + { |
| 71 | + id: "skill-detail", |
| 72 | + method: "GET", |
| 73 | + path: "/api/skills/:slug", |
| 74 | + auth: "Optional", |
| 75 | + description: "Fetch full skill details with reviews and rating summary. Authenticated users see isFavorited status.", |
| 76 | + responseExample: `{ |
| 77 | + "skill": { "id": "uuid", "name": "...", "slug": "...", "content": "...", ... }, |
| 78 | + "reviews": [{ "id": "...", "content": "...", "created_at": 1707955200000 }], |
| 79 | + "isFavorited": false, |
| 80 | + "ratingSummary": { "avgRating": 8.5, "ratingCount": 42 } |
| 81 | +}`, |
| 82 | + errors: [ |
| 83 | + { status: 400, body: "Skill slug is required", cause: "Missing slug param" }, |
| 84 | + { status: 404, body: "Skill not found", cause: "Invalid slug" }, |
| 85 | + ], |
| 86 | + }, |
| 87 | + { |
| 88 | + id: "skill-rate", |
| 89 | + method: "POST", |
| 90 | + path: "/api/skills/:slug/rate", |
| 91 | + auth: "Session required", |
| 92 | + description: "Rate a skill (0-10 scale). Upserts — re-rating updates existing score.", |
| 93 | + params: [ |
| 94 | + { name: "score", type: "number", required: true, description: "Rating 0-10 inclusive" }, |
| 95 | + ], |
| 96 | + requestExample: `{ "score": 8.5 }`, |
| 97 | + responseExample: `{ "success": true, "avg_rating": 8.2, "rating_count": 43 }`, |
| 98 | + errors: [ |
| 99 | + { status: 400, body: "Score must be a number between 0 and 10", cause: "Invalid score value" }, |
| 100 | + { status: 401, body: "Authentication required", cause: "Not logged in" }, |
| 101 | + { status: 404, body: "Skill not found", cause: "Invalid slug" }, |
| 102 | + ], |
| 103 | + }, |
| 104 | + { |
| 105 | + id: "skill-review-get", |
| 106 | + method: "GET", |
| 107 | + path: "/api/skills/:slug/review", |
| 108 | + auth: "None", |
| 109 | + description: "List reviews for a skill, newest first (max 100).", |
| 110 | + responseExample: `{ |
| 111 | + "reviews": [ |
| 112 | + { |
| 113 | + "id": "review-...", |
| 114 | + "content": "Excellent skill for Kubernetes deployment", |
| 115 | + "is_agent": false, |
| 116 | + "created_at": 1707955200000 |
| 117 | + } |
| 118 | + ] |
| 119 | +}`, |
| 120 | + errors: [{ status: 404, body: "Skill not found", cause: "Invalid slug" }], |
| 121 | + }, |
| 122 | + { |
| 123 | + id: "skill-review-post", |
| 124 | + method: "POST", |
| 125 | + path: "/api/skills/:slug/review", |
| 126 | + auth: "Session required", |
| 127 | + description: "Submit a text review for a skill.", |
| 128 | + params: [ |
| 129 | + { name: "content", type: "string", required: true, description: "1-2000 characters" }, |
| 130 | + ], |
| 131 | + requestExample: `{ "content": "This skill saved me hours of work!" }`, |
| 132 | + responseExample: `{ "success": true, "review": { "id": "review-...", "content": "...", ... } }`, |
| 133 | + errors: [ |
| 134 | + { status: 400, body: "Review content cannot be empty", cause: "Empty content" }, |
| 135 | + { status: 400, body: "Cannot exceed 2000 characters", cause: "Too long" }, |
| 136 | + { status: 401, body: "Authentication required", cause: "Not logged in" }, |
| 137 | + { status: 404, body: "Skill not found", cause: "Invalid slug" }, |
| 138 | + ], |
| 139 | + }, |
| 140 | + { |
| 141 | + id: "skill-favorite", |
| 142 | + method: "POST", |
| 143 | + path: "/api/skills/:slug/favorite", |
| 144 | + auth: "Session required", |
| 145 | + description: "Toggle favorite status. Adds if not favorited, removes if already favorited.", |
| 146 | + responseExample: `{ "favorited": true }`, |
| 147 | + notes: ["favorited: true = added, false = removed. No request body needed."], |
| 148 | + errors: [ |
| 149 | + { status: 401, body: "Authentication required", cause: "Not logged in" }, |
| 150 | + { status: 404, body: "Skill not found", cause: "Invalid slug" }, |
| 151 | + ], |
| 152 | + }, |
| 153 | +]; |
0 commit comments