# ApparatusAI JavaScript SDK

The **ApparatusAI SDK** provides an easy-to-use interface to interact with the **ApparatusAI API**. This SDK enables developers to fetch user information, run business forecasts, and analyze social trends using ApparatusAI's powerful machine learning models.

## Features
- 🔐 **Secure API Token Authentication**
- 📊 **Business Forecasting**
- 📈 **Social Trend Analysis**
- ⚡ **Easy Integration with JavaScript & Node.js**

## Installation
To install the SDK, run:
```sh
npm install apparatus-sdk
```

## Getting Started
### 1. Import the SDK
```javascript
const ApparatusAI = require("apparatus-sdk");
```

### 2. Initialize the SDK with your API Token
```javascript
const ai = new ApparatusAI("apai_your_api_token_here");
```
> ⚠️ **Note:** Ensure your API token starts with `apai_`, or an error will be thrown.

### 3. Fetch User Info
```javascript
(async () => {
    try {
        const userInfo = await ai.getUserInfo();
        console.log("User Info:", userInfo);
    } catch (error) {
        console.error("Error fetching user info:", error.message);
    }
})();
```

### 4. Perform Business Forecasting
```javascript
(async () => {
    try {
        const forecastData = await ai.forecast({ revenue: [10000, 12000, 15000] });
        console.log("Forecast Result:", forecastData);
    } catch (error) {
        console.error("Forecasting Error:", error.message);
    }
})();
```

### 5. Analyze Social Trends
```javascript
(async () => {
    try {
        const socialTrends = await ai.analyzeSocialTrends({ keyword: "AI Trends" });
        console.log("Social Trends Analysis:", socialTrends);
    } catch (error) {
        console.error("Social Analysis Error:", error.message);
    }
})();
```

## API Reference
### `new ApparatusAI(apiToken)`
Creates an instance of the SDK.

### `.getUserInfo()` → `Promise<Object>`
Fetches the authenticated user's information.

### `.forecast(data: Object)` → `Promise<Object>`
Submits business data for forecasting.

**Parameters:**
- `data` (Object): An object containing business metrics like revenue, expenses, etc.

**Example:**
```javascript
await ai.forecast({ revenue: [10000, 12000, 15000] });
```

### `.analyzeSocialTrends(params: Object)` → `Promise<Object>`
Analyzes social trends based on the given parameters.

**Parameters:**
- `params` (Object): Contains `keyword`, `dateRange`, and other optional filters.

**Example:**
```javascript
await ai.analyzeSocialTrends({ keyword: "Artificial Intelligence" });
```

## Error Handling
If the API request fails, the SDK throws an error with details:
```javascript
try {
    await ai.getUserInfo();
} catch (error) {
    console.error("API Error:", error.message);
}
```

## Contributing
1. Fork the repository
2. Create a new branch (`git checkout -b feature-branch`)
3. Commit your changes (`git commit -m "Add new feature"`)
4. Push to the branch (`git push origin feature-branch`)
5. Open a pull request

## License
This SDK is licensed under the **MIT License**.

---
🚀 **Start building with ApparatusAI today!**

