A REST API for JSON content with zero coding.
Project description
Yet Another JSON Server
Introduction
A REST API for JSON content with zero coding.
Technologies::
- Python 3.13+
- FastAPI 0.116+
The projects json-server and Python JSON Server inspires this one.
Getting started
This project has two options to have your data available for the API.
- Create a JSON file with your resources data.
So, use the docker image and define the file as volume for the API. - Upload a CSV file into the API which will converte it to a JSON file, and
the file name is used as the resource name.
For awhile, this option will updata the JSON file as a whole.
JSON file simple sample data structures:
(e.g.: my-db-data.json)
Case with one "resources" (posts).
{
"posts": [
{
"id": 1,
"title": "Yet Another JSON Server",
"author": "Adriano Vieira"
}
]
}
or
Multiple "resources" (`posts`, `comments`, `products`, and `stoke-exchange`). 👈🏽
{
"posts": [ {"id": 1, "title": "Yet Another JSON Server", "author": "Adriano Vieira" } ],
"comments": [ {"id": 1, "body": "some comment", "postId": 1 } ],
"products": [
{
"productId": 375,
"title": "Dress",
"brand": "Adidas",
"price": 40,
"reviewScore": 1.0431592108,
"color": "Black",
"size": "XL",
"image": "http://products.net/img/"
}
],
"stoke-exchange": [
{
"company": "Chuchu e Melão S/A",
"city": "Belo Horizonte",
"ceoUserId": "99273502-9448-4197-abc4-422d4c792264",
"state": "Minas Gerais",
"id": 17,
"country": "Brasil",
"postcode": 40256,
"idProduct": 19,
"priceTag": "45,593,820",
"shareValue": "617.00"
}
]
}
For those examples:
- the "resources":
posts,comments,products, andstoke-exchangeare the resources enpoints that you would make requests on the API. - the "requests":
posts/1,comments/1,products/375, andstoke-exchange/99273502-9448-4197-abc4-422d4c792264will get a valid responses data.- But the requests:
stoke-exchange/17andstoke-exchange/19will get error response
(read the OpenAPI Document for details).
- But the requests:
API operation
You can use it as Python module or containerized.
Module
Install the JSON server by:
pip install yet-another-json-server
After this, you can run:
ya-json-server
Setup:: via environment variables:
APP_JSON_FILENAME: optional, defaults todata/db.json.APP_PORT: optional, defaults to8000.
Container
You can use the docker image from the project, e.g.:
docker run --rm -it -p 80:8000 -v ./my-db-data.json:/home/worker/data/db.json \
registry.gitlab.com/adrianovieira/ya-json-server:1.0.0
This way, you can access the documentation for the running API at http://api.localhost/docs, such as:
- You can read it on OpenAPI Document.
Simple sample
Making requests
Check the OpenAPI Document to read the full description for each endpoint.
| endpoints | summary |
|---|---|
GET / |
Get list of resources. |
GET /{resource} |
Get all the data of the resource. |
GET /{resource}/{id} |
Get the resource ID data. |
PUT /upload |
Update DB JSON file from CSV file content. |
... |
Check the OpenAPI Document to read the full description for each endpoint.
You also can access the documentation for the running API at http://api.localhost/docs
License
Apache License 2.0
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yet_another_json_server-1.0.2.tar.gz.
File metadata
- Download URL: yet_another_json_server-1.0.2.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.13.7 Linux/6.16.7-200.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2de15f26aaccae6ee7e0fd170ca30c79e5ccbe9fed8860faddf28c9a838cd7b3
|
|
| MD5 |
3a3503dfccd6e4ffbcf6beea227ca547
|
|
| BLAKE2b-256 |
02480d3fcc7b260281ec31709dedfeb96d5c6bbdab1954b5ce60a8571c7f2f78
|
File details
Details for the file yet_another_json_server-1.0.2-py3-none-any.whl.
File metadata
- Download URL: yet_another_json_server-1.0.2-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.13.7 Linux/6.16.7-200.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b97875f96a5daff8dc8035909cb49b10700aa3a875487664ee74fa50f5db8d5
|
|
| MD5 |
118fa026550b2547b2ea95c637e5ea3a
|
|
| BLAKE2b-256 |
b41a0997f243feb97195f8a3d9dc91feef99e08eb09f398592c6aabd74c224a7
|