DIY guide · Medium API
Every integration starts with the right id
Medium URLs look simple until you automate them. Handles change format, redirects hide ids, and scrapers break when markup shifts. The durable pattern is: resolve once, store `user_id`, and never parse HTML again.
Why ids beat URLs
Your database should store user_id, not "whatever was in the link." Every list-articles, top-stories, and profile call keys off that id. Zenndra exposes id_for username and get user as first-class endpoints.
Common workflows
- Portfolio sync — resolve your handle, list articles, fetch markdown nightly.
- CRM enrichment — sales pastes a Medium URL, you store id + follower count.
- Aggregator onboarding — CSV of @writers → batch resolve before first ingest.
Production tips
Cache resolutions forever unless the user changes handle (rare). Log 404s separately from rate limits. Retry with backoff, not hammering.
Endpoints
GET /user/id_for/{username}GET /user/{user_id}
Starter code
const handle = 'johndoe';
const idRes = await fetch(`https://api.zenndra.com/user/id_for/${handle}`, {
headers: { Authorization: `Bearer ${process.env.ZENNDRA_API_KEY}` },
});
const { user_id } = await idRes.json();
const profile = await fetch(`https://api.zenndra.com/user/${user_id}`, {
headers: { Authorization: `Bearer ${process.env.ZENNDRA_API_KEY}` },
}).then(r => r.json());