Search API

Learn how to search for prompts using the PromptAI API.

GET Search Prompts

GET
/api/v1/prompts/search

Search for prompts using a query string and optional filters.

Query Parameters

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

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-15",
      "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"

Search Best Practices

Optimizing Search Queries

  • Use specific keywords that are likely to appear in the prompt title or content
  • Keep search terms concise and relevant
  • Use filters to narrow down results by category, tags, or type
  • For multi-word searches, the API will match prompts containing any of the words

Pagination

When dealing with large result sets, use pagination to improve performance:

  • Use the limit parameter to control the number of results per page
  • Use the offset parameter to navigate through pages
  • The response includes a total field to help calculate the total number of pages

Rate Limiting Considerations

Search operations are subject to the same rate limits as other API endpoints:

  • Implement caching for frequent searches to reduce API calls
  • Consider implementing debouncing for search inputs in user interfaces
  • Monitor rate limit headers to avoid hitting limits