JavaScript SDK

Browser-only JavaScript SDK for the AIDP API. No build tools required!

Installation

<script src="https://cdn.aidp.dev/sdk/v1/aidp.min.js"></script>

npm (for bundlers)

npm install @aidp/sdk-browser

Quick Start

<!DOCTYPE html>
<html>
  <head>
    <title>AIDP Search</title>
    <script src="https://cdn.aidp.dev/sdk/v1/aidp.min.js"></script>
  </head>
  <body>
    <input id="search" type="text" placeholder="Search businesses..." />
    <div id="results"></div>

    <script>
      const client = new AIDP.Client({
        apiKey: 'your-api-key',
      });

      document.getElementById('search').addEventListener('input', async (e) => {
        const query = e.target.value;
        if (!query) return;

        const results = await client.search({
          query,
          location: { lat: 45.5231, lon: -122.6765, distance: '5km' },
        });

        const html = results.data.businesses
          .map((b) => `<div>${b.name} - ${b.category}</div>`)
          .join('');

        document.getElementById('results').innerHTML = html;
      });
    </script>
  </body>
</html>

Configuration

Basic Configuration

Advanced Configuration


API Methods

Search for businesses using natural language queries.

Get Business

Get detailed information about a specific business.

Browse the business directory with filters.


Error Handling


Examples

Search with Autocomplete

Search with Map

Pagination


Browser Compatibility

The SDK works in all modern browsers:

  • ✅ Chrome 90+

  • ✅ Firefox 88+

  • ✅ Safari 14+

  • ✅ Edge 90+

Not supported:

  • ❌ Internet Explorer


Security Best Practices

Never Expose API Keys

Don't hardcode API keys in client-side code:

Do use a backend proxy:

Use Public API Keys

For client-side usage, use public API keys with restricted permissions:


Performance Tips

Debounce Search Input

Cache Results


Need Help?

Last updated