Skip to content

A simple, zero config RESTful api that takes whatever you want to throw at it

License

Notifications You must be signed in to change notification settings

RoryCombe/anyapi

Repository files navigation

any API 🤖

A simple, zero config RESTful api that takes whatever you want to throw at it


GitHub Workflow Status codecov

Getting Started

npx @anyapi/anyapi

or

npm i @anyapi/anyapi -g
anyapi

This will start the server on the default port of 2000. Using any HTTP client you can now GET, POST, PUT, DELETE with a collection type that is completely variable and up to you.

For example hamburgers:

fetch('http://localhost:2000/hamburgers', {
  method: 'POST',
  body: JSON.stringify({ name: 'Cheese Burger', ingredients: ['beef', 'tomato', 'lettuce', 'cheese'] }),
  headers: new Headers({'Content-Type': 'application/json'})
})

Then GET on http://localhost:2000/hamburgers to see your new collection

Methods

  • GETALL on :collection
  • GET on :collection with :id
  • CREATE on :collection with :data
  • UPDATE on :collection with :id and :data
  • DESTROY on :collection with :id