Back to Blog
Tutorials

Getting Started with the Fastnotry API

A step-by-step tutorial for integrating Fastnotry into your applications using our SDK.

DR

David Rodriguez

Developer Advocate

January 3, 202612 min read
Share:

Getting Started with the Fastnotry API

This tutorial will walk you through integrating Fastnotry into your application. By the end, you'll be able to execute prompts, manage versions, and track usage programmatically.

Prerequisites

Before starting, ensure you have:

  • A Fastnotry account (sign up at fastnotry.com)
  • Node.js 18+ installed
  • Basic familiarity with JavaScript/TypeScript
  • Step 1: Install the SDK

    Install the Fastnotry SDK using npm or yarn:

    npm install @fastnotry/sdk

    # or

    yarn add @fastnotry/sdk

    Step 2: Configure Authentication

    Get your API key from the Fastnotry dashboard under Settings > API Keys.

    import { Fastnotry } from '@fastnotry/sdk';

    const client = new Fastnotry({

    apiKey: 'your-api-key-here',

    });

    Step 3: Execute Your First Prompt

    Let's execute a simple prompt:

    async function generateProductDescription() {

    const response = await client.execute({

    promptId: 'product-description',

    variables: {

    productName: 'Smart Watch Pro',

    features: ['heart rate monitor', 'GPS', 'water resistant'],

    targetAudience: 'fitness enthusiasts',

    },

    });

    console.log(response.output);

    console.log(`Tokens used: ${response.usage.totalTokens}`);

    }

    Step 4: Working with Versions

    Fastnotry supports versioning for all prompts:

    // Get the latest version

    const latest = await client.prompts.get('product-description');

    // Get a specific version

    const v2 = await client.prompts.get('product-description', { version: 2 });

    // List all versions

    const versions = await client.prompts.listVersions('product-description');

    Step 5: Streaming Responses

    For long-form content, use streaming to improve user experience:

    const stream = await client.execute({

    promptId: 'blog-post-generator',

    variables: { topic: 'AI in Healthcare' },

    stream: true,

    });

    for await (const chunk of stream) {

    process.stdout.write(chunk.content);

    }

    Step 6: Error Handling

    Implement proper error handling:

    import { FastnotryError, RateLimitError } from '@fastnotry/sdk';

    try {

    const response = await client.execute({ promptId: 'my-prompt' });

    } catch (error) {

    if (error instanceof RateLimitError) {

    console.log(`Rate limited. Retry after ${error.retryAfter}s`);

    } else if (error instanceof FastnotryError) {

    console.error(`API Error: ${error.message}`);

    } else {

    throw error;

    }

    }

    Step 7: Webhooks (Optional)

    Set up webhooks to receive notifications:

    // In your webhook handler

    app.post('/webhooks/fastnotry', (req, res) => {

    const event = req.body;

    switch (event.type) {

    case 'prompt.executed':

    console.log(`Prompt executed: ${event.data.promptId}`);

    break;

    case 'prompt.updated':

    console.log(`Prompt updated: ${event.data.promptId}`);

    break;

    }

    res.status(200).send('OK');

    });

    Best Practices

    1. **Store API keys securely** - Never commit keys to version control

    2. **Implement retries** - Handle transient failures gracefully

    3. **Monitor usage** - Track token consumption to manage costs

    4. **Use caching** - Cache responses when appropriate

    5. **Test thoroughly** - Use our sandbox environment for testing

    Next Steps

    Now that you're up and running, explore:

  • [Advanced Configuration](/docs/advanced-config)
  • [Prompt Templates](/docs/templates)
  • [Analytics Dashboard](/docs/analytics)
  • [Team Management](/docs/teams)
  • Have questions? Join our Discord community or contact support.

    DR

    David Rodriguez

    Developer Advocate

    David helps developers get the most out of Fastnotry through tutorials, documentation, and community support.