Skip to main content

A REST API for JSON content with zero coding.

Project description

Yet Another JSON Server

image image

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.

  1. Create a JSON file with your resources data.
    So, use the docker image and define the file as volume for the API.
  2. 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, and stoke-exchange are the resources enpoints that you would make requests on the API.
  • the "requests": posts/1, comments/1, products/375, and stoke-exchange/99273502-9448-4197-abc4-422d4c792264 will get a valid responses data.
    • But the requests: stoke-exchange/17 and stoke-exchange/19 will get error response
      (read the OpenAPI Document for details).

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 to data/db.json.
  • APP_PORT: optional, defaults to 8000.

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:0.26.2

This way, you can access the documentation for the running API at http://api.localhost/docs, such as:

.Read it on link:docs/openapi.json[OpenAPI Document] description. [align="center"] image::docs/api.png[OpenAPI Document, 480]

Making requests

Check the link:docs/openapi.json[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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yet_another_json_server-0.26.3.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yet_another_json_server-0.26.3-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file yet_another_json_server-0.26.3.tar.gz.

File metadata

  • Download URL: yet_another_json_server-0.26.3.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

Hashes for yet_another_json_server-0.26.3.tar.gz
Algorithm Hash digest
SHA256 6c55e49c1fd6594d3820a0a8ae0e94abcd7cb80437c37fde0bdacc89410b5570
MD5 508239d6d4d173d465d7984260a28065
BLAKE2b-256 37341d7a03831c8da5b641431760930dec6e342ad4892237487324c4ceb61b29

See more details on using hashes here.

File details

Details for the file yet_another_json_server-0.26.3-py3-none-any.whl.

File metadata

File hashes

Hashes for yet_another_json_server-0.26.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5677fb3c615a06d4aff28787ffd296113484cd6d7e75239f1e6efceab8ddddc3
MD5 3950fc6bf0504f8b7fb434422b321709
BLAKE2b-256 f2b907a2af683af0bb5fba594f4ba710b2519e4a2118d82e6acb02988f2cf20d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page