# restful-dummy-server

> This can be used to mock restful api responses.

Latest version **1.0.5** (published 2026-01-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install restful-dummy-server
pnpm add restful-dummy-server
yarn add restful-dummy-server
bun add restful-dummy-server
```

Provides the command `restful-dummy-server`.

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2026-01-31 |
| First published | 2023-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Suneet Bansal |
| Maintainers | bansal.suneet |
| Keywords | dummy, mock, rest server, restful dummy server, fake |

## Links

- npm: https://www.npmjs.com/package/restful-dummy-server
- Repository: https://github.com/SuneetBansal/restful-dummy-server
- Homepage: https://github.com/SuneetBansal/restful-dummy-server#readme
- Issues: https://github.com/SuneetBansal/restful-dummy-server/issues
- npm.io page: https://npm.io/package/restful-dummy-server

## Dependencies (3)

- [express](https://npm.io/package/express.md) ^4.18.2
- [commander](https://npm.io/package/commander.md) ^11.0.0
- [express-http-proxy](https://npm.io/package/express-http-proxy.md) ^1.6.3

## Alternatives

- [pagerjs](https://npm.io/package/pagerjs.md) — 60 weekly downloads
- [whistle.savefor-mock](https://npm.io/package/whistle.savefor-mock.md) — 4 weekly downloads
- [@simulacrum/ldap-simulator](https://npm.io/package/@simulacrum/ldap-simulator.md) — 0 weekly downloads
- [@crvouga/mockingbird-service-paddle](https://npm.io/package/@crvouga/mockingbird-service-paddle.md) — 0 weekly downloads
- [odata-prova](https://npm.io/package/odata-prova.md) — 0 weekly downloads

## Recent versions

- 1.0.5 (latest) — 2026-01-31
- 1.0.4 — 2023-06-25
- 1.0.3 — 2023-06-25
- 1.0.2 — 2023-06-25
- 1.0.1 — 2023-06-25
- 1.0.0 — 2023-06-25

## README

# restful-dummy-server
This can be used to mock Rest API responses.

## How to install 
npm install -g restful-dummy-server

## How to use
### CLI options

#### 1. port
```js
"scripts": {
    "start": "restful-dummy-server -port 4000"
}
```

This will start restful dummy server on port 4000


#### 2. host
You can also mention host.
```js
"scripts": {
    "start": "restful-dummy-server -port 4000 -host xx.xx.xx.xx"
}
```

#### 3. static
```js
"scripts": {
    "start": "restful-dummy-server -port 4000 -static ./data"
}
```

**static** is used to know the relative path of a folder where all statics files are hosted. Which then would be used by Dummy server to download files against the rest api dowbloaded request.
Here this folder is **data**.


#### 4. config
```js
"scripts": {
    "start": "restful-dummy-server -port 4000 -static ./data -config ./test"
}
```

**config** is used to know the relative path of a folder which are having dummy request response instruction files in **.json** extensions only.

Note - 
1. Assuming **port** is 4000 for all below examples.
2. **data** folder is having **test.png** file

Example 1-
**test/config.json**

```js
[{
    "request": {
        "url": "/get/message",
        "method": "get"
    },
    "response": {
        "headers": {},
        "body": "Hello Dummy Server"
    }
}]
```

In this case if you hit http://localhost:5000/get/message then you will get **Hello Dummy Server** as response.


Example 2-
**test/config.json**

```js
[{
    "request": {
        "url": "/get/:message",
        "method": "get"
    },
    "response": {
        "headers": {},
        "body": { "message": "Hello Dummy Server" }
    }
}]
```

In this case if you hit http://localhost:5000/get/test or http://localhost:5000/get/msg etc. then you will get **{ "message": "Hello Dummy Server" }** as response.


Example 3-
**test/config.json**

```js
[{
    "request": {
        "url": "/get/png/*.*",
        "method": "get"
    },
    "response": {
        "headers": {
            "Content-Disposition": "attachment;filename= test.png;"
        },
        "body": "./test.png"
    }
}]
```

In this case if you hit http://localhost:5000/get/png/abc.png or http://localhost:5000/get/png/msg.png etc. then **test.png** will be downloaded as response.


Example 4-
**test/config.json**

```js
[{
    "request": {
        "url": "/get/**/*.*",
        "method": "get"
    },
    "response": {
        "headers": {
            "Content-Disposition": "attachment;filename= test.png;"
        },
        "body": "./test.png"
    }
}]
```

In this case if you hit http://localhost:5000/get/png/abc.png or http://localhost:5000/get/png/png2/msg.jpeg etc. then **test.png** will be downloaded as response.


Example 5-
**test/config.json**

```js
[{
    "request": {
        "url": "/get/**/*.png",
        "method": "get"
    },
    "response": {
        "headers": {
            "Content-Disposition": "attachment;filename= test.png;"
        },
        "body": "./test.png"
    }
}]
```

In this case if you hit http://localhost:5000/get/png/abc.png or http://localhost:5000/get/png/png2/msg.png etc. then **test.png** will be downloaded as response.


Example 6-
**test/config.json**

```js
[{
    "request": {
        "url": "/get/**/*.png",
        "method": "get"
    },
    "response": {
        "headers": {
            "Content-Disposition": "attachment;filename= test.png;"
        },
        "body": "./test.png",
        "delay": 2000 
    }
}]
```

Above **delay** is the special attribute which would cause Dummy server to respond in 2000 milliseconds.


#### 5. proxy
```js
"scripts": {
    "start": "restful-dummy-server -port 4000 -static ./data -config ./test -proxy localhost:2000"
}
```

If **proxy** is provided then Dummy server will redirect the request to the proxy server if there is no matching record found.

---
_Source: https://npm.io/package/restful-dummy-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
