# EmotionalClassificationAPI

**EmotionalClassificationAPI** は、指定されたテキストの感情を分類するための API です。この API を使用することで、感情分析や感情分類を効率的に実行できます。

***

#### **導入用途**

1. **顧客フィードバックの分析**\
   ユーザーレビューやカスタマーサポートメッセージの感情を把握します。
2. **SNS分析**\
   ソーシャルメディア投稿の感情を特定し、トレンド分析を行います。
3. **マーケティング戦略の強化**\
   コンテンツがユーザーに与える感情的な影響を分析します。
4. **テキスト解析アプリケーション**\
   感情分析機能を組み込むことで、アプリケーションの価値を高めます。

***

#### **Base URL**

```
https://emotionalclassification-mixederapi.mixeder.com/
```

***

#### **Endpoints**

**GET /**

指定されたテキストに対して感情分析を実行します。

**Headers**

| ヘッダー名          | 必須 | 説明                 |
| -------------- | -- | ------------------ |
| `Content-Type` | はい | `application/json` |

**Query Parameters**

| パラメーター名 | 必須 | 説明          |
| ------- | -- | ----------- |
| `key`   | はい | 使用する API キー |
| `text`  | はい | 感情分析を行うテキスト |

**Response**

* 成功時:\
  **HTTP Status**: 200\
  **Body**:

  ```json
  {
    "message": "API authentication, sentiment analysis, and billing completed successfully",
    "username": "user123",
    "analysis": {
      "text": "example text",
      "sentiment": "positive", 
      "confidence": 0.98
    },
    "billingResponse": "Billing processed successfully"
  }
  ```
* エラー時:\
  **HTTP Status**: 400 または 500\
  **Body**:

  ```json
  {
    "error": "Error message"
  }
  ```

***

#### **サンプルコード**

**JavaScript Fetch Example**

```javascript
async function analyzeSentiment(apiKey, text) {
  const apiUrl = 'https://emotionalclassification-mixederapi.mixeder.com/';
  
  const queryParams = new URLSearchParams({ key: apiKey, text });

  try {
    const response = await fetch(`${apiUrl}?${queryParams.toString()}`, {
      method: 'GET',
      headers: { 'Content-Type': 'application/json' },
    });

    if (!response.ok) {
      throw new Error(`API error: ${response.statusText}`);
    }

    const data = await response.json();
    console.log('Sentiment analysis result:', data.analysis);
    return data.analysis;
  } catch (error) {
    console.error('Error during sentiment analysis:', error.message);
    throw error;
  }
}

// 使用例
analyzeSentiment('your-api-key', 'I love this product!')
  .then((result) => console.log('Sentiment Analysis Result:', result))
  .catch((err) => console.error('Analysis failed:', err));
```

***

**Python Requests Example**

```python
import requests

def analyze_sentiment(api_key, text):
    api_url = 'https://emotionalclassification-mixederapi.mixeder.com/'
    params = {
        "key": api_key,
        "text": text,
    }
    try:
        response = requests.get(api_url, params=params)
        response.raise_for_status()
        data = response.json()
        print("Sentiment analysis result:", data["analysis"])
        return data["analysis"]
    except requests.exceptions.RequestException as e:
        print("Error during sentiment analysis:", e)
        raise

# 使用例
analyze_sentiment("your-api-key", "I am very happy with this service!")
```

***

**cURL Example**

```bash
curl -X GET 'https://emotionalclassification-mixederapi.mixeder.com/?key=your-api-key&text=I%20love%20this%20product' \
  -H "Content-Type: application/json"
```

***

#### **料金計算**

1. **サービス名**: `EmotionalClassificationAPI`
2. **単位あたり料金**: 0.05


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.mixeder.net/biz-ai/emotionalclassificationapi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
