# Blinky — agent skill

API version: ffeee60b

Blinky (https://blinky.spooky.click) tracks the video games a person has played, owns and wants, retro games first.
This document tells an AI agent how to sign in as a Blinky user and read and update their
library over a small JSON API: list their games, search IGDB for one to add, log that they
played or beat something, rate it, ask Clyde what to play next, read their stats, and share
a library with family.

If the user said something like "I beat Super Metroid last night" or "what should I play
next on the SNES?", follow the steps below: sign in once (reuse the saved token after that),
then call the API.

## Or connect over MCP

If you can use MCP servers, add https://blinky.spooky.click/mcp as a remote MCP server (Streamable HTTP) and skip
the rest. Every API route below is also a tool there, with the same arguments and results.
Your MCP client signs the user in by itself with OAuth (metadata at
https://blinky.spooky.click/.well-known/oauth-protected-resource/mcp). A token from the device flow below also
works on /mcp as a bearer token.

## Reuse a saved token first

Tokens don't expire, so run the device flow once per user. Before starting it, look for a
saved Blinky token: `~/.config/blinky/token` if you can write files, or whatever durable
storage you have. If a call answers 401, the token was revoked: run the device flow again.

## Check the API version

Every API response has an `X-Blinky-Api-Version` header (and `GET /api/me` returns
`api_version`). If it differs from the version at the top of the copy of this document you
saved, read https://blinky.spooky.click/skill again.

## Scopes

- `read`: see games, plays, libraries and stats (always granted).
- `write`: add and change games, log and edit plays, make libraries and invite links, join them.
- `delete`: remove games and delete libraries.

Ask for what you need. A route the token's scope doesn't cover answers
`403 {"error":"insufficient_scope","scope":"...","granted":"..."}`: run the device flow
again asking for more.

## Device flow (sign in once)

1. `POST https://blinky.spooky.click/api/device/code` with JSON `{"scope":"read write"}`. You get `device_code`,
   `user_code` (like `BCDF-GH23`), `verification_uri_complete`, `expires_in` (600) and `interval` (5).
2. Tell the user to open `verification_uri_complete` and approve. Show them the `user_code`.
3. Every `interval` seconds, `POST https://blinky.spooky.click/api/device/token` with `{"device_code":"..."}`.
   `400 {"error":"authorization_pending"}` means keep waiting; `access_denied` or
   `expired_token` means stop. Success is `{"access_token":"...","token_type":"Bearer","scope":"..."}`.
4. Save the token, then send `Authorization: Bearer <token>` on every call.

## Conventions

- JSON in, JSON out. GET arguments go in the query string; others in a JSON body.
- Errors are `{"error":"<code>","message"?:...}`. `invalid_<field>` (400) may list `valid` values.
  `not_found` (404) means it doesn't exist or isn't in a library the user belongs to.
- An **entry** (`entry_id`) is one game on one platform in one library. `igdb_id` is IGDB's id
  for the game. The same game on two platforms is two entries.
- Statuses: `playing`, `backlog`, `beaten`, `completed` (that's 100%), `dropped`, `wishlist`.
  `owned` is true or false; `format` is `cart`, `disc`, `digital` or `emulated`.
- Ratings are integers 1–10, shown as five hearts in halves (7 = 3½ hearts).
- Dates are `YYYY-MM-DD` in the user's own day: "yesterday" is yesterday where they are.
- PATCH is partial: send only what changes; `null` clears a field.
- `log_play` is not idempotent. Check `get_game`'s `plays` before logging one the user may
  already have logged.
- Each user has their own library (`personal_collection_id` in `/api/me`); `collection_id`
  defaults to it everywhere. Shared libraries come from `create_collection` and invite links.
- Confirm with the user before `delete_game` or `delete_collection`. Make an invite link only
  when they ask to share, and give it to them.

## Routes

Each heading is the HTTP route, then the MCP tool's name.

### GET https://blinky.spooky.click/api/me — `get_me`

The signed-in user: id, name, email, their own library's collection id, the token's scope, and the API version.

### GET https://blinky.spooky.click/api/collections — `list_collections`

Every library (collection) the user belongs to: their own, and any shared ones, with members and game counts.

### GET https://blinky.spooky.click/api/collections/:collection_id — `get_collection`

One library: name, members, number of games and a count per status.

- `collection_id` (required): A collection (library) id from list_collections. Defaults to the user's own library.

### POST https://blinky.spooky.click/api/collections — `create_collection`

Makes a new library the user can share with an invite link. Needs `write`.

- `name` (required)

### PATCH https://blinky.spooky.click/api/collections/:collection_id — `update_collection`

Renames a library. Needs `write`.

- `collection_id` (required): A collection (library) id from list_collections. Defaults to the user's own library.
- `name`

### DELETE https://blinky.spooky.click/api/collections/:collection_id — `delete_collection`

Deletes a shared library and every game and play in it, for every member. Can't be undone; the user's own library can't be deleted. Needs `delete`.

- `collection_id` (required): A collection (library) id from list_collections. Defaults to the user's own library.

### GET https://blinky.spooky.click/api/collections/:collection_id/invite — `get_collection_invite`

The user's current usable invite link for a library, or null.

- `collection_id` (required): A collection (library) id from list_collections. Defaults to the user's own library.

### POST https://blinky.spooky.click/api/collections/:collection_id/invites — `create_collection_invite`

Makes an invite link (good for 7 days and 10 people) that lets anyone who has it sign up and join the library as an equal member. Needs `write`.

- `collection_id` (required): A collection (library) id from list_collections. Defaults to the user's own library.

### GET https://blinky.spooky.click/api/invites/:code — `get_invite`

What library an invite code is for, and whether it can still be used.

- `code` (required)

### POST https://blinky.spooky.click/api/invites/:code/join — `join_collection`

Joins the library an invite code is for. Needs `write`.

- `code` (required)

### GET https://blinky.spooky.click/api/games — `list_games`

Games in a library (default: the user's own), filtered and sorted. Each has an entry id, the IGDB id, platform, status, owned, format, rating, notes and last_played.

- `collection_id`: A collection (library) id from list_collections. Defaults to the user's own library.
- `platform`: A platform as stored, e.g. SNES, NES, Genesis/MegaDrive.
- `owned`
- `format`: one of `cart` `disc` `digital` `emulated`. How they have it.
- `decade`: Release decade, e.g. 1990.
- `status`: playing, backlog, beaten, completed (100%), dropped or wishlist, or several separated by commas
- `q`: Part of the name.
- `sort`: one of `name` `added` `played` `year` `rating` `platform`
- `limit`: Default 100.
- `offset`

### GET https://blinky.spooky.click/api/games/:entry_id — `get_game`

One library entry with IGDB details (summary, genres, developer, platforms) and its whole play log.

- `entry_id` (required): A library entry id (one game on one platform in one library), from list_games, add_game or clyde.

### POST https://blinky.spooky.click/api/games — `add_game`

Adds a game from IGDB (find its igdb_id with search_igdb) to a library on one platform. Status defaults to backlog. If status is beaten or completed, finished_on logs a play with that date. Needs `write`.

- `igdb_id` (required)
- `platform`: A platform abbreviation from search_igdb's platforms (e.g. SNES); defaults to the game's first.
- `status`: one of `playing` `backlog` `beaten` `completed` `dropped` `wishlist`. completed means 100%.
- `owned`: Whether they own a copy. Defaults to true when format is given (unless wishlist).
- `format`: one of `cart` `disc` `digital` `emulated`. How they have it.
- `rating`: 1 to 10 (shown as five hearts, in halves).
- `notes`
- `finished_on`: YYYY-MM-DD
- `collection_id`: A collection (library) id from list_collections. Defaults to the user's own library.

### PATCH https://blinky.spooky.click/api/games/:entry_id — `update_game`

Changes a library entry. Partial: send only what changes; null clears format, rating or notes. collection_id moves it to another library. Needs `write`.

- `entry_id` (required): A library entry id (one game on one platform in one library), from list_games, add_game or clyde.
- `status`: one of `playing` `backlog` `beaten` `completed` `dropped` `wishlist`. completed means 100%.
- `platform`
- `owned`
- `format`: one of `cart` `disc` `digital` `emulated`. How they have it.
- `rating`: 1 to 10 (shown as five hearts, in halves).
- `notes`
- `collection_id`: A collection (library) id from list_collections. Defaults to the user's own library.

### DELETE https://blinky.spooky.click/api/games/:entry_id — `delete_game`

Removes a game and its play log from the library. Can't be undone. Needs `delete`.

- `entry_id` (required): A library entry id (one game on one platform in one library), from list_games, add_game or clyde.

### POST https://blinky.spooky.click/api/games/:entry_id/plays — `log_play`

Logs that the user played a game on a day, optionally with a result, rating and notes. A result moves the game's status (beaten, completed, dropped); a play with no result moves a backlog or wishlist game to playing; a rating becomes the game's rating. Not idempotent. Needs `write`.

- `entry_id` (required): A library entry id (one game on one platform in one library), from list_games, add_game or clyde.
- `played_on` (required): YYYY-MM-DD, in the user's own day.
- `result`: one of `beaten` `completed` `dropped`. completed means 100%.
- `rating`: 1 to 10 (shown as five hearts, in halves).
- `notes`

### PATCH https://blinky.spooky.click/api/plays/:play_id — `update_play`

Changes a logged play. Partial; null clears result, rating or notes. Doesn't change the game's status. Needs `write`.

- `play_id` (required)
- `played_on`
- `result`: one of `beaten` `completed` `dropped`
- `rating`: 1 to 10 (shown as five hearts, in halves).
- `notes`

### DELETE https://blinky.spooky.click/api/plays/:play_id — `delete_play`

Deletes one logged play. Needs `write`.

- `play_id` (required)

### GET https://blinky.spooky.click/api/plays — `list_recent_plays`

The most recent plays logged in a library, newest first.

- `collection_id`: A collection (library) id from list_collections. Defaults to the user's own library.
- `limit`: Default 20.

### GET https://blinky.spooky.click/api/search — `search_igdb`

Searches IGDB for games to add. Each result has igdb_id, name, year, platforms and in_library (entries the user already has of it).

- `q` (required): The game's name.

### GET https://blinky.spooky.click/api/clyde — `clyde`

Clyde, the random picker: one game to play next from a library, by default from the backlog and games in progress. Takes the same filters as list_games.

- `collection_id`: A collection (library) id from list_collections. Defaults to the user's own library.
- `platform`: A platform as stored, e.g. SNES, NES, Genesis/MegaDrive.
- `owned`
- `format`: one of `cart` `disc` `digital` `emulated`. How they have it.
- `decade`: Release decade, e.g. 1990.
- `status`: playing, backlog, beaten, completed (100%), dropped or wishlist, or several separated by commas; default backlog,playing
- `alternates`: Also return this many other picks.

### GET https://blinky.spooky.click/api/stats — `get_stats`

Pinky's scoreboard for a library: totals, games beaten per year (by the first beaten/100% play; 'undated' if none), per platform and per release decade.

- `collection_id`: A collection (library) id from list_collections. Defaults to the user's own library.

## Examples

**"I beat Super Metroid last night."** `GET /api/games?q=super metroid`. If it's there, `POST
/api/games/<entry_id>/plays` with `{"played_on":"<yesterday>","result":"beaten"}`. If not,
`GET /api/search?q=super metroid`, then `POST /api/games` with `{"igdb_id":1103,"platform":"SNES",
"status":"beaten","finished_on":"<yesterday>"}`.

**"What should I play next on the Genesis?"** `GET /api/clyde?platform=Genesis/MegaDrive&alternates=2`
(take the exact platform name from `list_games`).

**"I just bought a boxed copy of EarthBound."** Find it with `list_games?q=earthbound`; if it's
on the wishlist, `PATCH /api/games/<entry_id>` with `{"status":"backlog","owned":true,"format":"cart"}`.

**"How many games did I beat this year?"** `GET /api/stats` and read `beaten_per_year`.

**"Share my library with Anne."** Make a shared library (`POST /api/collections`), then
`POST /api/collections/<id>/invites` and give the user the `url`.
