API-referens

Varje rutt, i sin helhet

Goffys API för användardata, genererat från OpenAPI-kontraktet: varje rutt med sina parametrar, vad den svarar med och vilka fel den kan ge.

Så anropar du det

Varje rutt är en GET, svarar med JSON och kräver en bearer-token — din appsession eller en personlig åtkomsttoken från Profil → API-åtkomst. Bas-URL:en är densamma för alla.

curl -H "Authorization: Bearer <token>" https://backend.goffy.app/api/me
curl -H "Authorization: Bearer <token>" -o goffy-export.json https://backend.goffy.app/api/me/export

Rutter

En rond eller tour du varit med i kommer tillbaka så som appen visar den för dig, de andra spelarna inkluderade. En rond du inte spelat svarar 404, precis som en som inte finns.

GET /api/me

Your profile

Account fields and the handicap held on your player record.

Returns MeProfile

  • userId string (uuid) — The account id; the same value as the token subject.
  • playerId string (uuid) · optional — The player id every round, score and statistic is keyed by. Null until a player record exists.
  • username string — Sign-in name.
  • displayName string — Name shown to other players.
  • fullName string — Full name as entered on the profile.
  • email string · optional — Contact email, when one is set.
  • golfId string · optional — National golf id, normalised (no separators), when one is set.
  • distanceUnit string — Preferred distance unit: `metric` or `imperial`. Stored values are always metres.
  • createdAt string (date-time) — When the account was created.
  • homeClubs array of MeHomeClub — Home clubs, primary first when one is marked.
  • handicapIndex number (double) · optional — Current handicap index, when one is recorded.
  • handicapDate string (date) · optional — The date the handicap index was last set.
  • gender string · optional — Gender as chosen on the player record, when set.

Errors: 401, 404, 502

GET /api/me/export

Download everything

Your profile, tours, every round with your own scorecard lines, and all-time statistics as one JSON file. Limited to two downloads per minute.

Returns MeExport

  • exportedAt string (date-time) — When the export was produced.
  • profile MeProfile
  • tours array of MeTour — Every tour the user is a member of, finished ones included.
  • rounds array of MeRoundDetail — Every round the user has played, with their own scorecard lines.
  • statistics MeStatistics

Errors: 401, 404, 429, 502

GET /api/me/rounds

Your rounds

Every round you have played, newest first, with your totals in each.

Returns array of MeRoundSummary

  • roundId string (uuid) — Round id; use it with the round detail route.
  • tourId string (uuid) — The tour the round belongs to.
  • tourName string — Tour name.
  • courseName string — Course name.
  • status string — Round status: `open`, `playing`, `finished` or `cancelled`.
  • playDate string (date) · optional — Calendar date of play, when the round has one.
  • playedAtUtc string (date-time) — When the round was played, UTC.
  • holesScored integer (int32) — Holes with a score.
  • grossStrokes integer (int32) — Total gross strokes over the scored holes.
  • toPar integer (int32) — Gross strokes relative to par over the scored holes.
  • meritPoints number (double) — Merit points earned in this round across its games.
  • position integer (int32) · optional — Finishing position in the field; null when the round has no leaderboard yet.
  • fieldSize integer (int32) — Number of players in the round.

Errors: 401, 404, 502

GET /api/me/rounds/{roundId}

One of your rounds

The round as the app shows it to you: who played, every player's scorecard lines, hole events and scores, the game scores and the leaderboard. A round you did not play is a 404.

Parameters

  • roundId path · string (uuid) · required

Returns MeRoundDetail

  • round MeRound
  • players array of MePlayer — Everyone who played the round, the caller included, by id and display name.
  • holeEntries array of MeHoleEntry — Scorecard lines for every player, one per scored hole. Keyed by `playerId`.
  • holeEvents array of MeHoleEvent — Hole events for every player.
  • scores array of MeHoleScore — Stored gross scores for every player.
  • gameScores array of MeGameScore — Each game's score points, per player.
  • leaderboard array of MeRoundStanding — The round leaderboard: game points per player, with the per-game breakdown.

