Skip to main content

jsonapi Travis Coveralls github Codacy grade GitHub tag Python versions

A minimalistic JSON API framework in Python with support for graphql-style queries.

jsonapi is heavily inspired by graphql, but aimed at a much simpler use case. The idea is to have a minimal framework for easily building JSON based APIs, that doesn't require any particular frontend technology. The design is inspired in graphql's idea of a single fully customizable endpoint, but instead of defining a specific query language, jsonapi is entirely based on JSON both for the query and the response, requires much less boilerplate code, only works in Python 3, and of course, is much less battle-tested. If you find graphql amazing but would like to try a decaffeinated version that you can setup in 10 lines, then give jsonapi a shot.

Instalation

The easiest installation is through pip. Unfortunately the cute name jsonapi was taken already in PyPi, so the project is registered under jsonapi-simple.

pip install jsonapi-simple

You can also just clone and distribute with your project's source code:

git clone https://github.com/apiad/jsonapi.git

Hello world

To illustrate the usage is best to start with an example. The main class in jsonapi is (wait for it...) JsonApi, which defines all the available commands in the API as public methods:

>>> from jsonapi import JsonApi

>>> class HelloWorld(JsonApi):
...     def say(self, message, args):
...         return message.format(args)

Afterwards, create an instance of this API and call it, passing along either a JSON-enconded string, or a pure Python dictionary, to query either methods or attributes:

>>> api = HelloWorld()

>>> api({"say": { "$message": "Hello {0}!", "$args": "world" }})
{'say': 'Hello world!'}

Moving on

There is more that can be done with jsonapi, read the documentation to learn more:

Contributing

Contributions are highly appreciated. Just fork and submit a pull request. All contributors will be granted credit on the following list:

Changelog

In the roadmap

  • Automatic API documentation.

v0.2.2

v0.2.1

  • Support for typed arguments.

v0.2.0

  • Support for meta operators in dictionaries (_count, _items, _keys, _values).
  • The JsonObj constructor now receives either str, dict or a **kwargs mapping.

v0.1.4

  • Support for some meta operators for lists (_count and _items).

v0.1.3

  • Basic implementation of JsonObj for JSON manipulation.

v0.1.2

  • Suport for complex method arguments (parsed via JsonObj).

v0.1.1

  • Suport for plain method arguments.

v0.1

  • Basic layout of the API.
  • Simple attribute and method based navigation.
  • Automatic serialization to a JSON compatible object.
  • Basic documentation.

Colaboration

This project is licensed MIT, so you know the drill. Fork, open a pull request, and make sure to have up-to-date tests with (ideally) a 100% coverage.

MIT License

Copyright (c) 2018 Alejandro Piad

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for jsonapi-simple 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonapi-simple 0.2.2
File Size Uploaded Provenance Actions
jsonapi-simple-0.2.2.tar.gz 5.5 kB Without provenance Details for jsonapi-simple-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jsonapi-simple 0.2.2
File Interpreter ABI Platform Actions
jsonapi_simple-0.2.2-py3-none-any.whl Python 3 none any Details for jsonapi_simple-0.2.2-py3-none-any.whl

Total release size: 12.5 kB

Release files / jsonapi-simple-0.2.2.tar.gz

Download URL jsonapi-simple-0.2.2.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
05f9670a9bdc8f58759453ba0de3778b48d6f16640a622f34c1f12a7a1c9f5cd
BLAKE2b-256 checksum
How to use checksums
12a9c11572734f1e81bd39385ab42d5c6b059c22fee5ed04e44c8868d0d4c5fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.6.7

Release files / jsonapi_simple-0.2.2-py3-none-any.whl

Download URL jsonapi_simple-0.2.2-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d9c03ce340f8fa1cd9d68c62a6ed22af3cc789d21358348077ef17437506c7e
BLAKE2b-256 checksum
How to use checksums
aa3a7d31e87e974efcc0822309a8d35c71680c3fa1a89f66db5968415e01ef52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.6.7

Security for jsonapi-simple 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page