Design colors

Quickly and easily deploy a mocked REST API

Save time on the development of your Frontend project by avoiding wasting it on the API mocking just by using an intuitive and developer friendly JSON file structure.

$ yarn global add restapify 
# or npm install -g restapify
$ restapify serve mockedApi/

#1 Define routes [docs]

    • [
        "#for i in range([q:limit|25])",
        {
          "id": "n:[i]",
          "email": "[#faker:internet:email]"
        },
        "#endfor"
      ]
      • {
          "id": "n:[userid]",
          "email": "[#faker:internet:email]"
        }
      • [null]
      • [null]
      • {
          "#header": {
            "Content-Type": "text/html; charset=UTF-8"
          },
          "#body": {
            "success": true
          }
        }
      • {
          "success": true,
          "data": {
            "id": "n:[userid]",
            "email": "[#faker:internet:email]"
          }
        }
      • [
          "#for i in range([q:limit|25])",
          {
            "id": "n:[i]",
            "creatorId": "n:[userid]",
            "content": "[#faker:lorem:sentences]"
          },
          "#endfor"
        ]
  • {
      "firstname": "[#faker:name:firstName]",
      "lastname": "[#faker:name:lastName]",
      "email": "[#faker:internet:email]"
    }
Icon arrow-right

#2 Consume the API

GET http://localhost:6767/api/posts
Icon arrow-bar-bottom

Status: 200

[
  {
    "id": 0,
    "title": "Post n: #0"
  },
  {
    "id": 1,
    "title": "Post n: #1"
  },
  {
    "id": 2,
    "title": "Post n: #2"
  },
  {
    "id": 3,
    "title": "Post n: #3"
  },
  {
    "id": 4,
    "title": "Post n: #4"
  }
]

GET http://localhost:6767/api/users
Icon arrow-bar-bottom

Status: 200

[
  {
    "id": 0,
    "email": "Julianne.Hegmann58@gmail.com"
  },
  {
    "id": 1,
    "email": "Sim44@gmail.com"
  },
  ". . .",
  {
    "id": 24,
    "email": "Evalyn_Kovacek71@hotmail.com"
  }
]

GET http://localhost:6767/api/users?limit=3
Icon arrow-bar-bottom

Status: 200

[
  {
    "id": 0,
    "email": "Clyde.Cartwright@gmail.com"
  },
  {
    "id": 1,
    "email": "Maximilian42@yahoo.com"
  },
  {
    "id": 2,
    "email": "Betsy40@gmail.com"
  }
]

GET http://localhost:6767/api/users/42
Icon arrow-bar-bottom

Status: 200

{
  "id": 42,
  "email": "Betsy40@gmail.com"
}

Status: 404

POST http://localhost:6767/api/users/42
Icon arrow-bar-bottom

Status: 201

{
  "success": true,
  "data": {
    "id": 42,
    "email": "Maximilian42@yahoo.com"
  }
}

DELETE http://localhost:6767/api/users/42
Icon arrow-bar-bottom

Status: 200

{
  "success": true
}

Status: 401

GET http://localhost:6767/api/users/42/comments
Icon arrow-bar-bottom

Status: 200

[
  {
    "id": 0,
    "creatorId": 42,
    "content": "Saepe ipsam est recusandae accusamus expedita. Magnam quibusdam aut enim omnis aspernatur libero facilis ab sed. Consequuntur aliquid quod ut ea. Vitae totam nemo error ut quo qui omnis et. Blanditiis natus corporis. Incidunt dolorem recusandae qui."
  },
  {
    "id": 1,
    "creatorId": 42,
    "content": "Quibusdam aut illum sit dicta suscipit. Illo error quia nostrum quod aut. Asperiores vitae tenetur odit odio. Explicabo ab dolores. Molestiae corrupti hic officia nihil sunt veritatis adipisci et et."
  },
  ". . .",
  {
    "id": 24,
    "creatorId": 42,
    "content": "Quo culpa dolorem. Est veniam dolorem nam. Dolor autem dolore qui aut repellendus. Necessitatibus voluptas et et asperiores voluptas consectetur placeat vitae. Voluptas neque et tempora sit aspernatur enim. Quibusdam autem optio veniam."
  }
]

GET http://localhost:6767/api/me
Icon arrow-bar-bottom

Status: 200

{
  "firstname": "Janie",
  "lastname": "Hermann",
  "email": "Jo.Kessler@yahoo.com"
}

💡 Incredible DX

Intuitive files structure and JSON syntax to cover all the scenarios of your future API

✅ JSON valid

You will only use .json files that follows the ECMA-404 standard

🎛 Dashboard

Out of the box Single Page Application to explore and manage your mocked API

💻 CLI

Use the CLI for an instant deployment

📝 Fakerjs implementation

Intuitive syntax to quickly populate your API responses with the famous fakerjs library

🔥 Built in hot watcher

Directly see your changes after a file update


Getting Started

Using the cli

The simplest way to use Restapify is to use his cli...

yarn global add restapify
# or npm install -g restapify

...and then serve your api folder:

restapify serve path/to/folder/

Using the JavaScript class

You can install restapify's class using `npm` (note that this package should be a devDependency):

yarn add -D restapify
# or npm i -D restapify

You can then import the class and instantiate it to serve the api folder:

import * as path from 'path'
import Restapify from 'restapify'

const apiFolderPath = path.resolve(__dirname, './path/to/folder')

const rpfy = new Restapify({
  rootDir: apiFolderPath
})
rpfy.run()