> ## Documentation Index
> Fetch the complete documentation index at: https://docs.joinrefine.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get Refine search working in your app in 5 minutes

## Prerequisites

Before you begin, you'll need:

* A Refine account with an API key
* An organization ID and catalog ID from your dashboard
* A product catalog uploaded to Refine

<Note>
  Don't have a catalog yet? See [Creating a Catalog](/api-reference/catalog-operations/create-catalog) to set one up via API, or use the dashboard.
</Note>

## Install the SDK

<CodeGroup>
  ```bash npm theme={null}
  npm install @refine-ai/sdk
  ```

  ```bash yarn theme={null}
  yarn add @refine-ai/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @refine-ai/sdk
  ```
</CodeGroup>

## Initialize the Client

```typescript theme={null}
import { Refine } from '@refine-ai/sdk';

const refine = new Refine({
  apiKey: process.env.REFINE_API_KEY,
  organizationId: 'org_abc123',
  catalogId: 'cat_xyz789'
});
```

<Warning>
  Never expose your API key in client-side code for production applications. Use environment variables and consider server-side rendering for sensitive operations.
</Warning>

## Make Your First Search

```typescript theme={null}
const results = await refine.search.text({
  query: 'blue running shoes',
  topK: 12
});

console.log(`Found ${results.totalResults} products`);

results.results.forEach(product => {
  console.log(`${product.title} - $${product.price}`);
});
```

## Display Results

Here's a complete example rendering search results:

```typescript theme={null}
import { Refine } from '@refine-ai/sdk';

const refine = new Refine({
  apiKey: process.env.REFINE_API_KEY,
  organizationId: 'org_abc123',
  catalogId: 'cat_xyz789'
});

async function search(query: string) {
  const results = await refine.search.text({
    query,
    topK: 24,
    visualWeight: 0.4
  });

  // Track the search for analytics
  const searchContext = refine.events.trackSearch(
    query,
    results.results,
    { surface: 'search_results', totalResults: results.totalResults }
  );

  // Render results
  const container = document.getElementById('results');
  container.innerHTML = results.results.map((product, index) => `
    <div class="product" data-id="${product.productId}" data-position="${index}">
      <img src="${product.imageUrl}" alt="${product.title}" />
      <h3>${product.title}</h3>
      <p>$${product.price}</p>
    </div>
  `).join('');

  // Track clicks
  container.querySelectorAll('.product').forEach(el => {
    el.addEventListener('click', () => {
      const productId = el.dataset.id;
      const position = parseInt(el.dataset.position);
      searchContext.trackClick(productId, position);
    });
  });
}
```

## Track Conversions

When a user makes a purchase, track the conversion to close the analytics loop:

```typescript theme={null}
refine.events.trackPurchase({
  orderId: 'order_12345',
  value: 149.99,
  currency: 'USD',
  items: [
    { itemId: 'sku_001', quantity: 1, unitPrice: 99.99 },
    { itemId: 'sku_002', quantity: 2, unitPrice: 25.00 }
  ]
});
```

## What's Next?

<CardGroup cols={2}>
  <Card title="Text Search" icon="magnifying-glass" href="/sdk/search/text-search">
    Advanced text search with filters and sorting
  </Card>

  <Card title="Image Search" icon="image" href="/sdk/search/image-search">
    Search by uploading images
  </Card>

  <Card title="Recommendations" icon="wand-magic-sparkles" href="/sdk/recommendations/overview">
    Add product recommendations
  </Card>

  <Card title="Event Tracking" icon="chart-line" href="/sdk/events/overview">
    Complete event tracking guide
  </Card>
</CardGroup>
