AgentSkillsCN

stackey-api

当用户提及“Stackey API”“区块端点”“收藏端点”“区块媒体”“Stackey后端”,或在编写调用StackeyBackend Supabase Edge Functions的代码时,可使用此技能。

SKILL.md
--- frontmatter
name: stackey-api
description: Use this skill when users mention "Stackey API", "blocks endpoint", "favorites endpoint", "block-media", "Stackey backend", or when working on code that calls the StackeyBackend Supabase Edge Functions.
version: 1.0.0
context: fork

Stackey Backend API

REST API reference for the StackeyBackend Supabase Edge Functions. All endpoints are served from Supabase Edge Functions.

Base URL

  • Local: http://127.0.0.1:54321/functions/v1
  • Production: https://<project-ref>.supabase.co/functions/v1

Authentication Levels

LevelDescriptionHeader Required
PublicNo authenticationNone
UserValid JWT tokenAuthorization: Bearer <token>
AdminJWT + role='admin'Authorization: Bearer <token>

Endpoints Overview

EndpointMethodsAuthPurpose
/blocksGETPublicList blocks with filtering
/blocksPOSTAdminCreate a block
/blocks/:idGETPublicGet single block
/blocks/:idPATCHAdminUpdate a block
/blocks/:idDELETEAdminDelete a block
/users/meGET, PATCHUserUser profile
/favoritesGET, POSTUserList/add favorites
/favorites/:blockIdDELETEUserRemove favorite
/block-mediaPOSTAdminUpload media
/block-media/:idDELETEAdminDelete media

Quick Examples

List public blocks

bash
curl "http://127.0.0.1:54321/functions/v1/blocks"

Get user profile (requires auth)

bash
curl -H "Authorization: Bearer $TOKEN" \
  "http://127.0.0.1:54321/functions/v1/users/me"

Create a block (admin only)

bash
curl -X POST \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "Zoom In", "tags": ["camera", "zoom"], "is_public": true}' \
  "http://127.0.0.1:54321/functions/v1/blocks"

Response Format

All endpoints return JSON with consistent structure:

Success:

json
{
  "blocks": [...],
  "total": 50
}

Error:

json
{
  "error": "Error message"
}

Common Headers

All requests should include:

  • Content-Type: application/json (for POST/PATCH)
  • Authorization: Bearer <token> (for authenticated endpoints)

Additional Resources

For detailed endpoint documentation with all parameters and response schemas, see references/endpoints.md.