
Json API Smart
Is your client library which support ths JSON:API standard specified
on JSON:API.
class BaseResource(JsonApiResource):
@staticmethod
def base_url(cls) -> str:
return "http://baseurl.com/"
class People(BaseResource):
id: str = resource_id()
first_name: str = attribute()
class Article(BaseResource):
id: str = resource_id()
title: str = attribute()
number: int = attribute()
some_date: date = attribute(decoder=date.fromisoformat)
some_optional: Optional[int] = attribute()
author: People = relationship()
Query it with:
article = Article.find("101")
article.id
article.title
article.number
article.some_optional
article.author.id
article.author.first_name
Query resources
Call your resources by building chains:
articles = Article.all()
articles = Article.with_params(price=5).all()
articles = Article.where(author=101).all()
articles = Article.find("101")