# GrapeAvaterAPI リファレンス

## GrapeAvatarAPI リファレンス

### API説明と利用例

`GrapeAvatarAPI` を使用すると、APIキーを利用してファイルの**アップロード**および**削除**が可能です。\
このAPIは、ユーザーからの大量アップロードを効率的に処理し、サーバーの容量やトラフィックの増大を気にすることなくファイル管理機能を提供します。

***

### 1. APIキーの取得

APIキーとフォルダー名を取得するには、メールでのお問い合わせが必要です。取得したAPIキーを使ってファイルのアップロードと削除を実行できます。

メール:<apply@grape.mixeder.net>

***

### 2. ファイルアップロード

#### **エンドポイント**

`POST` `https://grapes-avatarapi.mixeder.net/upload`

#### **使用例**

**cURL**

```bash
curl -X POST https://grapes-avatarapi.mixeder.net/upload \
     -F "file=@/path/to/yourfile.png" \
     -F "apiKey=your_api_key"
```

**Python**

```python
import requests

url = "https://grapes-avatarapi.mixeder.net/upload"
files = {"file": open("/path/to/yourfile.png", "rb")}
data = {"apiKey": "your_api_key"}

response = requests.post(url, files=files, data=data)
print(response.json())
```

**PHP**

```php
<?php
$ch = curl_init("https://grapes-avatarapi.mixeder.net/upload");
$file = new CURLFile('/path/to/yourfile.png');
$data = ["file" => $file, "apiKey" => "your_api_key"];

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
```

**Node.js**

```javascript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

const form = new FormData();
form.append('file', fs.createReadStream('/path/to/yourfile.png'));
form.append('apiKey', 'your_api_key');

axios.post('https://grapes-avatarapi.mixeder.net/upload', form, { headers: form.getHeaders() })
  .then(response => { console.log(response.data); })
  .catch(error => { console.error(error); });
```

**Go**

```go
package main

import (
    "fmt"
    "log"
    "mime/multipart"
    "net/http"
    "os"
)

func main() {
    file, err := os.Open("/path/to/yourfile.png")
    if err != nil {
        log.Fatal(err)
    }
    defer file.Close()

    body := &multipart.Writer{}
    req, err := http.NewRequest("POST", "https://grapes-avatarapi.mixeder.net/upload", body)
    req.Header.Set("Content-Type", body.FormDataContentType())

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        log.Fatal(err)
    }
    defer resp.Body.Close()

    fmt.Println("アップロード結果:", resp.Status)
}
```

アップロード後、ファイルは次のURLからアクセスできます：

```
https://grapes-avatarapi.mixeder.net/フォルダ名/ファイル名
```

例：

```json
{
  "message": "ファイルが正常に保存されました。",
  "fileName": "68fea2b2d25d1100.png"
}
```

***

### 3. ファイル削除

#### **エンドポイント**

`DELETE` `https://grapes-avatarapi.mixeder.net/delete`

#### **使用例**

**cURL**

```bash
curl -X DELETE https://grapes-avatarapi.mixeder.net/delete \
     -H "Content-Type: application/json" \
     -d '{"apiKey": "your_api_key", "fileName": "uploaded_file_name.png"}'
```

**Python**

```python
import requests

url = "https://grapes-avatarapi.mixeder.net/delete"
payload = {"apiKey": "your_api_key", "fileName": "uploaded_file_name.png"}

response = requests.delete(url, json=payload)
print(response.json())
```

**PHP**

```php
<?php
$ch = curl_init("https://grapes-avatarapi.mixeder.net/delete");
$data = json_encode(["apiKey" => "your_api_key", "fileName" => "uploaded_file_name.png"]);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
```

**Node.js**

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

const deleteData = { apiKey: "your_api_key", fileName: "uploaded_file_name.png" };

axios.delete('https://grapes-avatarapi.mixeder.net/delete', { data: deleteData })
  .then(response => { console.log(response.data); })
  .catch(error => { console.error(error); });
```

**Ruby**

```ruby
require 'net/http'
require 'json'

uri = URI('https://grapes-avatarapi.mixeder.net/delete')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(uri.path, { 'Content-Type' => 'application/json' })
request.body = { apiKey: "your_api_key", fileName: "uploaded_file_name.png" }.to_json

response = http.request(request)
puts response.body
```

***

これらのコードを使用することで、ファイルの**アップロード**および**削除**が簡単に実行できます。APIキーを適切に管理し、安全なファイル操作を行いましょう。


---

# 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/grapeapi/apirifarensu/grapeavaterapi-rifarensu.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.