Errors: 401, 404, 502

GET /api/me/statistics

Your statistics

Rounds, tours, games, trophies and scoring trends for one calendar year, or all time when no year is given.

Parameters

  • year query · integer (int32)

Returns MeStatistics

  • playerId string (uuid) — The caller's player id.
  • year integer (int32) · optional — Calendar year the numbers cover, or null for all time.
  • availableYears array — Years the user has rounds in, newest first.
  • overview MeStatisticsOverview
  • activeTours array of MeStatisticsTour — Tours the user is in that have not finished.
  • trophies MeStatisticsTrophies
  • games array of MeStatisticsGame — Game types played in the period, with wins.
  • recentRounds array of MeRoundSummary — The most recent rounds in the period.
  • scoring MeStatisticsScoring

Errors: 401, 404, 502

GET /api/me/tours

Your tours

Every tour you are a member of, hidden and finished ones included, each with the players in it.

Returns array of MeTour

  • id string (uuid) — Tour id.
  • tourName string · optional — Tour name, when one was given.
  • status string — Tour status: `active`, `finished` or `archived`.
  • isHidden boolean — True when the user hid the tour from their own tour list.
  • unfinishedRoundCount integer (int32) — Rounds in the tour that have not finished.
  • createdAt string (date-time) — When the tour was created.
  • playerCount integer (int32) — How many players are in the tour, the caller included.
  • players array of MePlayer — The players in the tour, the caller included, by id and display name.

Errors: 401, 404, 502

GET /api/me/tours/{tourId}

One of your tours

The tour, the players in it, and the merit standings. A tour you are not in is a 404.

Parameters

  • tourId path · string (uuid) · required

Returns MeTourDetail

  • tour MeTour
  • leaderboard array of MeTourStanding — The merit standings, highest first. Empty until a round has been scored.

Errors: 401, 404, 502

Samma endpoints, från en klient

Varje endpoint ovan så som de genererade klienterna skriver den. Klienterna genereras från samma kontrakt, så varje anrop och varje fält kommer med beskrivningen du ser här: JSDoc i TypeScript, XML-summaries i C#, kommentarer på Python-modellerna. Editorn visar dem, så du behöver inte ha den här sidan uppe.

TypeScript

const goffy = createGoffyClient(process.env.GOFFY_TOKEN);

// Your profile
await goffy.api.me.get();

// Download everything
await goffy.api.me.exportEscaped.get();

// Your rounds
await goffy.api.me.rounds.get();

// One of your rounds
await goffy.api.me.rounds.byRoundId(roundId).get();

// Your statistics
await goffy.api.me.statistics.get();

// Your tours
await goffy.api.me.tours.get();

// One of your tours
await goffy.api.me.tours.byTourId(tourId).get();

C#

var goffy = GoffyUserDataClientFactory.Create(token);

// Your profile
await goffy.Api.Me.GetAsync();

// Download everything
await goffy.Api.Me.Export.GetAsync();

// Your rounds
await goffy.Api.Me.Rounds.GetAsync();

// One of your rounds
await goffy.Api.Me.Rounds[roundId].GetAsync();

// Your statistics
await goffy.Api.Me.Statistics.GetAsync();

// Your tours
await goffy.Api.Me.Tours.GetAsync();

// One of your tours
await goffy.Api.Me.Tours[tourId].GetAsync();

Python

goffy = create_client(token)

# Your profile
await goffy.api.me.get()

# Download everything
await goffy.api.me.export.get()

# Your rounds
await goffy.api.me.rounds.get()

# One of your rounds
await goffy.api.me.rounds.by_round_id(round_id).get()

# Your statistics
await goffy.api.me.statistics.get()

# Your tours
await goffy.api.me.tours.get()

# One of your tours
await goffy.api.me.tours.by_tour_id(tour_id).get()

Installationsraderna för alla tre finns i guiden.

Kom igång

Skaffa en token, sedan en klient

Skapa en token i appen, eller installera en av de genererade klienterna för TypeScript, .NET och Python.