API Reference

Access your SpacePrompts prompts using your personal API key. Available on the Pro and Team plans.

Authentication

All requests must include your API key in the X-API-Key header. You can generate or view your API key from your Account Settings.

Header
X-API-Key: {YOUR_API_KEY}
Never share your API key or commit it to public repositories.

Base URL

https://services.spaceprompts.com/api/v2

Rate Limits

All endpoints are rate limited to 60 requests per minute per API key. Requests exceeding this limit will receive a 429 Too Many Requests response.

Endpoints

GET/prompts/{slug}

Retrieve a prompt by its slug. Only returns prompts owned by the API key holder.

Path Parameters

ParameterTypeDefaultDescription
slugstringThe unique slug of the prompt

Query Parameters

ParameterTypeDefaultDescription
response_formatstringjsonResponse format. Use text to return the system prompt as plain text only.

Example Requests

JSON (default)

cURL
curl -X GET "https://services.spaceprompts.com/api/v2/prompts/{slug}"   -H "X-API-Key: {YOUR_API_KEY}"
JavaScript / TypeScript
const response = await fetch('https://services.spaceprompts.com/api/v2/prompts/{slug}', {
  headers: {
    'X-API-Key': '{YOUR_API_KEY}',
  },
})

const data = await response.json()
console.log(data.system_prompt)

Text only

cURL
curl -X GET "https://services.spaceprompts.com/api/v2/prompts/{slug}?response_format=text"   -H "X-API-Key: {YOUR_API_KEY}"
JavaScript / TypeScript
const response = await fetch('https://services.spaceprompts.com/api/v2/prompts/{slug}?response_format=text', {
  headers: {
    'X-API-Key': '{YOUR_API_KEY}',
  },
})

const text = await response.text()
console.log(text)

Example Response

200 OK
{
  "title": "AI Code Reviewer - Security & Performance",
  "category": "Technology",
  "tags": ["code-review", "debugging", "code-quality", "software-engineering"],
  "system_prompt": "You are an expert code reviewer. Analyze the provided code and deliver a structured, actionable review focused on functionality, security, performance, and maintainability."
}
POST/prompts/run/{slug}

Run a prompt against the DeepSeek AI model. Uses the prompt's system_prompt as the system message and your query as the user message.

Request Body

FieldTypeRequiredDescription
querystringYesThe user message to send to the AI model

Query Parameters

ParameterTypeDefaultDescription
response_formatstringjsonResponse format. Use text to return the AI result as plain text only.

Example Requests

JSON (default)

cURL
curl -X POST "https://services.spaceprompts.com/api/v2/prompts/run/{slug}"   -H "X-API-Key: {YOUR_API_KEY}"   -H "Content-Type: application/json"   -d "{"query": "Target job title: Software Engineer Current role: Junior Developer with 2 years experience in React and Node.js"}"
JavaScript / TypeScript
const response = await fetch('https://services.spaceprompts.com/api/v2/prompts/run/{slug}', {
  method: 'POST',
  headers: {
    'X-API-Key': '{YOUR_API_KEY}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    query: 'Target job title: Software Engineer Current role: Junior Developer with 2 years experience in React and Node.js',
  }),
})

const data = await response.json()
console.log(data.result)

Text only

cURL
curl -X POST "https://services.spaceprompts.com/api/v2/prompts/run/{slug}?response_format=text"   -H "X-API-Key: {YOUR_API_KEY}"   -H "Content-Type: application/json"   -d "{"query": "Target job title: Software Engineer Current role: Junior Developer with 2 years experience in React and Node.js"}"
JavaScript / TypeScript
const response = await fetch('https://services.spaceprompts.com/api/v2/prompts/run/{slug}?response_format=text', {
  method: 'POST',
  headers: {
    'X-API-Key': '{YOUR_API_KEY}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    query: 'Target job title: Software Engineer Current role: Junior Developer with 2 years experience in React and Node.js',
  }),
})

const text = await response.text()
console.log(text)

Example Response

200 OK
{
  "model": "deepseek-chat",
  "result": "John Doe, [email protected]. Software Engineer with 2 years of experience building scalable web applications using React and Node.js. Proven ability to deliver high-quality code, optimize performance, and collaborate within agile teams."
}
GET/token-count

Count tokens for a given prompt and model using model-specific tokenizers.

Query Parameters

ParameterTypeRequiredDescription
promptstringYesThe text to count tokens for
modelstringYesOne of: openai, claude, gemini, deepseek

Supported Models

AliasModel
openaiGPT-5.4
claudeClaude Sonnet 4.6
geminiGemini 3.1 Pro Preview
deepseekDeepSeek V3.2

Example Requests

cURL
curl -X GET "https://services.spaceprompts.com/api/v2/token-count?prompt=You+are+an+expert+code+reviewer&model=gemini"   -H "X-API-Key: {YOUR_API_KEY}"
JavaScript / TypeScript
const response = await fetch('https://services.spaceprompts.com/api/v2/token-count?prompt=You+are+an+expert+code+reviewer&model=gemini', {
  headers: {
    'X-API-Key': '{YOUR_API_KEY}',
  },
})

const data = await response.json()
console.log(data.token_count)

Example Response

200 OK
{
  "model": "gemini",
  "token_count": 9,
  "character_count": 38
}
POST/prompts/enhance

Enhance a prompt using AI. Analyzes the prompt for issues and returns an improved version. Uses the same enhancement quota as the dashboard.

Request Body

FieldTypeRequiredDescription
promptstringYesThe prompt text to enhance (max 3,000 characters)

Query Parameters

ParameterTypeDefaultDescription
response_formatstringjsonResponse format. Use text to return only the enhanced prompt as plain text.

Example Requests

JSON (default)

cURL
curl -X POST "https://services.spaceprompts.com/api/v2/prompts/enhance"   -H "X-API-Key: {YOUR_API_KEY}"   -H "Content-Type: application/json"   -d '{"prompt": "You are an expert code reviewer. Analyze the provided code and deliver a structured, actionable review focused on functionality,
   security, performance, and maintainability."}'
JavaScript / TypeScript
const response = await fetch('https://services.spaceprompts.com/api/v2/prompts/enhance', {
  method: 'POST',
  headers: {
    'X-API-Key': '{YOUR_API_KEY}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    prompt: 'You are an expert code reviewer. Analyze the code and provide actionable feedback.',
  }),
})

const data = await response.json()
console.log(data.enhanced_prompt)

Text only

cURL
curl -X POST "https://services.spaceprompts.com/api/v2/prompts/enhance?response_format=text"   -H "X-API-Key: {YOUR_API_KEY}"   -H "Content-Type: application/json"   -d '{"prompt": "You are an expert code reviewer. Analyze the provided code and deliver a structured, actionable review focused on functionality,
   security, performance, and maintainability."}'
JavaScript / TypeScript
const response = await fetch('https://services.spaceprompts.com/api/v2/prompts/enhance?response_format=text', {
  method: 'POST',
  headers: {
    'X-API-Key': '{YOUR_API_KEY}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    prompt: 'You are an expert code reviewer. Analyze the code and provide actionable feedback.',
  }),
})

const text = await response.text()
console.log(text)

Example Response

200 OK
{
  "enhanced_prompt": "You are an expert code reviewer. Analyze the provided code and deliver a structured, actionable review focused on functionality, security, performance, and maintainability."
}

Response Status Codes

CodeDescription
200Successful response
401Missing or invalid API key
403API access requires a Pro plan
404Prompt not found
429Rate limit exceeded — 60 requests/minute per API key