yellowskunk-contact
v1.0.1
Published
Node.js client for Yellow Skunk contact API
Downloads
19
Maintainers
Readme
yellowskunk-contact
A tiny Node.js client for sending contact messages through the YellowSkunk serverless API.
- ✅ Minimal API — one function:
sendContact(options) - ✅ Works anywhere Node runs (server, scripts, serverless)
- ✅
authUIDnow optional — server can resolve UID from yourapiKey - ✅ Customizable timeout, headers, and endpoint override
Install
npm install yellowskunk-contact
# or
yarn add yellowskunk-contact
# or
pnpm add yellowskunk-contactPeer/runtime: Node 14+ recommended (Axios under the hood).
Quick start
// CommonJS
const { sendContact } = require('yellowskunk-contact');
(async () => {
const result = await sendContact({
// Your API key: https://devs-yellowskunk.netlify.app/apikey
apiKey: process.env.YELLOWSKUNK_API_KEY,
// The message you want to send
content: 'Hello from my Node.js client!',
// The recipient's alias
toAlias: 'yellowskunk',
// authUID is optional now; include only if you need it for compatibility
// authUID: 'YOUR_FIREBASE_UID',
});
console.log(result);
// -> { ok: true, id: "...", timestamp: 1710000000000 }
})();Using ESM
import { sendContact } from 'yellowskunk-contact';
await sendContact({ apiKey, content: 'Hi!', toAlias: 'yellowskunk' });API
sendContact(options) => Promise<object>
Sends a contact message via YellowSkunk’s Netlify function.
| Option | Type | Required | Default | Description |
| ---------- | ------ | -------- | --------------------------------------------------- | -------------------------------------------------------------------------------------- |
| apiKey | string | ✅ | — | Your per-user API key. Get it from the dev portal. |
| content | string | ✅ | — | Message body. Must be a non-empty string. |
| toAlias | string | ✅ | — | Recipient alias. |
| authUID | string | ❌ | — | (Legacy/optional) Explicit user id. If omitted, the server resolves UID from apiKey. |
| endpoint | string | ❌ | https://api--yellowskunk.netlify.app/contact/send | Override API endpoint (useful for staging/self-host). |
| timeout | number | ❌ | 10000 | Axios request timeout in ms. |
| headers | object | ❌ | { 'content-type': 'application/json' } (merged) | Extra HTTP headers to merge into the request. |
Returns a JSON object from the API, e.g.:
{ "ok": true, "id": "msg_123", "timestamp": 1710000000000 }On HTTP errors, it throws an Error with:
message: API error text orHTTP <status>status: HTTP status codedata: raw error payload (if any)
Examples
Basic script
const { sendContact } = require('yellowskunk-contact');
(async () => {
try {
const res = await sendContact({
apiKey: process.env.YELLOWSKUNK_API_KEY,
content: 'Question about pricing',
toAlias: 'sales'
});
console.log('Sent:', res);
} catch (err) {
console.error('Send failed:', {
message: err.message,
status: err.status,
data: err.data,
});
process.exitCode = 1;
}
})();With a custom endpoint and headers
await sendContact({
apiKey,
content: 'Hello staging!',
toAlias: 'yellowskunk',
endpoint: 'http://localhost:8888/.netlify/functions/contact/send',
timeout: 5000,
headers: { 'x-trace-id': 'abc123' }
});Using environment variables
export YELLOWSKUNK_API_KEY="sk_live_..."
node send.jsWhy authUID is optional now?
The server can infer your user from the apiKey. authUID remains supported for backward compatibility; if you pass it, it will be included in the payload.
Errors & troubleshooting
Missing apiKey, content (string), or toAliasOne of the required fields is missing orcontentis empty/whitespace.HTTP errors (e.g. 401/403/429/5xx) Catch the error and inspect
err.statusanderr.datafor details:try { /* ... */ } catch (err) { console.error(err.status, err.message, err.data); }Proxy/Corporate Networks You may need to configure Axios proxy env vars (
HTTP_PROXY/HTTPS_PROXY).
Security
- Keep your API key secret. Do not commit it to version control.
- Use environment variables or your platform’s secret manager.
Changelog (highlights)
- 0.x.x —
authUIDmade optional; improved error normalization; addedtimeout/headersoptions.
License
MIT © YellowSkunk
Links
- Dev portal for API keys:
https://devs-yellowskunk.netlify.app/apikey - Default API endpoint:
https://api--yellowskunk.netlify.app/contact/send
