@opengolfapi/sdk
v3.0.0
Published
OpenGolfAPI SDK — read the open golf map (free), score games (OpenMatch), write Moments, and compose the 3.0 primitives (competitions, assets, claims, beta, the verifiable OpenGolf Chain) behind one portable OpenGolf ID. Runs anywhere fetch exists.
Maintainers
Readme
@opengolfapi/sdk
The OpenGolfAPI client — read the open golf map (free, no key), score any game (OpenMatch, keyless), write golfer Moments, and compose the 3.0 primitives (competitions, assets, claims, beta, and the verifiable OpenGolf Chain) — all behind one portable OpenGolf ID. Runs anywhere fetch exists: browser, Node, React Native, Workers.
Part of the open standards donated to golf — OpenShot, Moments, OpenMatch, OpenJoin, OpenGolf ID. Build it in minutes; the data lives forever.
npm i @opengolfapi/sdkRead (free, no key)
import { OpenGolf } from "@opengolfapi/sdk";
const og = new OpenGolf();
const { courses } = await og.searchCourses("pebble");
const holes = await og.holes(courses[0].id);Score a game (OpenMatch — free, keyless)
const result = await og.score("skins", {
players: [{ player_id: "a", holes: { 1: 4, 2: 5 } }],
holes: [{ hole: 1, par: 4 }, { hole: 2, par: 5 }],
});Write Moments (free key — feeds the open map)
const og = new OpenGolf({ apiKey: "ogapi_…" }); // free key: Sign in with OpenGolf → create_dev_key
// a recorded GPS round → breadcrumb moments
await og.submitRound(courseId, watchTrack);
// or any single moment (the open standard primitive)
await og.submitMoments({
moment_type: "shot", lat, lng, recorded_at: new Date().toISOString(),
course_id: courseId, hole_number: 7, payload: { club: "7i" },
});The Moment interface is the open standard — any app that emits this shape is interoperable.
Build a whole app (3.0 primitives)
Bake in OpenGolf ID from line one — it's deterministic from email, so every user is on the standard with zero signup:
import { OpenGolf, deriveOpenGolfId } from "@opengolfapi/sdk";
const og = new OpenGolf({ apiKey: "ogapi_…" });
const sub = await deriveOpenGolfId(user.email); // portable identity, no redirect
// Competitions (contest over OpenMatch — free gross Result)
const { competition } = await og.createCompetition({ name: "Saturday Skins", type: "skins", course_id });
await og.recordAttempt(competition.id, { player_id: sub, hole: 1, strokes: 4 });
await og.finalizeCompetition(competition.id);
// Assets (trophy / course-passport stamp), Claims (trust ledger), Beta (local knowledge)
await og.mintAsset({ type: "passport", name: "Played Pebble Beach", owner: sub });
await og.fileClaim({ claim_type: "record", subject: `course:${course_id}` });
await og.postBeta({ course_id, text: "Green slopes back-to-front", hole: 7 });
// The user owns it all — their verifiable, Bitcoin-anchored record (own-read free)
const chain = await og.myChain();Full recipe: GET https://api.opengolfapi.org/api/v1/toolkit/quickstart.
Links
- Docs & live API — https://opengolfapi.org/docs
- Sign in with OpenGolf —
@opengolfapi/sign-in - AI/agent guide — https://api.opengolfapi.org/llms.txt
OpenGolfAPI is a non-profit open commons for golf, founded by Chicago tech entrepreneur Julian Pretto. MIT. [email protected]
