金融与汇率

Améthyste API

为Discord用户生成个性化图像的API服务。提供多种图像模板和自定义选项,可直接集成到Discord机器人中使用。

查看官方文档 ↗

接入教程

1. 访问Améthyste官网注册获取API密钥
2. 选择需要的图像生成端点(如/生成/欢迎)
3. 在Discord机器人代码中调用API
4. 传入用户ID和自定义参数
5. 接收并处理返回的图像URL
6. 将生成的图像发送到Discord频道

使用Python生成Discord欢迎图像

python
import requests

url = 'https://api.amethyste.moe/generate/welcome'
headers = {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
}
data = {
    'username': 'DiscordUser123',
    'avatar': 'https://example.com/avatar.png',
    'background': 'default'
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
    with open('welcome.png', 'wb') as f:
        f.write(response.content)
    print('Image saved successfully')
else:
    print(f'Error: {response.status_code}')
    print(response.text)

使用PHP生成等级卡片图像

php
<?php
$api_url = 'https://api.amethyste.moe/generate/rankcard';
$api_key = 'YOUR_API_KEY';

$data = array(
    'username' => 'PHPUser',
    'level' => 25,
    'xp' => 1250,
    'avatar' => 'https://example.com/user_avatar.jpg',
    'theme' => 'dark'
);

$options = array(
    'http' => array(
        'header'  => "Authorization: Bearer $api_key\r\n" .
                    "Content-Type: application/json\r\n",
        'method'  => 'POST',
        'content' => json_encode($data)
    )
);

$context = stream_context_create($options);
$result = file_get_contents($api_url, false, $context);

if ($result !== false) {
    file_put_contents('rank_card.png', $result);
    echo 'Image generated successfully';
} else {
    echo 'Failed to generate image';
}
?>

使用JavaScript生成Discord资料卡

javascript
const fetch = require('node-fetch');

async function generateProfileCard() {
    const url = 'https://api.amethyste.moe/generate/profile';
    const apiKey = 'YOUR_API_KEY';
    
    const requestData = {
        username: 'JS_User',
        discriminator: '1234',
        avatar: 'https://example.com/profile_pic.jpg',
        status: 'online',
        badges: ['developer', 'supporter']
    };
    
    try {
        const response = await fetch(url, {
            method: 'POST',
            headers: {
                'Authorization': `Bearer ${apiKey}`,
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(requestData)
        });
        
        if (response.ok) {
            const buffer = await response.buffer();
            require('fs').writeFileSync('profile_card.png', buffer);
            console.log('Profile card generated successfully');
        } else {
            console.error(`Error: ${response.status}`);
            console.error(await response.text());
        }
    } catch (error) {
        console.error('Request failed:', error);
    }
}

generateProfileCard();

常见问题

如何获取API密钥?

请访问Améthyste官方网站并注册账户,在控制面板中可以生成和管理您的API密钥。免费套餐提供有限的调用次数,高级套餐提供更多功能和更高的调用限制。

生成的图像格式支持哪些?

API默认生成PNG格式的图像,支持透明背景。所有生成的图像都是高质量的,适合在Discord和其他平台上使用。如果需要其他格式,可以通过参数指定或后续转换。

API调用有什么限制?

免费套餐每分钟最多10次调用,每天最多100次调用。付费套餐根据等级提供更高的限制。建议在代码中添加适当的错误处理和重试逻辑,以应对速率限制的情况。

相似接口推荐

AWS Import/Export

AWS Import/Export服务通过邮寄物理存储设备的方式,在AWS云和用户本地环境间高效传输海量数据。该服务利用亚马逊高速内部网络直接读写存储设备,适用于大规模数据迁移场景。

待确认
AWS Greengrass

AWS IoT Greengrass可将AWS功能无缝扩展至物理设备,使设备能够本地处理生成的数据,同时仍利用云端进行管理、分析和持久存储。该服务确保设备能够快速响应本地事件,并在间歇性连接下稳定运行。

待确认
Amazon ElastiCache

Amazon ElastiCache是一项Web服务,可简化云端分布式缓存的设置、操作和扩展。它让客户能够获得高性能内存缓存的所有优势,同时减少管理负担。

待确认
Amazon Elastic Inference

Elastic Inference是AWS提供的弹性推理服务公共API。自2023年4月15日起,AWS不再接受新客户使用该服务,并协助现有客户迁移至性价比更优的替代方案。该API用于管理云端AI推理的加速计算资源。

待确认