Guidance for working in this repository.
allkeyshop-api — an unofficial TypeScript client for AllKeyShop.
Published to npm as a library (main → dist/src/allkeyshop.js). There is no server;
consumers import AllkeyshopService and call search() / find().
npm run build— compile withtsctodist/(emitsdist/src+dist/configonly).npm test— runsbuildthen Jest (ts-jest type-checks the tests).npm run check— Biome: format + lint + organise imports, with--write. Use this before committing.npm run lint/npm run format— lint-only / format-only.
The public surface is one class with two methods:
AllkeyshopService.search(name)→GameOffers— offers + lowest prices for the best-matching game.AllkeyshopService.find(name)→ProductIdsResponse— just the matching game names/ids, no pricing.
Constructor options: currency (default eur), platform (default PC; appended to the
search term, pc means none), store (default any; filters offers by merchant name).
Data flow for search():
gather.ts:getProductIds→fetch.ts:fetchAllGamesdownloads the full game catalog (vaks.php) once, caches it on disk (os.tmpdir(), 1-day TTL) and in memory, thenfilter.ts:filterByNamefuzzy-matches the name locally.gather.ts:getGameDatafetches pricing for the top match (price_history_api.php) and transforms the raw response into the cleanGameOffersshape (resolving merchant/ edition/region ids to names, parsing prices).filterByStorenarrows offers when astoreis set.
Files: allkeyshop.ts (public class) · gather.ts (lookup + pricing transform + public
types) · fetch.ts (catalog download/cache) · file.ts (cache dir) · filter.ts (fuzzy
filters) · config/constants.ts (defaults).
- Two external endpoints, both undocumented and unstable:
vaks.php(catalog) andprice_history_api.php(pricing). If search breaks, suspect an endpoint change first — that is exactly what 2.0.0 fixed. - Raw vs public types: the raw API shapes (
Raw*) are internal togather.ts; only the transformedOffer/LowestPrice/GameOfferstypes are exported. Keep that boundary. dist/is committed and shipped (files: ["dist"]). Rebuild it when source changes.- Tests are behavioural — assert observable behaviour, not implementation/existence.
Mocks live in
tests/mock/. - Formatting is Biome-enforced: single quotes, no semicolons, 2-space indent. Non-null
assertions are allowed in
tests/only.