{"id":16136,"library":"narou","title":"Narou API Wrapper","description":"Narou is a TypeScript library that provides a fluent interface wrapper for the Narou Developer APIs (dev.syosetu.com), which allow programmatic access to data from the Japanese web novel publishing site Shousetsuka ni Narou. It supports various APIs including novel search, ranking retrieval, ranking history, and R18 novel search. The library currently stands at version 2.0.1, with recent releases showing active maintenance and minor bug fixes. It differentiates itself by offering a method-chaining syntax, full TypeScript type safety, and multi-environment compatibility, automatically selecting between native `fetch` for Node.js and JSONP for browser environments. It also boasts comprehensive coverage of all Narou Developer APIs, ensuring access to the full range of data provided by the Narou Developer Portal.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/deflis/node-narou","tags":["javascript","typescript"],"install":[{"cmd":"npm install narou","lang":"bash","label":"npm"},{"cmd":"yarn add narou","lang":"bash","label":"yarn"},{"cmd":"pnpm add narou","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Use named import for Node.js environments. CommonJS `require` is not supported for this ESM-first library.","wrong":"const { search } = require('narou')","symbol":"search","correct":"import { search } from 'narou'"},{"note":"Individual API functions are exported as named exports, not as a default export.","wrong":"import ranking from 'narou'","symbol":"ranking","correct":"import { ranking } from 'narou'"},{"note":"For browser environments, use the explicit '/browser' subpath import to enable JSONP and browser-specific optimizations.","wrong":"import { search } from 'narou'","symbol":"search","correct":"import { search } from 'narou/browser'"},{"note":"Enums and helper types like `Genre` are also named exports.","symbol":"Genre","correct":"import { Genre } from 'narou'"}],"quickstart":{"code":"import { search, ranking } from 'narou';\nimport { Genre, Order, RankingType } from 'narou';\n\nasync function getNovels() {\n  // Search for 'isekai' romance novels, ordered by favorite count\n  const searchResult = await search('異世界')\n    .genre(Genre.RenaiIsekai)\n    .order(Order.FavoriteNovelCount)\n    .limit(10)\n    .execute();\n\n  console.log(`Found ${searchResult.allcount} novels matching the criteria.`);\n  for (const novel of searchResult.values) {\n    console.log(`- ${novel.title} (NCODE: ${novel.ncode})`);\n  }\n\n  // Get daily ranking for a specific date\n  const rankingResult = await ranking()\n    .date(new Date('2023-04-01'))\n    .type(RankingType.Daily)\n    .execute();\n  \n  console.log('\\nDaily Ranking (2023-04-01):');\n  for (const novel of rankingResult) {\n    console.log(`- Rank ${novel.rank}: NCODE ${novel.ncode} (Points: ${novel.pt})`);\n  }\n}\n\ngetNovels().catch(console.error);","lang":"typescript","description":"This quickstart demonstrates searching for novels by keywords and genre, and retrieving daily rankings, showcasing the fluent API."},"warnings":[{"fix":"Ensure your Node.js environment is v18+ for native `fetch`, or provide a global `fetch` polyfill if using Node.js v16-v17. This usually does not require changes unless you had custom `fetchOptions`.","message":"Version 1.0.0 removed the internal `node-fetch` dependency. This might affect applications relying on specific `node-fetch` behavior or polyfills, as the library now uses native `fetch` in Node.js environments (which requires Node.js 18+ or a global polyfill for earlier Node.js 16+ versions).","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade your Node.js runtime to version 16.0.0 or later. Use `nvm` or a similar tool for managing Node.js versions.","message":"The package now requires Node.js version 16.0.0 or higher. Older Node.js versions are not supported and will lead to runtime errors or installation failures.","severity":"breaking","affected_versions":"<16.0.0"},{"fix":"Change your import statement from `import { search } from 'narou'` to `import { search } from 'narou/browser'` for browser builds.","message":"When targeting browser environments, a specific import path (`narou/browser`) is required. Importing from the main 'narou' package directly in a browser environment will result in module resolution errors or incorrect functionality as it's optimized for Node.js.","severity":"gotcha","affected_versions":">=0.9.0"},{"fix":"Upgrade to `narou@2.0.1` or later if you are using `rankingHistory` in a browser environment and rely on `fetchOptions`.","message":"While the library supports both Node.js and browser environments, the `rankingHistory` function in the browser version did not correctly respect `fetchOptions` prior to v2.0.1.","severity":"gotcha","affected_versions":">=1.0.0 <2.0.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Use ES module import syntax: `import { search } from 'narou';` instead of `const { search } = require('narou');`.","cause":"Attempting to use CommonJS `require()` syntax with this ESM-first library in a module context or a Node.js version configured for ESM.","error":"ReferenceError: require is not defined"},{"fix":"Ensure you are using `import { search } from 'narou'` for Node.js and `import { search } from 'narou/browser'` for browser environments. Check your bundler configuration to ensure correct module resolution.","cause":"Attempting to use the `narou/browser` specific import in a Node.js environment, or vice-versa, or an incorrect bundling setup.","error":"TypeError: (0, _narou_browser__WEBPACK_IMPORTED_MODULE_0__.search) is not a function"},{"fix":"Upgrade your Node.js environment to v18 or newer, or install a `fetch` polyfill (e.g., `node-fetch`) and ensure it's globally available before importing `narou`.","cause":"Running the Node.js version of the library in a Node.js environment older than v18, which does not have `fetch` globally available, after `node-fetch` was removed in v1.0.0.","error":"UnhandledPromiseRejectionWarning: TypeError: fetch is not a function"}],"ecosystem":"npm"}