{"id":17311,"library":"nyro","title":"Nyro HTTP Request Library","description":"Nyro is a promise-based HTTP and HTTP/2 request library for JavaScript and TypeScript, currently stable at version 2.0.4. It offers comprehensive support for all HTTP methods and focuses on performance and flexibility, incorporating features like proxy support, request queueing, caching mechanisms, and built-in pagination APIs. The library provides robust error handling, retries, and configurable timeouts. While it ships with TypeScript types, it is primarily designed for Node.js environments. Its \"browser support\" refers to browser-like features within Node rather than client-side browser usage. The project appears actively maintained with recent updates and differentiates itself by providing advanced functionalities such as `bodySchema` for response validation and specialized proxy tools.","status":"active","version":"2.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/Bes-js/nyro","tags":["javascript","http","https","request","response","proxy","fastgate","agent","http-proxy-agent","typescript"],"install":[{"cmd":"npm install nyro","lang":"bash","label":"npm"},{"cmd":"yarn add nyro","lang":"bash","label":"yarn"},{"cmd":"pnpm add nyro","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Nyro is primarily an ESM module, direct CommonJS `require` can cause issues. Use dynamic import for CJS if necessary.","wrong":"const nyro = require('nyro');","symbol":"nyro","correct":"import nyro from 'nyro';"},{"note":"Named export for HTTP methods enum. Also available as a string literal, e.g., 'GET'.","wrong":"import nyro, { Method } from 'nyro';","symbol":"Method","correct":"import { Method } from 'nyro';"},{"note":"Named export for expected response type enum (e.g., 'json', 'text').","wrong":"import * as NyroTypes from 'nyro';","symbol":"ResponseType","correct":"import { ResponseType } from 'nyro';"},{"note":"Type import for the response object, useful for TypeScript applications to define the shape of the `await nyro(...)` result.","symbol":"NyroResponse","correct":"import type { NyroResponse } from 'nyro';"}],"quickstart":{"code":"import nyro, { ResponseType, Method } from 'nyro';\n\n(async() => {\n\n const { body, statusCode } = await nyro({\n    url: 'https://hercai.onrender.com/v3/hercai',\n    params: {\n        question: 'Hi How Are You?'\n    },\n    method: Method.Get, // Or 'GET'\n    responseType: ResponseType.Json, // Or 'json'\n    headers: {\n        'User-Agent': 'Nyro-App/1.0'\n    },\n    bodySchema: {\n        content: String,\n        reply: String\n    }\n });\n\n  console.log(`Status Code: ${statusCode}`);\n  console.log('Your Question; ' + body.content);\n  console.log('AI Reply; ' + body.reply);\n\n})();","lang":"typescript","description":"Demonstrates a basic promise-based GET request, including URL parameters, HTTP method, expected response type, custom headers, and response body schema validation using Nyro. It logs the status code and the parsed AI reply."},"warnings":[{"fix":"Migrate to ES module import syntax (`import ... from 'nyro';`) or use dynamic `import()` within CommonJS modules. Ensure your project's `package.json` specifies `\"type\": \"module\"` if it's an ESM project.","message":"Version 2.0.0 introduced significant changes, likely transitioning to an ESM-first architecture. This means direct `require()` statements in CommonJS modules might no longer work as expected and may require configuration changes or dynamic imports.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Do not attempt to use Nyro directly in a web browser. It is designed for server-side (Node.js) applications. For client-side, consider browser-native `fetch` or a dedicated browser-compatible HTTP client.","message":"The documentation mentions 'Browser Support (Node Only)'. This implies that certain browser-like features or configurations are available when running Nyro in a Node.js environment, but the library is not intended for direct client-side browser usage.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"The actual data payload should be passed via the `body` option. Use `bodySchema` purely for validation against a JavaScript type constructor (e.g., `String`, `Number`, `Object`, `Array`) or custom validation functions.","message":"The `bodySchema` option is for defining the *expected structure* of the request body for validation and type safety, not for defining the actual data payload to be sent. Incorrectly assuming it's the request body itself can lead to empty or malformed requests.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Exercise extreme caution and ensure legal and ethical compliance when using any features that could be construed as attack-oriented. Only use such features in controlled, authorized environments for legitimate security research or testing.","message":"Nyro includes a 'Layer7 Attack' feature. While potentially intended for security testing or load generation, using this functionality for malicious purposes is explicitly prohibited by the library's license and can lead to legal consequences.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"For ESM, ensure `import nyro from 'nyro';` is used. For CommonJS, if the library is ESM-only in v2+, you might need `const { default: nyro } = await import('nyro');` or configure your environment for ESM.","cause":"Attempting to call `nyro` as a function after using `const nyro = require('nyro');` in a CommonJS module, or due to incorrect default import in ESM.","error":"TypeError: nyro is not a function"},{"fix":"Either convert your consuming module to ESM by adding `\"type\": \"module\"` to your `package.json` and using `import` statements, or use a dynamic import: `const { default: nyro } = await import('nyro');`.","cause":"You are attempting to `require()` Nyro (which is an ESM module) from a CommonJS module, or your Node.js environment is not configured for ESM.","error":"ERR_REQUIRE_ESM: require() of ES Module .../node_modules/nyro/index.mjs from ... not supported."},{"fix":"Ensure `bodySchema` correctly reflects the expected runtime shape of the response body. If the schema is dynamic or very complex, you might need to manually assert the type: `const { body } = await nyro(...) as { body: ExpectedBodyType };`","cause":"When using TypeScript, the inferred type of the response might not match the expected structure, or the `bodySchema` is incorrectly defined.","error":"Property 'body' does not exist on type 'NyroResponse<any>'"},{"fix":"Ensure your proxy agent (e.g., `http-proxy-agent`, `https-proxy-agent`, `socks-proxy-agent`) matches the protocol of your proxy server. Also, verify that the `url` in your Nyro request matches the protocol expected by the agent.","cause":"Incorrect proxy agent configuration, often when mixing HTTP and HTTPS protocols for the proxy or target URL, or using an agent not compatible with the protocol.","error":"Error: Protocol 'http:' not supported by agent"}],"ecosystem":"npm","meta_description":null}