Building Your First App

A step-by-step tutorial for building your first application with our platform.

Overview

In this tutorial, you'll build a simple application that:

  • Authenticates with the API
  • Retrieves product information
  • Displays data in a user-friendly format

Step 1: Project Setup

Create a new project:

bash
mkdir my-first-app cd my-first-app npm init -y npm install @your-sdk/core

Step 2: Initialize the Client

Create index.js:

javascript
import { Client } from '@your-sdk/core'; const client = new Client({ apiKey: process.env.API_KEY });

Step 3: Fetch Products

javascript
async function getProducts() { try { const products = await client.products.list(); return products.data; } catch (error) { console.error('Error fetching products:', error); return []; } }

Step 4: Display Data

javascript
async function displayProducts() { const products = await getProducts(); products.forEach(product => { console.log(`${product.name}: $${product.price}`); }); } displayProducts();

Step 5: Add Error Handling

javascript
async function getProducts() { try { const products = await client.products.list(); return { success: true, data: products.data }; } catch (error) { if (error.status === 401) { return { success: false, error: 'Authentication failed' }; } return { success: false, error: error.message }; } }

Next Steps


Is this page helpful?