# ConvertAPI

## ConvertAPI リファレンス

### サービス名

**ConvertAPI**

### 利用用途

`ConvertAPI`は、指定した画像ファイルをアスキーアート(ASCII Art)に変換するAPIです。アスキーアートは、画像の輝度情報を基に文字を組み合わせて生成される視覚的表現で、画像をテキスト形式に変換して表示したい場合に利用されます。

{% hint style="info" %}
**このAPIの利用にはAPIキーが必要ですが、料金は発生しません。また、請求書にも記載されません。**
{% endhint %}

***

### API エンドポイント

```
https://events-front.mixeder.net/ConvertAPI/
```

***

### パラメータ

| パラメータ  | 必須 | 説明             |
| ------ | -- | -------------- |
| `key`  | 必須 | 利用者のAPIキー      |
| `from` | 必須 | 変換する画像ファイルのURL |

***

### 利用方法

1. 有効なAPIキーを用意します。
2. 変換したい画像のURLを`from`パラメータに指定します。
3. 上記のパラメータを使ってリクエストを送信すると、アスキーアートが返されます。

***

### サンプルレスポンス

```plaintext
@@@@@@@@@@@@@@@@@@
@@&&&*******::::::
@@&&&*******::::::
@@@@@@@@@@@@@@@@@@
```

***

### サンプルコード

#### cURL

```bash
curl "https://events-front.mixeder.net/ConvertAPI/?key=YOUR_API_KEY&from=https://example.com/sample.jpg"
```

#### Node.js

```javascript
const https = require('https');

const url = 'https://events-front.mixeder.net/ConvertAPI/?key=YOUR_API_KEY&from=https://example.com/sample.jpg';

https.get(url, (res) => {
    let data = '';
    res.on('data', (chunk) => {
        data += chunk;
    });
    res.on('end', () => {
        console.log(data);
    });
}).on('error', (err) => {
    console.error('Error: ' + err.message);
});
```

#### Python

```python
import requests

url = "https://events-front.mixeder.net/ConvertAPI/"
params = {
    "key": "YOUR_API_KEY",
    "from": "https://example.com/sample.jpg"
}

response = requests.get(url, params=params)
if response.status_code == 200:
    print(response.text)
else:
    print(f"Error: {response.status_code}")
```

***

### エラーメッセージ

* **API Key not provided.**: APIキーが指定されていません。
* **Query\[From] not provided.**: 画像のURLが指定されていません。
* **API key is wrong**: APIキーが無効です。

***

### 注意事項

* 画像ファイルのURLは外部から直接参照できる形式である必要があります。
* 適切なAPIキーを使用しないと、リクエストは拒否されます。

***

これで、`ConvertAPI`を利用して画像をアスキーアートに変換するための手順が整いました。
