Python Library Support

Hey all, working on a client who seems to have a potential taste for adopting {json:api}. I’m mostly a polyglot developer focused in JVM tooling, so python support is outside of my standard wheelhouse.

They are planning to use a python stack, and I see a bunch of support via Django and Flask, I understand that flask is a bit more dynamic and Django is more opinionated so I’m leaning towards Flask as the base. That being said there is still a bunch of options, and I’m going through activity and support on GitHub to compare.

While I do that, does anyone have experience with any of the python libraries and any blurbs of info to share?

Thanks!

I am currently using flask with marshmallow-jsonapi and webargs + custom code to parse the query string. marshmallow-jsonapi is definitely missing some features like pagination but you can easily extend the Schema class to handle it based on your setup, e.g. flask-sqlalchemy.

My backend is definitely verbose but allows me to customize per resource, e.g. different schemas per user group and scope. The packages down below are great for getting started but I always end up fighting them.

Libraries that exist for flask + jsonapi:

1 Like

I developed a flask library to expose databases using jsonapi and an openapi UI: https://github.com/thomaxxl/safrs

It is possible to expose existing databases as well: as a PoC I have implemented the mysql employees and sakila test databases ( https://github.com/datacharmer/test_db ). A live version of the sakila database can be found here: http://www.blackbirdbits.com:5000/api

1 Like

Thanks to you both for the very helpful responses!!!

@scott.werner.vt Do you have any insights on the differences between the two libraries you listed? They seem to have similar dependencies (marshmallow + flask + sqlalchemy), to a python library novice such as myself I’m having trouble seeing the nuanced value of each option.

@Thomaxxl Thanks, I started something with safrs a bit ago and haven’t taken it through, I’ve gone with flask-rest-jsonapi for the moment because I just did a very quick modification to their demo code to get it up and running as a dev poc / mock environment. Do you have familiarity with this library and can you talk about any of the differences or advantages in addition to the OAS support for safrs?

I don’t have any experience with flask-rest-jsonapi but I think I would’ve used it myself if I had known about it when I started safrs because both libraries serve the same purpose. The main difference is the OAS support.

Safrs tries to provide an easy-to-use interface for developers: the implementation is quite complex but I want to shield users/developers from these implementation details, this is why I’m currently working on implementing support for existing databases.

If you have any suggestions on how things can be improved, please let me know.

1 Like

Do you have any insights on the differences between the two libraries you listed? They seem to have similar dependencies (marshmallow + flask + sqlalchemy), to a python library novice such as myself I’m having trouble seeing the nuanced value of each option.

flask-restless development for json-api support seems to have stalled as the last commit on master was 2017-03-25. flask-rest-jsonapi is still active and growing so I recommend checking it out.

Those dependencies are just commonly used in flask REST backends. Marshmallow for validating input and dumping to json, sqlalchemy for ORM, and flask for serving it all.

1 Like

So it ends up being support and current implementation progress. flask-rest-jsonapi seemed to be supported by milibris which seems to have gone dark. I think in that case both cases dev has somewhat stalled, but now that I have work on the flask-rest-jsonapi I’ll probably just stick here for now.

@scott.werner.vt @Thomaxxl Thanks to you both for the help!

I know you opined that Django is too opinionated :grinning: but thought I’d share my opinion that opinionated frameworks can be quite helpful.

We are successfully using Django, Django REST Framework(DRF) and django-restframework-json-api(DJA). These are all actively being maintained and enhanced.

DRF is working on adding OAS schema support and DJA would hopefully follow with an OAS schema for {json:api}.