Prompts API

Endpoints for retrieving, creating, updating, and deleting prompts.

GET List All Prompts

GET
/api/v1/prompts

Retrieve a list of all prompts, with optional filtering.

Query Parameters

ParameterTypeRequiredDescriptionExample
categorystring
Optional
Filter prompts by categoryAI
tagsstring
Optional
Filter prompts by tags (comma-separated)chatgpt,openai
typestring
Optional
Filter prompts by type (static or dynamic)dynamic
userstring
Optional
Filter prompts by creator usernamedeveloper01
limitnumber
Optional
Limit the number of results (default: 20, max: 100)10
offsetnumber
Optional
Offset for pagination (default: 0)20
sortstring
Optional
Sort by field (created_at, title)created_at
orderstring
Optional
Sort order (asc, desc)desc

Example Response

200
JSON
{
  "status": "success",
  "count": 2,
  "total": 50,
  "prompts": [
    {
      "id": 1,
      "title": "Chatbot Prompts",
      "content": "A collection of prompts for building advanced chatbots. Use these to create more engaging and helpful AI assistants that can handle a wide range of {{ topic }} queries and provide {{ tone }} responses.",
      "category": "AI",
      "tags": [
        "chatgpt",
        "openai"
      ],
      "type": "dynamic",
      "created_at": "2025-04-17",
      "user": "developer01",
      "providerCompatibility": [
        "gpt-4",
        "claude-2"
      ],
      "difficulty": "intermediate"
    },
    {
      "id": 4,
      "title": "Code Review Checklist",
      "content": "Use this checklist when reviewing code:\n\n1. Is the code well-documented?\n2. Are there appropriate unit tests?\n3. Does it follow our style guide?\n4. Are there any potential security vulnerabilities?\n5. Is error handling implemented correctly?\n6. Are there any performance concerns?\n7. Is the code DRY (Don't Repeat Yourself)?\n8. Are variable and function names descriptive?\n\nProvide specific examples and suggestions for improvement.",
      "category": "Programming",
      "tags": [
        "code-review",
        "best-practices"
      ],
      "type": "static",
      "created_at": "2025-04-12",
      "user": "developer01",
      "providerCompatibility": [
        "gpt-3.5",
        "gpt-4",
        "claude-2"
      ],
      "difficulty": "intermediate"
    }
  ]
}

Example Request

BASH
curl -X GET "https://promptai.trymagic.xyz/api/v1/prompts?category=AI&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

GET Get a Specific Prompt

GET
/api/v1/prompts/:id

Retrieve a specific prompt by its ID.

Path Parameters

ParameterTypeRequiredDescriptionExample
idstring | number
Required
The ID of the prompt to retrieve1

Query Parameters (for Dynamic Prompts)

For dynamic prompts, you can provide variable values as query parameters. These will be used to process the prompt template.

ParameterTypeRequiredDescriptionExample
[variable_name]string
Optional
Value for the variable in the prompttopic=AI&tone=friendly

Example Response

200
JSON
{
  "status": "success",
  "prompt": {
    "id": 1,
    "title": "Chatbot Prompts",
    "content": "A collection of prompts for building advanced chatbots. Use these to create more engaging and helpful AI assistants that can handle a wide range of {{ topic }} queries and provide {{ tone }} responses.",
    "category": "AI",
    "tags": [
      "chatgpt",
      "openai"
    ],
    "type": "dynamic",
    "created_at": "2025-04-17",
    "user": "developer01",
    "providerCompatibility": [
      "gpt-4",
      "claude-2"
    ],
    "difficulty": "intermediate",
    "variables": [
      "topic",
      "tone"
    ]
  }
}

Example Request

BASH
# Basic request
curl -X GET "https://promptai.trymagic.xyz/api/v1/prompts/1" \
  -H "Authorization: Bearer YOUR_API_KEY"

# With dynamic variables
curl -X GET "https://promptai.trymagic.xyz/api/v1/prompts/1?topic=AI&tone=friendly" \
  -H "Authorization: Bearer YOUR_API_KEY"

GET Search Prompts

GET
/api/v1/prompts/search

Search for prompts using a query string.

Query Parameters

ParameterTypeRequiredDescriptionExample
querystring
Required
Search query stringchatbot
limitnumber
Optional
Limit the number of results (default: 20, max: 100)10
offsetnumber
Optional
Offset for pagination (default: 0)20
categorystring
Optional
Filter search results by categoryAI
typestring
Optional
Filter search results by type (static or dynamic)dynamic

Example Response

200
JSON
{
  "status": "success",
  "count": 1,
  "total": 1,
  "prompts": [
    {
      "id": 1,
      "title": "Chatbot Prompts",
      "content": "A collection of prompts for building advanced chatbots. Use these to create more engaging and helpful AI assistants that can handle a wide range of {{ topic }} queries and provide {{ tone }} responses.",
      "category": "AI",
      "tags": [
        "chatgpt",
        "openai"
      ],
      "type": "dynamic",
      "created_at": "2025-04-17",
      "user": "developer01",
      "providerCompatibility": [
        "gpt-4",
        "claude-2"
      ],
      "difficulty": "intermediate"
    }
  ]
}

Example Request

BASH
curl -X GET "https://promptai.trymagic.xyz/api/v1/prompts/search?query=chatbot&category=AI" \
  -H "Authorization: Bearer YOUR_API_KEY"