# Agent Media Tools — JavaScript SDK

[![status](https://img.shields.io/badge/status-source%20preview-yellow)](https://agentmediatools.com/integrations)
[![Node 18+](https://img.shields.io/badge/node-18+-green)](https://nodejs.org)

JavaScript/TypeScript client for [Agent Media Tools](https://agentmediatools.com) — image processing, PDF manipulation, AI generation, web scraping, QR codes, pastebin, and 70+ API endpoints.

## Installation

The npm package is not published yet. For local review from this repository:

```bash
cd sdk/javascript
npm ci
```

Registry installation instructions will be added after the official package is published.

## Quick Start

### Free tier — no API key needed

```javascript
import { Client } from '@agentmediatools/sdk';
// or: const { Client } = require('@agentmediatools/sdk');

const client = new Client();

// 🖼️ Resize an image
const result = await client.image.resize(fs.readFileSync('photo.jpg'), {
  width: 800,
  format: 'webp'
});
fs.writeFileSync('photo.webp', result);

// 🔗 Generate a QR code
const qr = await client.qrcode.generate('https://example.com');
fs.writeFileSync('qrcode.png', qr);

// 🛠️ Generate a UUID
console.log(await client.dev.uuid());
```

### With API key — for premium endpoints

```javascript
import { Client } from '@agentmediatools/sdk';

const client = new Client({ apiKey: 'mt_your_key_here' });

// 🌐 Scrape a web page
const content = await client.scrape('https://example.com');
console.log(content);

// 🎨 Generate an AI image
const result = await client.ai.generateImage('a serene mountain lake at sunset', {
  model: 'flux',
  wait: true
});
console.log(result.result.images[0].url);
```

## Namespaces

| Namespace | Description |
|-----------|-------------|
| `client.image.*` | Image processing — resize, convert, compress, analyze, crop, batch |
| `client.pdf.*` | PDF tools — merge, split, compress, rotate, toText, toImages, fromImages |
| `client.ai.*` | AI generation — generateImage, generateVideo, transcribe, removeBg, ocr |
| `client.web.*` | Web page tools — screenshot, htmlToPdf, articleExtract |
| `client.intel.*` | Intelligence — dnsLookup, sslCheck, ogPreview, regexTest, colorConvert |
| `client.tools.*` | Utilities — csvConvert, caseConvert, slugify, zipFiles, videoInfo |
| `client.agent.*` | Agent — identity, approvals, receipts, jobs, heartbeat, shop, provisioning |
| `client.mailbox.*` | Mailbox — create, post, poll, peek, claim |
| `client.artifact.*` | Artifact store — upload, get, raw |
| `client.pastebin.*` | Text pastes |
| `client.qrcode.*` | QR code generation |
| `client.shortener.*` | URL shortening |
| `client.webhook.*` | Webhook inboxes |
| `client.jwt.*` | JWT decoding |
| `client.jsonTools.*` | JSON formatting, validation, minification |
| `client.dev.*` | Developer tools — ip, uuid, password, hash, base64, units, diff |

## Requirements

- Node.js 18+
- `node-fetch` (automatically installed)

## Documentation

Full API docs: [https://agentmediatools.com/docs](https://agentmediatools.com/docs)

## License

MIT
