Install the yeetpost package:
Export your API key so the process can read it:
export YEETPOST_API_KEY=<your-api-key>
Send a post:
import { yeetpost } from "yeetpost";
await yeetpost({
connection: "<your-connection-slug>",
text: "Hello from yeetpost!",
});
To post to several connections in one call, use the JSON endpoint. It answers with one result per connection and accepts an Idempotency-Key, so a retry cannot double-post:
const response = await fetch("https://api.yeetpost.com/api/v2/posts", {
method: "POST",
headers: {
"x-api-key": process.env.YEETPOST_API_KEY!,
"content-type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({
text: "Hello from yeetpost!",
connectionSlugs: ["<your-connection-slug>"],
}),
});
const { results } = await response.json();
for (const result of results) {
console.log(result.connectionSlug, result.status, result.url);
}
Read each result.status rather than the HTTP status alone: one connection can fail while the rest go out.