JSON as REST API
Project description
Jason Server
Get a full fake REST API
Table of contents
Getting started
Install Jason Server
pip3 install jason-server
Create a db.json
file with some data
{
"articles": [
{ "id": 1, "title": "jason-server", "author": "1" },
{ "id": 2, "title": "jason-routes", "author": "1" }
],
"authors": [
{ "id": 1, "name": "bob"}
]
}
Start JSON Server
jason-server watch db.json
Now if you go to http://localhost:8080/articles, you'll get
{ "id": 1, "title": "jason-server", "author": "1" },
{ "id": 2, "title": "jason-routes", "author": "1" }
Routes
Singular routes
GET /authors
Pagination
Use _page
and _limit
to paginate data.
In the Link
header you'll get first
, prev
, next
and last
links.
GET /articles?_page=2
GET /articles?_page=3&_limit=15
Sorting
Use _sort
and _order
(defaults order: asccendant)
GET /persons?_sort=age
GET /persons?_sort=name&_order=desc
Alternative host (default: localhost)
You can start JSON Server on other host with the --host
flag:
$ json-server --host "0.0.0.0" watch db.json
Alternative port (default: 8080)
You can start JSON Server on other ports with the --port
flag:
$ json-server --port 8100 watch db.json
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jason-server-0.5.1.tar.gz
(8.9 kB
view hashes)
Built Distribution
Close
Hashes for jason_server-0.5.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed2da5a11eea0f03e46f9d144cede44c7cdab470d5f3932fdc699bcc2be32c17 |
|
MD5 | 7a5ea750dd47ac9497904422690dfd23 |
|
BLAKE2b-256 | 538b49a7cf89583f19e2c8d181d159d5619dcf15f297491e8050d1c7549cdf01 |