OpenAPI とその他の言語
API 全体は OpenAPI 3.1 のドキュメントで記述されています。これはこのサイトの API リファレンスの元になっており、公式 SDK のない言語向けにクライアントを生成することもできます。
- 仕様:
https://api.spacepost.dev/openapi.json - リポジトリ内のソースファイル:
openapi/openapi.yaml
クライアントを生成する
Section titled “クライアントを生成する”ベース URL を https://api.spacepost.dev に設定し、sp_live_ キーでベアラー認証を構成します。
openapi-typescript と openapi-fetch で、型と fetch クライアントを生成します。
npx openapi-typescript https://api.spacepost.dev/openapi.json -o spacepost.d.tsnpm install openapi-fetchimport createClient from "openapi-fetch";import type { paths } from "./spacepost";
const client = createClient<paths>({ baseUrl: "https://api.spacepost.dev", headers: { Authorization: `Bearer ${process.env.SPACEPOST_API_KEY}` },});
const { data, error } = await client.POST("/emails", { body: { from: "Acme <hello@acme.com>", to: ["user@example.com"], subject: "Hi", html: "<p>Hi</p>" },});pipx install openapi-python-clientopenapi-python-client generate --url https://api.spacepost.dev/openapi.jsongo install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latestcurl -s https://api.spacepost.dev/openapi.json -o openapi.jsonoapi-codegen -package spacepost -generate types,client openapi.json > spacepost.gen.goOpenAPI Generator を使います。
npx @openapitools/openapi-generator-cli generate \ -i https://api.spacepost.dev/openapi.json \ -g ruby -o ./spacepost-rubyPHP、Ruby、Java、Kotlin、Swift、C#、Rust など、数十の言語向けのジェネレーターがあります。
Postman と API ツール
Section titled “Postman と API ツール”仕様の URL を Postman、Insomnia、Bruno、Hoppscotch にインポートします。ベアラートークン用に、コレクション変数を設定してください。
Resend の SDK を使う
Section titled “Resend の SDK を使う”SpacePost は Resend と互換性があるため、他の言語の公式 Resend SDK も、ベース URL を上書きするだけで動作することがよくあります。Resend からの移行をご覧ください。
API リファレンスすべてのエンドポイントと、リクエスト・レスポンスのスキーマ。