Skip to content

Get All Prompts

The fetchAllPrompts endpoint allows you to retrieve all prompts associated with your account from the PromptTK API. This endpoint requires authentication via your user ID and API key.

import { PromptTK } from "@devvle/ptk-api-sdk";
const promptTK = new PromptTK({
userId: "your-user-id",
apiKey: "your-api-key",
});
async function fetchPrompts() {
try {
const response = await promptTK.fetchAllPrompts();
const data = await response.json();
console.log("All Prompts:", data);
} catch (error) {
console.error("Error fetching prompts:", error);
}
}
fetchPrompts();

Expected Output:

{
success: true,
message: 'Prompts retrieved successfully',
data: [
{
recordId: '<prompt-id-1>',
promptName: '<prompt-name-1>',
projectId: '<project-id-1>',
ownerId: '<your-user-id>',
createdAt: 0000000000000, // Timestamp in milliseconds
updatedAt: 0000000000000, // Timestamp in milliseconds
activeVersionId: '<latest-version-id-1>',
latestVersionNumber: 1 // Version number for the most recent version
},
{
recordId: '<prompt-id-2>',
promptName: '<prompt-name-2>',
projectId: '<project-id-2>',
ownerId: '<your-user-id>',
createdAt: 0000000000000, // Timestamp in milliseconds
updatedAt: 0000000000000, // Timestamp in milliseconds
activeVersionId: '<latest-version-id-2>',
latestVersionNumber: 3 // Version number for the most recent version
}
// ...more prompts
]
}

The fetchAllPrompts function makes a request to the following endpoint:

GET /v1/prompts
HeaderDescription
userIdYour unique user ID from PromptTK
apiKeyYour API key from PromptTK