Registry / devops / restyped-axios

restyped-axios

JSON →
library2.0.0jsnpmunverified

Axios wrapper with TypeScript typings for consuming RESTyped API definitions. Version 2.0.0 requires TypeScript 2.8+. Enforces type-safe HTTP requests: route paths, query parameters, request bodies, and responses are checked at compile time against a provided RESTyped interface. Differentiates from raw Axios by eliminating runtime errors from mismatched endpoints. Low release cadence; stable for RESTyped ecosystem.

npm install restyped-axios
INSTALL
IMPORT
SIG · RESTYPED-AXIOS
R
restyped-axios
devopsjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import axios from 'restyped-axios'
✗ const axios = require('restyped-axios')
ESM default export; CJS require works but loses type inference.
RESTypedAxiosInstance
✓ import { RESTypedAxiosInstance } from 'restyped-axios'
Type import for typed instance.
RESTypedAxiosClient
✓ import { RESTypedAxiosClient } from 'restyped-axios'
Type used for create() return type.

Demonstrates creating a typed Axios client with RESTyped API definition and making a request with typed params.

import axios from 'restyped-axios'; import { GiphyAPI } from 'restyped-giphy-api'; const client = axios.create<GiphyAPI>({ baseURL: 'http://api.giphy.com/v1', }); client.request({ url: '/gifs/trending', params: { api_key: process.env.KEY ?? '' }, }).then(response => { console.log(response.data.data[0].url); });
Debug
Known issues
breakingVersion 2.0.0 drops support for TypeScript <2.8
fix
Update TypeScript to 2.8+ or use restyped-axios@1.x for TS 2.4-2.7.
affects: >=2.0.0
gotchaGET requests with query params cannot use client.get() – only client.request() provides type-checked params
fix
Use client.request({ url, params }) instead of client.get(url, { params }).
affects: *
gotchaRoute parameters (e.g., /posts/:id/like) require explicit generic declaration to avoid compile error
fix
Use client.post<'/posts/:id/like'>('/posts/3/like') instead of plain call.
affects: *
deprecatedPeer dependency on axios may not be compatible with newer axios versions (v1.x)
fix
Lock axios to version ^0.27.0 or check compatibility.
affects: >=2.0.0
Errors
Common errors & fixes
Type argument cannot be inferred from usage. Consider specifying the type arguments explicitly.
Using generic method like client.post without explicit generic route type for path parameters.
fix
Add explicit generic: client.post<'/posts/:id/like'>('/posts/3/like')
Argument of type 'X' is not assignable to parameter of type 'never'.
Calling a method with an invalid route or wrong parameter types due to strict RESTyped definition.
fix
Check the route exists in the API definition and parameters match the expected types.
Cannot find module 'restyped-axios' or its corresponding type declarations.
Missing installation or TypeScript not resolving types correctly.
fix
Run npm install restyped-axios and ensure tsconfig.json includes node_modules type resolution.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
axiosoptionalPeer dependency for HTTP client functionality
Agent activity
10 hits · last 30 days
node
10
Resources
restyped-axios — npm install restyped-axios · libregistry