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
Filter
GET /articles?title=title&author=eminem
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
Database
GET /db
Extras
Alternative Host
You can start JSON Server on other host with the --host
flag:
$ json-server --host "0.0.0.0" watch db.json
Default: localhost
Alternative Port
You can start JSON Server on other ports with the --port
flag:
$ json-server --port 8100 watch db.json
Default: 8080
CLI Usage
Usage: jason-server [OPTIONS] COMMAND [ARGS]...
Options:
-h, --host TEXT Host adress
-p, --port INTEGER Port
-q, --quiet
--version Show the version and exit.
--help Show this message and exit.
Commands:
watch Run your database as REST Api
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.7.0.tar.gz
(9.6 kB
view hashes)
Built Distribution
Close
Hashes for jason_server-0.7.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 576627990dc8116e665bf5b7aae432563568a7ce5d9bd83ff49c198a0ba99195 |
|
MD5 | 7da7ce2155538b1dff61482a007b8e77 |
|
BLAKE2b-256 | c53d72f9b5261503200564d7a9f46c3dce2acc4ca362ada73c5fe2bc94ff2825 |