# 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/6b/9a/0a696aaf5b2ecf31ab015664ba512312c0f47937b23a4c14172543c6b022/chisel-1.6.1.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.6.1",
"project_urls": {
"Homepage": "https://github.com/craigahobbs/chisel"
},
"split_keywords": [
"api",
" json",
" framework",
" schema",
" wsgi"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0737dcbb0796bf077f2baa2b160f05e1c46571b3286add10750c16c4e94f2136",
"md5": "aa6fde8870835805e7a91bf39b92c104",
"sha256": "add591edf82411c896888cd06234d995018ff4097724ae4cbf66f48ce66365bb"
},
"downloads": -1,
"filename": "chisel-1.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "aa6fde8870835805e7a91bf39b92c104",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 124767,
"upload_time": "2025-07-30T17:17:17",
"upload_time_iso_8601": "2025-07-30T17:17:17.414488Z",
"url": "https://files.pythonhosted.org/packages/07/37/dcbb0796bf077f2baa2b160f05e1c46571b3286add10750c16c4e94f2136/chisel-1.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6b9a0a696aaf5b2ecf31ab015664ba512312c0f47937b23a4c14172543c6b022",
"md5": "bc49120e2750c8f93be91f048a1d8201",
"sha256": "36db28adbc210193b8d6b1bd5cce79619894e89c5a404e728f32cef5b71f94ee"
},
"downloads": -1,
"filename": "chisel-1.6.1.tar.gz",
"has_sig": false,
"md5_digest": "bc49120e2750c8f93be91f048a1d8201",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 124614,
"upload_time": "2025-07-30T17:17:19",
"upload_time_iso_8601": "2025-07-30T17:17:19.189841Z",
"url": "https://files.pythonhosted.org/packages/6b/9a/0a696aaf5b2ecf31ab015664ba512312c0f47937b23a4c14172543c6b022/chisel-1.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-30 17:17:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "craigahobbs",
"github_project": "chisel",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "chisel"
}