생성기로 이동

API / OPENAPI

커버 HTTP API

프로그램은 Bearer, 공개 웹은 Turnstile. 성공은 이미지, 실패는 JSON.
01

인증

EVA_API_TOKEN을 환경 변수에 둡니다. Authorization: Bearer. 문서에 실제 토큰은 없습니다.

02

엔드포인트

GET https://eva.dashen.wang/api/v1/stats · GET https://eva.dashen.wang/api/v1/meta · POST https://eva.dashen.wang/api/v1/covers · POST https://eva.dashen.wang/api/v1/exports

03

예제

OpenAPI: https://eva.dashen.wang/api/v1/openapi.json

curl -sS https://eva.dashen.wang/api/v1/stats
curl -sS -H "Authorization: Bearer $EVA_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: demo-001" \
  -d '{"formatId":"article","themeId":"mono","output":"webp","quality":80,"content":{"title":"标题"}}' \
  https://eva.dashen.wang/api/v1/covers -o cover.webp
const res = await fetch('https://eva.dashen.wang/api/v1/covers', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer ' + process.env.EVA_API_TOKEN,
    'Content-Type': 'application/json',
    'Idempotency-Key': crypto.randomUUID(),
  },
  body: JSON.stringify({
    formatId: 'article',
    themeId: 'mono',
    output: 'webp',
    quality: 80,
    content: { title: '标题', subtitle: '副标题' },
  }),
});
const blob = await res.blob();
$ch = curl_init('https://eva.dashen.wang/api/v1/covers');
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . getenv('EVA_API_TOKEN'),
    'Content-Type: application/json',
    'Idempotency-Key: wp-' . wp_generate_uuid4(),
  ],
  CURLOPT_POSTFIELDS => wp_json_encode([
    'formatId' => 'article',
    'themeId' => 'mono',
    'output' => 'webp',
    'quality' => 80,
    'content' => ['title' => get_the_title($post)],
  ]),
  CURLOPT_RETURNTRANSFER => true,
]);
$image = curl_exec($ch);