{"id":28559190,"url":"https://github.com/toastdriven/django-microapi","last_synced_at":"2025-06-10T08:36:22.345Z","repository":{"id":210071852,"uuid":"725674646","full_name":"toastdriven/django-microapi","owner":"toastdriven","description":"A tiny library to make writing CBV-based APIs easier in Django.","archived":false,"fork":false,"pushed_at":"2024-08-23T16:06:03.000Z","size":73,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-07T16:54:56.344Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toastdriven.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-30T16:29:43.000Z","updated_at":"2025-03-30T14:02:39.000Z","dependencies_parsed_at":"2024-08-21T21:05:38.464Z","dependency_job_id":null,"html_url":"https://github.com/toastdriven/django-microapi","commit_stats":null,"previous_names":["toastdriven/django-microapi"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Fdjango-microapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Fdjango-microapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Fdjango-microapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Fdjango-microapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toastdriven","download_url":"https://codeload.github.com/toastdriven/django-microapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Fdjango-microapi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258990245,"owners_count":22789079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-10T08:36:12.524Z","updated_at":"2025-06-10T08:36:22.336Z","avatar_url":"https://github.com/toastdriven.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-microapi\n\n[![Documentation Status](https://readthedocs.org/projects/django-microapi/badge/?version=latest)](https://django-microapi.readthedocs.io/en/latest/?badge=latest)\n\nA tiny library to make writing CBV-based APIs easier in Django.\n\nEssentially, this just provides some sugar on top of the plain old `django.views.generic.base.View` class, all with the intent of making handling JSON APIs easier (without the need for a full framework).\n\n\n## Usage\n\n```python\n# We pull in two useful classes from `microapi`.\nfrom microapi import ApiView, ModelSerializer\n\nfrom .models import BlogPost\n\n\n# Inherit from the `ApiView` class...\nclass BlogPostView(ApiView):\n    # ...then define `get`/`post`/`put`/`delete`/`patch` methods on the\n    # subclass.\n\n    # For example, we'll provide a list view on `get`.\n    def get(self, request):\n        posts = BlogPost.objects.all().order_by(\"-created\")\n\n        # The `render` method automatically creates a JSON response from\n        # the provided data.\n        return self.render({\n            \"success\": True,\n            \"posts\": self.serialize_many(posts),\n        })\n\n    # And handle creating a new blog post on `post`.\n    def post(self, request):\n        if not request.user.is_authenticated:\n            return self.render_error(\"You must be logged in\")\n\n        # Read the JSON\n        data = self.read_json(request)\n\n        # TODO: Validate the data here.\n\n        # Use the included `ModelSerializer` to load the user-provided data\n        # into a new `BlogPost`.\n        post = self.serializer.from_dict(BlogPost(), data)\n        # Don't forget to save!\n        post.save()\n\n        return self.render({\n            \"success\": True,\n            \"post\": self.serialize(post),\n        })\n```\n\n\n## Installation\n\n```bash\n$ pip install django-microapi\n```\n\n\n## Rationale\n\nThere are a lot of API frameworks out there (hell, I [built](https://tastypieapi.org/) [two](https://github.com/toastdriven/restless) of them). But for many tasks, they're either [overkill](https://en.wikipedia.org/wiki/HATEOAS) or just too opinionated.\n\nSo `django-microapi` is kind of the antithesis to those. With the exception of a tiny extension to `View` for nicer errors, it doesn't call **ANYTHING** automatically. Other than being JSON-based, it doesn't have opinions on serialization, or validation, or URL structures.\n\nYou write the endpoints you want, and `microapi` brings some conveniences to the table to make writing that endpoint as simple as possible _without_ assumptions.\n\nI've long had a place in my heart for the simplicity of Django's function-based views, as well as the conveniences of `django.shortcuts`. `microapi` tries to channel that love/simplicity.\n\n\n## API Docs\n\nhttps://django-microapi.rtfd.io/\n\n\n## Testing\n\nTo run the tests, you'll need both [Pipenv](https://pipenv.pypa.io/en/latest/), and [Just](https://just.systems/) installed.\n\n```shell\n$ just test\n```\n\n\n## License\n\nNew BSD\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoastdriven%2Fdjango-microapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoastdriven%2Fdjango-microapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoastdriven%2Fdjango-microapi/lists"}