Skip to content

Latest commit

 

History

History
188 lines (138 loc) · 6.27 KB

File metadata and controls

188 lines (138 loc) · 6.27 KB

⤴️ Back to the TypeScript/JavaScript Client README · Full API migration guide

TypeScript/JavaScript Client — v1 to v2 Migration

Important

New client versions default to https://neuro.appstun.net/api/v2. v1 (/api/v1) is deprecated and will be turned off on 2026-11-01.

This guide covers changes in NeuroInfoAPI-Client.ts / .js when upgrading from the v1-default client to the v2-default client. For raw HTTP migration (envelopes, endpoint renames), see the full API migration guide.

Quick checklist

  1. Update to the latest client files or neuroinfoapi-client npm package.
  2. Remove manual baseUrl: ".../api/v1" unless you intentionally stay on v1 during transition.
  3. Replace schedule.isFinal checks with status or isScheduleFinal(status).
  4. Update getVod call sites: parameter renamed from streamId to id.
  5. Update getSchedule call sites: argument order is now (week, year?).
  6. Replace getCurrentSubathons() path expectation: server route is now /subathon.
  7. Stop using getSubathonYears(true) / ?detailed.
  8. Use getDevstreamTimes() for devstream timestamps.
  9. Blog: use result.data.entries, not result.data.data.entries.
  10. WebSocket: default URL is /api/v2/ws; handle scheduleUpdate.status instead of isFinal.

Default configuration

Option v1 client v2 client
REST baseUrl https://neuro.appstun.net/api/v1 https://neuro.appstun.net/api/v2
WS baseUrl wss://neuro.appstun.net/api/ws wss://neuro.appstun.net/api/v2/ws
Response unwrapping None Unwraps { data: T }
HTTP dependency Older external helper Built-in HttpClient on top of standard fetch

request() and ApiResult<T>

The client still returns { data, error } — that is the client result type, not the HTTP envelope.

v1 behavior

private async request<T>(url: string, params?: Record<string, any>): Promise<ApiResult<T>> {
  const response = await this.apiInstance.request<T>(url, { query: params });
  return { data: response, error: null };
}

v2 behavior

private async request<T>(url: string, params?: Record<string, any>): Promise<ApiResult<T>> {
  const response = await this.apiInstance.request<any>(url, { query: params });
  const data =
    response && typeof response === "object" && "data" in response ? response.data : response;
  return { data: data as T, error: null };
}

Method and path changes

Method v1 v2
getVod(id) GET /twitch/vod?streamId= GET /twitch/vod?id=
getSchedule(week, year?) was getSchedule(year?, week?) week is required first argument
getCurrentSubathons() GET /subathon/current GET /subathon
getBlogFeed(raw?) GET /blog/feed GET /blog
getSubathonYears(detailed?) ?detailed overload always year -> name map
getDevstreamTimes() not available GET /devstream/times

Blog feed typing fix

Older client typings could force:

const { data } = await client.getBlogFeed();
const entries = data?.data?.entries;

Now use:

const { data } = await client.getBlogFeed();
const entries = data?.entries;

Schedule isFinal -> status

REST types

// v1
interface ScheduleResponse {
  year: number;
  week: number;
  schedule: ScheduleEntry[];
  isFinal: boolean;
}

// v2
type ScheduleStatus = "confirmed" | "auto_discord" | "auto_twitch";

interface ScheduleResponse {
  year: number;
  week: number;
  schedule: ScheduleEntry[];
  status: ScheduleStatus;
}

Helper

v2 exports isScheduleFinal(status):

import { isScheduleFinal } from "./NeuroInfoAPI-Client";

const { data } = await client.getLatestSchedule();
if (data && !isScheduleFinal(data.status)) {
  console.log("Schedule may still change");
}

NeuroApiError

v2 adds optional fields from the REST error envelope:

class NeuroApiError {
  code: string;
  message: string;
  status?: number;
  timestamp?: number;
  path?: string;
}

WebSocket client

v1 default v2 default
URL wss://neuro.appstun.net/api/ws wss://neuro.appstun.net/api/v2/ws
scheduleUpdate type isFinal status

Ticket auth now defaults to GET /api/v2/ws/ticket when the WebSocket URL is /api/v2/ws.

NeuroInfoApiEventer (deprecated)

The polling-based eventer still works, but prefer NeuroInfoApiWebsocketClient for new work.

NPM package

npm install neuroinfoapi-client@latest

Migration examples

Before

import { NeuroInfoApiClient } from "neuroinfoapi-client";

const client = new NeuroInfoApiClient("token");
const schedule = await client.getLatestSchedule();
if (schedule.data?.isFinal) console.log("Final schedule");

After

import { NeuroInfoApiClient, isScheduleFinal } from "neuroinfoapi-client";

const client = new NeuroInfoApiClient("token");
const schedule = await client.getLatestSchedule();
if (schedule.data && isScheduleFinal(schedule.data.status)) {
  console.log("Final schedule");
}

What did not change

  • ApiResult<T> pattern: { data: T | null, error: NeuroApiError | null }
  • setApiToken() / Bearer auth
  • 10s timeout default
  • WebSocket event names except the scheduleUpdate payload shape

See also