# chisel
[](https://pypi.org/project/chisel/)
[](https://pypi.org/project/chisel/)
[](https://github.com/craigahobbs/chisel/blob/main/LICENSE)
[](https://pypi.org/project/chisel/)
Chisel is a light-weight Python WSGI application framework built for creating well-documented,
schema-validated JSON web APIs.
## Links
- [API Documentation](https://craigahobbs.github.io/chisel/)
- [Source code](https://github.com/craigahobbs/chisel)
## JSON APIs
Chisel provides the [action](https://craigahobbs.github.io/chisel/action.html#chisel.action)
decorator for easily implementing schema-validated JSON APIs.
~~~ python
@chisel.action(spec='''
# Sum a list of numbers
action sum_numbers
urls
GET
query
# The list of numbers
float[len > 0] numbers
output
# The sum of the numbers
float sum
''')
def sum_numbers(ctx, req):
return {'sum': sum(req['numbers'])}
application = chisel.Application()
application.add_request(sum_numbers)
application.request('GET', '/sum_numbers', query_string='numbers.0=1&numbers.1=2&numbers.2=4')
('200 OK', [('Content-Type', 'application/json')], b'{"sum":7.0}')
~~~
Each action defines an ``action`` definition using
[Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/).
The action callback is passed two arguments, a request
[Context](https://craigahobbs.github.io/chisel/app.html#chisel.Context)
and the schema-validated request input dictionary. The input request dictionary is created by
combining the request's URL path parameters, query string parameters, and input JSON content
parameters.
If there is a schema validation error the appropriate error code is automatically returned.
~~~ python
status, _, content_bytes = application.request('GET', '/sum_numbers')
'400 Bad Request'
b'{"error":"InvalidInput","message":"Required member \'numbers\' missing (query string)"}'
~~~
## API Documentation
You can add API documentation to your application by adding the Chisel documentation application
requests from
[create_doc_requests](https://craigahobbs.github.io/chisel/request.html#chisel.create_doc_requests).
~~~ python
application = chisel.Application()
application.add_requests(chisel.create_doc_requests())
~~~
By default the documentation application is hosted at "/doc/". An example of of Chisel's documentation output is
available [here](https://craigahobbs.github.io/chisel/example/#var.vName='chisel_doc_request').
## Development
This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
It was started using [python-template](https://github.com/craigahobbs/python-template#readme) as follows:
~~~ sh
template-specialize python-template/template/ chisel/ -k package chisel -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k nomain 1
~~~
Raw data
{
"_id": null,
"home_page": "https://github.com/craigahobbs/chisel",
"name": "chisel",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "api, json, framework, schema, wsgi",
"author": "Craig A. Hobbs",
"author_email": "craigahobbs@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/21/f4/c23286174e636dcf1a81d45b745fc446f7da3bc89bf6e7594932ca4b6b26/chisel-1.4.2.tar.gz",
"platform": null,
"description": "# chisel\n\n[](https://pypi.org/project/chisel/)\n[](https://pypi.org/project/chisel/)\n[](https://github.com/craigahobbs/chisel/blob/main/LICENSE)\n[](https://pypi.org/project/chisel/)\n\nChisel is a light-weight Python WSGI application framework built for creating well-documented,\nschema-validated JSON web APIs.\n\n\n## Links\n\n- [API Documentation](https://craigahobbs.github.io/chisel/)\n- [Source code](https://github.com/craigahobbs/chisel)\n\n\n## JSON APIs\n\nChisel provides the [action](https://craigahobbs.github.io/chisel/action.html#chisel.action)\ndecorator for easily implementing schema-validated JSON APIs.\n\n~~~ python\n@chisel.action(spec='''\n# Sum a list of numbers\naction sum_numbers\n urls\n GET\n\n query\n # The list of numbers\n float[len > 0] numbers\n\n output\n # The sum of the numbers\n float sum\n''')\ndef sum_numbers(ctx, req):\n return {'sum': sum(req['numbers'])}\n\napplication = chisel.Application()\napplication.add_request(sum_numbers)\napplication.request('GET', '/sum_numbers', query_string='numbers.0=1&numbers.1=2&numbers.2=4')\n\n('200 OK', [('Content-Type', 'application/json')], b'{\"sum\":7.0}')\n~~~\n\nEach action defines an ``action`` definition using\n[Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/).\nThe action callback is passed two arguments, a request\n[Context](https://craigahobbs.github.io/chisel/app.html#chisel.Context)\nand the schema-validated request input dictionary. The input request dictionary is created by\ncombining the request's URL path parameters, query string parameters, and input JSON content\nparameters.\n\nIf there is a schema validation error the appropriate error code is automatically returned.\n\n~~~ python\nstatus, _, content_bytes = application.request('GET', '/sum_numbers')\n\n'400 Bad Request'\nb'{\"error\":\"InvalidInput\",\"message\":\"Required member \\'numbers\\' missing (query string)\"}'\n~~~\n\n\n## API Documentation\n\nYou can add API documentation to your application by adding the Chisel documentation application\nrequests from\n[create_doc_requests](https://craigahobbs.github.io/chisel/request.html#chisel.create_doc_requests).\n\n~~~ python\napplication = chisel.Application()\napplication.add_requests(chisel.create_doc_requests())\n~~~\n\nBy default the documentation application is hosted at \"/doc/\". An example of of Chisel's documentation output is\navailable [here](https://craigahobbs.github.io/chisel/example/#var.vName='chisel_doc_request').\n\n\n## Development\n\nThis package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).\nIt was started using [python-template](https://github.com/craigahobbs/python-template#readme) as follows:\n\n~~~ sh\ntemplate-specialize python-template/template/ chisel/ -k package chisel -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k nomain 1\n~~~\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Lightweight WSGI application framework, schema-validated JSON APIs, and API documentation",
"version": "1.4.2",
"project_urls": {
"Homepage": "https://github.com/craigahobbs/chisel"
},
"split_keywords": [
"api",
" json",
" framework",
" schema",
" wsgi"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3f309f85b14292f8bbff97142fa5c0115832608bff1e2fe7c3697bbc8a4e735d",
"md5": "c1c17216c36623d3b0fde01f27226f09",
"sha256": "903f10254400332d869caeaa70c5e0be0f4dccc3278ece16af542dc664e75f79"
},
"downloads": -1,
"filename": "chisel-1.4.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c1c17216c36623d3b0fde01f27226f09",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 125895,
"upload_time": "2025-03-21T20:41:51",
"upload_time_iso_8601": "2025-03-21T20:41:51.545466Z",
"url": "https://files.pythonhosted.org/packages/3f/30/9f85b14292f8bbff97142fa5c0115832608bff1e2fe7c3697bbc8a4e735d/chisel-1.4.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "21f4c23286174e636dcf1a81d45b745fc446f7da3bc89bf6e7594932ca4b6b26",
"md5": "d852e69e4c8ee387600b606766f0fd5e",
"sha256": "2fc80e25b61c4e524c2f877f136165660c3c0f15c58f2b2210e5b816789d7fa4"
},
"downloads": -1,
"filename": "chisel-1.4.2.tar.gz",
"has_sig": false,
"md5_digest": "d852e69e4c8ee387600b606766f0fd5e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 125738,
"upload_time": "2025-03-21T20:41:53",
"upload_time_iso_8601": "2025-03-21T20:41:53.233729Z",
"url": "https://files.pythonhosted.org/packages/21/f4/c23286174e636dcf1a81d45b745fc446f7da3bc89bf6e7594932ca4b6b26/chisel-1.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-03-21 20:41:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "craigahobbs",
"github_project": "chisel",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "chisel"
}