export type GetApiV2AchievementsPlayerXuidTitleIdArgs = {xuid: string, titleId: string}; export type GetApiV2AchievementsPlayerXuidTitleIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get player achievements for a specific game * * GET /v2/achievements/player/{xuid}/{titleId} */ export const getApiV2AchievementsPlayerXuidTitleId = async (args: GetApiV2AchievementsPlayerXuidTitleIdArgs, options?: GetApiV2AchievementsPlayerXuidTitleIdOptions) => { const {baseUrl = "https://api.xbl.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v2/achievements/player/${encodeURIComponent(String(args.xuid))}/${encodeURIComponent(String(args.titleId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };