Node.js Client Library

Official Node.js client library for PromptHub API with TypeScript support.

What's Coming

TypeScript Support

Full TypeScript definitions with auto-completion and type safety.

Easy Installation

Simple npm install with zero configuration required.

Usage Preview

Here's what the Node.js client library will look like when it's ready:

// Installation
npm install @prompthub/client

// Usage
import { PromptHub } from '@prompthub/client';

const client = new PromptHub({
  apiKey: 'pm-your-api-key-here',
  baseUrl: 'https://your-domain.com'
});

// Get a prompt
const prompt = await client.prompts.get('welcome_message');
console.log(prompt.content);

// With error handling
try {
  const prompt = await client.prompts.get('welcome_message');
  console.log(prompt.content);
} catch (error) {
  console.error('Error:', error.message);
}

Current Alternative

While we're working on the official client library, you can use the REST API directly:

// Using fetch (built-in)
async function getPrompt(promptId) {
  const response = await fetch(`/api/v1/prompts/${promptId}`, {
    headers: {
      'Authorization': 'Bearer pm-your-api-key-here',
      'Content-Type': 'application/json'
    }
  });
  
  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  }
  
  const data = await response.json();
  return data.prompt;
}

// Using axios
import axios from 'axios';

const api = axios.create({
  baseURL: 'https://your-domain.com',
  headers: {
    'Authorization': 'Bearer pm-your-api-key-here'
  }
});

const prompt = await api.get('/api/v1/prompts/welcome_message');
console.log(prompt.data.prompt.content);

Get Notified

Want to be notified when the Node.js client library is ready?