### Quick start: HttpSession, ApiClient, WebClient Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Quick start example showing how to create an HttpSession, use the public ApiClient to search series, and use the WebClient with login to get a profile. ```typescript import { HttpSession, ApiClient, WebClient } from "ichime-ts-api-client"; // Создаем сессию const session = new HttpSession("https://smotret-anime.com"); // Используем публичный API const apiClient = new ApiClient(session); const series = await apiClient.listSeries({ query: "naruto" }); // Или веб-клиент с авторизацией const webClient = new WebClient(session); await webClient.login("username", "password"); const profile = await webClient.getProfile(); ``` -------------------------------- ### WebClient instantiation example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/05-web-client.md Example of creating a WebClient instance with an HttpSession and debug enabled. ```typescript import { HttpSession, WebClient } from "ichime-ts-api-client"; const session = new HttpSession("https://smotret-anime.com"); const client = new WebClient(session, { debug: true }); ``` -------------------------------- ### Install dependencies with pnpm Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Installs project dependencies using pnpm. Requires Node.js >= 24.0.0 and pnpm. ```bash pnpm install ``` -------------------------------- ### listEpisodes usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/01-api-client.md Example usage of listEpisodes with options. It calls the method with seriesId, limit, and offset, then iterates over the returned episodes and logs their id, episodeFull, and firstUploadedDateTime as an ISO string. ```typescript const episodes = await client.listEpisodes({ seriesId: 12345, limit: 50, offset: 0 }); for (const ep of episodes) { console.log(ep.id, ep.episodeFull, ep.firstUploadedDateTime.toISOString()); } ``` -------------------------------- ### Install ichime-ts-api-client with pnpm Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/README.md Install the ichime-ts-api-client package from npm using pnpm. Requires Node.js >=24.0.0 and the package is distributed as an ESM module. ```bash pnpm add ichime-ts-api-client ``` -------------------------------- ### Install ichime-ts-api-client with pnpm, npm, or yarn Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/llms.txt Install the ichime-ts-api-client library using pnpm, npm, or yarn. Requires Node.js >= 24.0.0 and ESM modules (type: "module" in package.json). ```bash # pnpm (рекомендуется) pnpm add ichime-ts-api-client # npm npm install ichime-ts-api-client # yarn yarn add ichime-ts-api-client ``` -------------------------------- ### getRecentEpisodes usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/05-web-client.md Example of calling getRecentEpisodes and logging the series title and upload timestamp for each episode. ```typescript const recent = await client.getRecentEpisodes(2); recent.forEach((ep) => console.log(ep.seriesTitleRomaji, ep.episodeUploadedAt?.toISOString())); ``` -------------------------------- ### setCookie(name, value) usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/02-http-session.md Example of manually setting a cookie named 'theme' to 'dark'. ```typescript await session.setCookie("theme", "dark"); ``` -------------------------------- ### Login with WebClient.login Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/llms.txt Authenticates the WebClient using email and password. Throws WebClientError on failure; the example logs success or the error message. ```typescript import { HttpSession, WebClient, WebClientError } from "ichime-ts-api-client"; const session = new HttpSession("https://smotret-anime.com"); const client = new WebClient(session); try { await client.login("user@example.com", "password123"); console.log("Авторизация успешна"); } catch (error) { if (error instanceof WebClientError) { console.error("Ошибка авторизации:", error.message); } } ``` -------------------------------- ### getSeries: fetch full series info Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Get full series information using getSeries and log titles, descriptions, and genres. ```typescript const series = await client.getSeries(12345); console.log(series.titles, series.descriptions, series.genres); ``` -------------------------------- ### getEpisode: fetch full episode info Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Get full episode information using getEpisode and log translations. ```typescript const episode = await client.getEpisode(67890); console.log(episode.translations); ``` -------------------------------- ### getEpisode basic call Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/01-api-client.md Basic usage example for getEpisode. It fetches an episode by ID and logs its full data and translations. The method returns a Promise. ```typescript const episode = await client.getEpisode(67890); console.log(episode.episodeFull, episode.translations.length); for (const t of episode.translations) { console.log(t.id, t.typeKind, t.typeLang, t.authorsSummary); } ``` -------------------------------- ### Get moments list Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Retrieves a list of moments, optionally sorted (e.g., "popular"), and logs title, source description, and duration. ```typescript import type { MomentSorting } from "ichime-ts-api-client"; const moments = await client.getMoments(1, "popular"); for (const moment of moments) { console.log(moment.momentTitle, moment.sourceDescription, moment.durationSeconds); } ``` -------------------------------- ### GET /?ajax=m-index-personal-episodes[&pageP={page}] Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/endpoints.md Retrieves personal episodes for the authenticated user. Requires authentication. The `pageP` parameter is added only when `page > 1`. ```APIDOC ## GET /?ajax=m-index-personal-episodes[&pageP={page}] ### Description Retrieves personal episodes for the authenticated user. Requires authentication. The `pageP` parameter is added only when `page > 1`. ### Method GET ### Endpoint /?ajax=m-index-personal-episodes[&pageP={page}] ### Parameters #### Query Parameters - **ajax** (string) - Required - Fixed value "m-index-personal-episodes". - **pageP** (integer) - Optional - Page number, added only when page > 1. ### Response #### Success Response (200) - HTML content. Parses elements `#m-index-personal-episodes div.m-new-episode` into NewPersonalEpisode[] array. Invalid elements are skipped. ``` -------------------------------- ### Get moment details Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Retrieves details for a moment by its ID and logs series ID, series title, and episode ID. ```typescript const details = await client.getMomentDetails(99999); console.log(details.seriesId, details.seriesTitle, details.episodeId); ``` -------------------------------- ### GET /api/series Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/llms.txt Performs a GET request with a custom timeout. ```APIDOC ## [GET] /api/series ### Description Performs a GET request with a custom timeout. ### Method GET ### Endpoint /api/series ### Parameters #### Query Parameters - **timeout** (number) - Optional - Timeout in milliseconds (default 10000). ### Request Example { "timeout": 15000 } ### Response #### Success Response (200) - **response** (object) - The response body. #### Response Example { "timeout": 15000 } ``` -------------------------------- ### Build project with pnpm Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Builds the project using pnpm. ```bash pnpm build ``` -------------------------------- ### constructor(baseUrl: string) Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/02-http-session.md Creates a new HttpSession instance with the specified base URL. Initializes a CookieJar for cookie storage. ```APIDOC ## constructor(baseUrl: string) ### Description Creates a new HttpSession instance with the specified base URL. Initializes a CookieJar for cookie storage. ### Method constructor ### Parameters - **baseUrl** (string) - Required - Base URL of the site (e.g., "https://smotret-anime.com"). Used for resolving relative paths and as the default cookie domain. ### Request Example ```typescript import { HttpSession } from "ichime-ts-api-client"; const session = new HttpSession("https://smotret-anime.com"); ``` ### Response No return value. ``` -------------------------------- ### getCookieString() usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/02-http-session.md Example of calling getCookieString to obtain a cookie header string and logging it. ```typescript const cookieHeader = await session.getCookieString(); console.log(cookieHeader); ``` -------------------------------- ### getCookie(name) usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/02-http-session.md Example of calling getCookie to retrieve a cookie named 'csrf' and logging its value. ```typescript const csrf = await session.getCookie("csrf"); console.log(csrf); // значение или undefined ``` -------------------------------- ### constructor(session: HttpSession, config?: WebClientConfig) Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/05-web-client.md Creates a new WebClient instance with the given HTTP session and optional configuration. The session holds authentication cookies, and the config can enable debug logging. ```APIDOC ## constructor(session: HttpSession, config?: WebClientConfig) ### Description Creates a new WebClient instance. The session is required and holds authentication cookies. The optional config can enable debug logging. ### Method constructor ### Endpoint N/A (constructor) ### Parameters #### Constructor Parameters - **session** (HttpSession) - Required - HTTP session (authentication cookies live here) - **config** (WebClientConfig) - Optional - Configuration object, defaults to `{}` - **config.debug** (boolean) - Optional - Enable request/error logging via `console.debug`, defaults to `false` ### Request Example ```typescript import { HttpSession, WebClient } from "ichime-ts-api-client"; const session = new HttpSession("https://smotret-anime.com"); const client = new WebClient(session, { debug: true }); ``` ### Response #### Success Response (200) - **client** (WebClient) - The created WebClient instance #### Response Example ```typescript const client = new WebClient(session, { debug: true }); ``` ``` -------------------------------- ### Create ApiClient with HttpSession and debug config Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/01-api-client.md Example of creating an ApiClient instance with a debug-enabled configuration. Imports HttpSession and ApiClient from the package, creates a session with the base URL, and passes it to the client constructor. ```typescript import { HttpSession, ApiClient } from "ichime-ts-api-client"; const session = new HttpSession("https://smotret-anime.com"); const client = new ApiClient(session, { debug: true }); ``` -------------------------------- ### getAnimeListEditableEntry usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/05-web-client.md Example usage of getAnimeListEditableEntry with seriesId 12345. Logs the entry's status, score, and commentary. ```typescript const entry = await client.getAnimeListEditableEntry(12345); console.log(entry.status, entry.score, entry.commentary); ``` -------------------------------- ### getMomentDetails usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/05-web-client.md Example usage of getMomentDetails. Calls the method with momentId 99999 and logs the seriesTitle and episodeId from the returned details. ```typescript const details = await client.getMomentDetails(99999); console.log(details.seriesTitle, details.episodeId); ``` -------------------------------- ### WebClient constructor Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/llms.txt Creates a new WebClient instance using an HttpSession. The session is initialized with the base URL of the target website. ```APIDOC ## WebClient Constructor ### Description Creates a new WebClient instance for web scraping. Requires an HttpSession with the base URL. ### Method Constructor ### Endpoint `new WebClient(session)` ### Parameters - **session** (HttpSession) - Required - An HttpSession instance initialized with the base URL. ### Request Example ```typescript import { HttpSession, WebClient } from "ichime-ts-api-client"; const session = new HttpSession("https://smotret-anime.com"); const client = new WebClient(session); ``` ### Response Returns a WebClient instance. ``` -------------------------------- ### getMomentEmbed — Get moment video URL Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/llms.txt Gets the direct video URL for a moment. Requires authentication via login() before calling. ```typescript import { HttpSession, WebClient } from "ichime-ts-api-client"; import type { MomentEmbed } from "ichime-ts-api-client"; const session = new HttpSession("https://smotret-anime.com"); const client = new WebClient(session); await client.login("user@example.com", "password123"); const embed: MomentEmbed = await client.getMomentEmbed(99999); console.log(embed.videoUrl); // "https://video.smotret-anime.com/..." ``` -------------------------------- ### isEmptyDate usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/03-date-decoder.md Example of using isEmptyDate with a placeholder date and a real date. Note that the function expects a Date object, not a string. ```typescript import { isEmptyDate, parseApiDate } from "ichime-ts-api-client"; const placeholder = parseApiDate("2000-01-01 00:00:00"); const real = parseApiDate("2024-01-15 14:30:00"); console.log(isEmptyDate(placeholder)); // true console.log(isEmptyDate(real)); // false ``` -------------------------------- ### Run tests with pnpm Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Runs the test suite using pnpm. ```bash pnpm test ``` -------------------------------- ### Example: getTranslationEmbed usage Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/01-api-client.md Example usage of getTranslationEmbed. It fetches the translation embed for ID 111222, iterates over the streams to log their URLs, and logs the subtitlesVttUrl. ```typescript const embed = await client.getTranslationEmbed(111222); for (const stream of embed.stream) { console.log(`${stream.height}p:`, stream.urls); } console.log("Субтитры:", embed.subtitlesVttUrl); ``` -------------------------------- ### POST /users/login Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/endpoints.md Logs in a user with username and password. The response is HTML; success is determined by the absence of error strings. On failure, a WebClientError is thrown. ```APIDOC ## POST /users/login ### Description Logs in a user with username and password. The response is HTML; success is determined by the absence of error strings. On failure, a WebClientError is thrown. ### Method POST ### Endpoint /users/login ### Parameters #### Request Body (application/x-www-form-urlencoded) - **LoginForm[username]** (string) - Required - The username parameter. - **LoginForm[password]** (string) - Required - The password parameter. - **dynpage** (string) - Required - Fixed value "1". - **yt0** (string) - Required - Empty string. ### Response #### Success Response (200) - HTML content. Success if the HTML does not contain "Неверный E-mail или пароль." and "Вход по паролю". Otherwise, a WebClientError("Invalid credentials") is thrown. #### Error Response (>= 400) - WebClientError.badStatusCode. ``` -------------------------------- ### WebClientError constructor Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/07-web-errors.md Creates a new WebClientError instance with a specified error message. ```APIDOC ## WebClientError constructor ### Description Creates a new WebClientError instance with a specified error message. ### Method constructor ### Signature ```ts constructor(message: string) ``` ### Parameters - **message** (string) - Required - The error message. ### Properties - Inherits from `Error` with `name = "WebClientError"`. ``` -------------------------------- ### getTranslation usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/01-api-client.md Example usage of getTranslation. It calls the method with a translation ID and logs the series title and episode full name from the returned translation object. ```typescript const translation = await client.getTranslation(111222); console.log(translation.series.title, translation.episode.episodeFull); ``` -------------------------------- ### parseApiDate basic usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/03-date-decoder.md Example of calling parseApiDate with a valid date string. The resulting Date is in UTC, so the output shows the time shifted by -3 hours. ```typescript import { parseApiDate } from "ichime-ts-api-client"; const date = parseApiDate("2024-01-15 14:30:00"); console.log(date.toISOString()); // 2024-01-15T11:30:00.000Z ``` -------------------------------- ### Lint code with pnpm Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Runs the linter using pnpm. ```bash pnpm lint ``` -------------------------------- ### login(username, password) Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/05-web-client.md Аутентификация пользователя через POST /users/login. ```APIDOC ## `login(username, password)` ### Description Отправляет `POST /users/login` с формой `LoginForm[username]`, `LoginForm[password]`, `dynpage=1`, `yt0=""`. Если в ответе встречается `"Неверный E-mail или пароль."` или `"Вход по паролю"` — бросает `new WebClientError("Invalid credentials")`. ### Method `login` ### Signature ```ts async login(username: string, password: string): Promise ``` ### Parameters - `username` (string) - Required - E-mail/логин - `password` (string) - Required - Пароль ### Returns `Promise` при успехе. ### Request Example ```typescript await client.login("user@example.com", "password123"); ``` ### Error Handling ```typescript import { WebClientError } from "ichime-ts-api-client"; try { await client.login("bad@example.com", "wrong"); } catch (error) { if (error instanceof WebClientError) { console.error(error.message); // "Invalid credentials" } } ``` ``` -------------------------------- ### editAnimeListEntry usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/05-web-client.md Example usage of editAnimeListEntry. Passes seriesId 12345, score 8, episodes 5, status AnimeListEntryStatusNumericId.watching, and a comment. Requires an existing client instance. ```typescript import { AnimeListEntryStatusNumericId } from "ichime-ts-api-client"; await client.editAnimeListEntry(12345, 8, 5, AnimeListEntryStatusNumericId.watching, "Отличное аниме!"); ``` -------------------------------- ### getAnimeList usage example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/05-web-client.md Example usage of getAnimeList with userId 100500 and category "watching". Logs the first entry's series title and watched episodes. ```typescript const watching = await client.getAnimeList(100500, "watching"); console.log(watching[0]?.seriesTitleFull, watching[0]?.episodesWatched); ``` -------------------------------- ### Error handling example with WebClient Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/07-web-errors.md Shows how to catch and handle WebClientError and ApiClientError when using WebClient. It logs the error message and cause, and notes that ApiClientError indicates the session is also used by ApiClient. ```typescript import { ApiClientError, HttpSession, WebClient, WebClientError } from "ichime-ts-api-client"; const client = new WebClient(new HttpSession("https://smotret-anime.com")); try { await client.getProfile(); } catch (error) { if (error instanceof WebClientError) { // "Authentication required" — нужно вызвать login() с валидными данными console.error(error.message); console.error(error.cause); // для unknownError — исходная ошибка транспорта } else if (error instanceof ApiClientError) { // сессия используется и ApiClient'ом } } ``` -------------------------------- ### listSeries with MAL ID and chips options Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/01-api-client.md Example using non-standard options: filtering by MyAnimeList ID and using chips with limit and offset. The first call returns an array with a single series. ```typescript const byMal = await client.listSeries({ myAnimeListId: 16498 }); console.log(byMal); // массив с одним сериалом const filtered = await client.listSeries({ chips: { "genres": "1", "years.0": "2023" }, limit: 10, offset: 20, }); ``` -------------------------------- ### login Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/llms.txt Authenticates the user on the website using email and password. Throws WebClientError on failure. ```APIDOC ## login ### Description Authenticates the user on the website using email and password. Throws WebClientError on failure. ### Method `client.login(email, password)` ### Parameters - **email** (string) - Required - User's email address. - **password** (string) - Required - User's password. ### Request Example ```typescript await client.login("user@example.com", "password123"); ``` ### Response Resolves on success. Throws WebClientError on failure. ``` -------------------------------- ### Format code with pnpm Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Formats the codebase using pnpm. ```bash pnpm format ``` -------------------------------- ### parseApiDate error handling example Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/03-date-decoder.md Example showing how parseApiDate throws an Error when the input string lacks a space between date and time, and notes that an invalid date with a correct separator also throws an Error. ```typescript try { parseApiDate("2024-01-15T14:30:00"); // нет пробела между датой и временем } catch (error) { console.error((error as Error).message); // "Invalid date format: 2024-01-15T14:30:00" } // Невалидная дата с корректным разделителем бросает "Invalid date: ..." // parseApiDate("2024-13-45 99:99:99") → Error("Invalid date: ...") ``` -------------------------------- ### GET /api/series Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/endpoints.md Lists anime series with optional filters. ```APIDOC ## GET /api/series ### Description Retrieves a list of anime series. This endpoint is called by the `listSeries(options?)` method of the `ApiClient`. ### Method GET ### Endpoint /api/series ### Parameters #### Query Parameters - **query** (string) - Optional - Search query for series. - **limit** (number) - Optional - Maximum number of series to return. - **offset** (number) - Optional - Number of series to skip. - **chips** (string) - Optional - Serialized as "k1=v1;k2=v2" (pairs sorted by key). - **myAnimeListId** (number) - Optional - Filter by MyAnimeList ID. ### Response #### Success Response (200) - **data** (Series[]) - Array of series objects. #### Response Example { "data": [ { "id": 1, "name": "Example Series" } ] } ### Errors 403/404/other errors return an `ApiClientError`. ``` -------------------------------- ### RequestOptions Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/types.md Options interface for HTTP requests, extending RequestInit with a timeout. ```APIDOC ## RequestOptions ### Description Extends `RequestInit` (excluding `dispatcher`) with a `timeout` option. Used for HTTP requests. ### Type `interface` ### Fields - **timeout** (`number`) - Optional - Timeout in milliseconds (default 10000). - Inherits all fields from `RequestInit` except `dispatcher`. ### Source `src/http-session.ts:3-5` ``` -------------------------------- ### GET /api/episodes/{episodeId} Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/endpoints.md Fetches full details of a single episode by its ID. ```APIDOC ## GET /api/episodes/{episodeId} ### Description Retrieves detailed information about a specific episode. Called by `getEpisode(episodeId)`. ### Method GET ### Endpoint /api/episodes/{episodeId} ### Parameters #### Path Parameters - **episodeId** (number) - Required - The ID of the episode. ### Response #### Success Response (200) - **data** (EpisodeFull) - Full episode object including `seriesId` and `translations`. #### Response Example { "data": { "id": 1, "seriesId": 1, "name": "Episode 1", "translations": [] } } ### Errors 403/404/other errors return an `ApiClientError`. ``` -------------------------------- ### ApiClient constructor Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/01-api-client.md Constructor for the ApiClient class. It initializes the client with an HttpSession and optional configuration. ```APIDOC ## Constructor ### Description Creates a new instance of the ApiClient with the provided HTTP session and optional configuration. ### Method constructor ### Endpoint new ApiClient(session, config?) ### Parameters #### Parameters - **session** (HttpSession) - Required - HTTP session with base URL and cookie storage - **config** (ApiClientConfig) - Optional - Configuration object - **config.debug** (boolean) - Optional - Enables console.debug/console.warn/console.error logging for requests, JSON decoding, and API errors ### Request Example ```typescript import { HttpSession, ApiClient } from "ichime-ts-api-client"; const session = new HttpSession("https://smotret-anime.com"); const client = new ApiClient(session, { debug: true }); ``` ### Response No response body. The constructor returns an ApiClient instance. ``` -------------------------------- ### GET /api/series/{seriesId} Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/endpoints.md Fetches full details of a single series by its ID. ```APIDOC ## GET /api/series/{seriesId} ### Description Retrieves detailed information about a specific series. Called by `getSeries(seriesId)`. ### Method GET ### Endpoint /api/series/{seriesId} ### Parameters #### Path Parameters - **seriesId** (number) - Required - The ID of the series. ### Response #### Success Response (200) - **data** (SeriesFull) - Full series object. Nested `genres`, `descriptions`, `episodes` may be null. Episode `firstUploadedDateTime` is a Date. #### Response Example { "data": { "id": 1, "name": "Example Series", "genres": null, "descriptions": null, "episodes": null } } ### Errors 403/404/other errors return an `ApiClientError`. ``` -------------------------------- ### GET /api/episodes Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/01-api-client.md Retrieves a list of episodes with optional filtering by series and pagination. ```APIDOC ## [GET] /api/episodes ### Description Retrieves a list of episodes, optionally filtered by series ID, with pagination support. ### Method GET ### Endpoint /api/episodes ### Parameters #### Query Parameters - **seriesId** (number) - Optional - ID of the series to filter episodes by. - **limit** (number) - Optional - Maximum number of episodes to return. - **offset** (number) - Optional - Number of episodes to skip for pagination. ### Request Example ```typescript const episodes = await client.listEpisodes({ seriesId: 12345, limit: 50, offset: 0 }); ``` ### Response #### Success Response (200) - **episodes** (Episode[]) - List of episodes. Each episode includes `firstUploadedDateTime` as a `Date`. #### Response Example ```typescript for (const ep of episodes) { console.log(ep.id, ep.episodeFull, ep.firstUploadedDateTime.toISOString()); } ``` ### Errors - **ApiClientError** - Rejects with this error on failure. ``` -------------------------------- ### Настройка окружения для разработки Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/llms.txt Команды для клонирования репозитория и установки зависимостей с помощью pnpm. ```bash # Клонировать репозиторий git clone https://github.com/dimensi/ichime-ts-api-client.git cd ichime-ts-api-client # Установить зависимости pnpm install ``` -------------------------------- ### GET /moments/{momentId} Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/endpoints.md Retrieves detailed information about a specific moment. Requires authentication. ```APIDOC ## GET /moments/{momentId} ### Description Retrieves detailed information about a specific moment. Requires authentication. ### Method GET ### Endpoint /moments/{momentId} ### Parameters #### Path Parameters - **momentId** (string) - Required - The identifier of the moment. ### Response #### Success Response (200) - **HTML** - Expected to contain exactly 2 links in `.m-moment-player h3 a[href]`: the first is the episode URL `/catalog/{seriesId}-…/{episodeId}-…` (parsed via `extractIdentifiersFromUrl`), the second is the series title. Maps to `MomentDetails`. ### Error Handling - Requires authentication; otherwise throws `WebClientError.authenticationRequired()`. - If the HTML structure is violated, throws `WebClientError.couldNotParseHtml()`. - Non-2xx status codes throw `WebClientError.badStatusCode(status)`. ``` -------------------------------- ### Get moment embed URL Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Fetches the video URL for a moment by its ID and logs it. ```typescript const embed = await client.getMomentEmbed(99999); console.log(embed.videoUrl); ``` -------------------------------- ### Create WebClient with HttpSession Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Creates a WebClient instance using an HttpSession with the base URL of the target site. Required before calling any authenticated methods. ```typescript import { HttpSession, WebClient } from "ichime-ts-api-client"; const session = new HttpSession("https://smotret-anime.com"); const client = new WebClient(session); ``` -------------------------------- ### ApiClientError Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/04-api-errors.md Documentation for the ApiClientError class, its constructor, properties, and static factory methods. ```APIDOC ## ApiClientError ### Description Wrapper class for all API client errors: transport, decoding, and API errors. ### Constructor ```ts constructor(message: string, cause?: ApiError | Error) ``` #### Parameters - **message** (string) - Required - Error message text. - **cause** (ApiError | Error) - Optional - Underlying cause; becomes a public readonly property `cause`. ### Properties - Inherits from `Error` (`.name = "ApiClientError"`). - `cause?: ApiError | Error` - readonly. ### Static Methods #### `ApiClientError.canNotDecodeResponseJson(error?)` ##### Description Creates an `ApiClientError` indicating that the response body could not be decoded as JSON, or the JSON is neither `{ data }` nor `{ error: { code, message } }`. ##### Signature ```ts static canNotDecodeResponseJson(error?: Error): ApiClientError ``` ##### Parameters - **error** (Error) - Optional - The `JSON.parse` error, if any. ##### Message `"Cannot decode response JSON"` #### `ApiClientError.apiError(error)` ##### Description Creates an `ApiClientError` wrapping an API error. ##### Signature ```ts static apiError(error: ApiError): ApiClientError ``` ##### Parameters - **error** (ApiError) - Required - The API error. ##### Message `"API error: {error.message}"`; `cause` is the provided `ApiError`. #### `ApiClientError.requestFailed(error?)` ##### Description Creates an `ApiClientError` indicating that the underlying HTTP request failed. ##### Signature ```ts static requestFailed(error?: Error): ApiClientError ``` ##### Parameters - **error** (Error) - Optional - The transport error from `HttpSession.request`. ##### Message `"Request failed"` ``` -------------------------------- ### Get moments by series Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/README.md Fetches moments for a specific series by its ID and page number. ```typescript const moments = await client.getMomentsBySeries(12345, 1); ``` -------------------------------- ### Быстрый старт: создание сессии, публичный API и веб-клиент Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/README.md Пример инициализации HttpSession с базовым URL, использования ApiClient для публичного JSON API без авторизации и WebClient для авторизованных запросов. Показывает методы listSeries, login и getProfile. ```typescript import { HttpSession, ApiClient, WebClient } from "ichime-ts-api-client"; const session = new HttpSession("https://smotret-anime.com"); // Публичный JSON API — без авторизации const apiClient = new ApiClient(session); const series = await apiClient.listSeries({ query: "naruto" }); // Веб-клиент с авторизацией const webClient = new WebClient(session); await webClient.login("username", "password"); const profile = await webClient.getProfile(); ``` -------------------------------- ### sendRequest(path, queryItems?) Source: https://github.com/dimensi/ichime-ts-api-client/blob/main/_autodocs/api-reference/05-web-client.md Performs a GET request to the specified path with optional query parameters. ```APIDOC ## `sendRequest(path, queryItems?)` ### Description Performs a GET request to the specified path relative to the base URL, with optional query parameters. Throws `WebClientError.unknownError()` on network failure and `WebClientError.badStatusCode(status)` if the response status is >= 400. ### Method GET ### Endpoint `{baseUrl}/{path}` ### Parameters #### Path Parameters - **path** (string) - Required - Path relative to `baseUrl`. #### Query Parameters - **queryItems** (Record) - Optional - Query parameters, sorted by name. Default: `{}`. ### Returns - `Promise` - HTML text of the response. Throws `WebClientError.couldNotConvertResponseDataToString()` if reading the response fails. ### Example ```ts const html = await client.sendRequest('/page', { q: 'search' }); ``` ```