nimrodel


Namenimrodel JSON
Version 0.8.0 PyPI version JSON
download
home_page
SummaryBottle-wrapper to make python objects accessible via HTTP API
upload_time2022-03-10 05:26:42
maintainer
docs_urlNone
author
requires_python>=3.6
license
keywords library api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Nimrodel

[![](https://img.shields.io/pypi/v/nimrodel?style=for-the-badge)](https://pypi.org/project/nimrodel/)
[![](https://img.shields.io/pypi/dm/nimrodel?style=for-the-badge)](https://pypi.org/project/nimrodel/)
[![](https://img.shields.io/github/stars/krateng/nimrodel?style=for-the-badge&color=purple)](https://github.com/krateng/nimrodel/stargazers)
[![](https://img.shields.io/pypi/l/nimrodel?style=for-the-badge)](https://github.com/krateng/nimrodel/blob/master/LICENSE)


A simple Bottle.py-wrapper to provide HTTP API access to any python object.

# Requirements

* Python 3.5 or higher

# Quick Start

Install with

```
pip install nimrodel
```

Create your API with

```python

from nimrodel import API

myapi = API()
```

You may optionally pass a port number with `port=42`, a path with `path="api"` and whether you want to serve on IPv4 (`IPv6=False`).
You can also give the API object an existing bottle server (`server=bottleobject`), in which case your API will be served on the existing server. It is heavily recommended to also pass a path variable to separate API from regular routing of your server.
You may also pass a custom function with `parsedoc=yourfunction` that takes your method as input and returns a dictionary with the values `desc` for the function description, `params` for a dictionary of parameter names mapped to a dictionary and `returns` for a dictionary of the return value. Both return and param dictionaries can have the keys `type` and `desc` for data type and description respectively. By default nimrodel will attempt to parse your docstring according to the reST standard (Sphinx).


Then make any class accessible with a decorator.

```python

@myapi.apiclass("group")
class Group:

	def __init__(self,name,apipath,songs):
		# some stuff
		self.__apiname__ = apipath
```

Any instance of that class is now accessible via the combination of class path and its individual path. Now just decorate the methods. All its arguments can be passed via URI query arguments.

```python
	@myapi.get("songs")
	def get_songs(self,member):
		return {"songs":[s["title"] for s in self.songs if member in s["performers"]]}
```

Now create an object and make sure it has an `__apiname__` attribute:

```python
e = Group("Exid","exid",exidsongs)
```

Then you can access its methods with simple HTTP calls like `/group/exid/songs?member=Junghwa`.

There is also an integrated graphical API explorer under `/api_explorer`.

Nimrodel also allows you to create a simple function-based API with the class `EAPI`.


For more in-depth exploration of the possibilities, refer to the file `example.py` included in the repository.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "nimrodel",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "library,api",
    "author": "",
    "author_email": "Johannes Krattenmacher <nimrodel@dev.krateng.ch>",
    "download_url": "https://files.pythonhosted.org/packages/09/0e/bb8ce1a078dbab7665452c03c99b38b56561c16ae22033cddd1b2571fe5c/nimrodel-0.8.0.tar.gz",
    "platform": null,
    "description": "# Nimrodel\n\n[![](https://img.shields.io/pypi/v/nimrodel?style=for-the-badge)](https://pypi.org/project/nimrodel/)\n[![](https://img.shields.io/pypi/dm/nimrodel?style=for-the-badge)](https://pypi.org/project/nimrodel/)\n[![](https://img.shields.io/github/stars/krateng/nimrodel?style=for-the-badge&color=purple)](https://github.com/krateng/nimrodel/stargazers)\n[![](https://img.shields.io/pypi/l/nimrodel?style=for-the-badge)](https://github.com/krateng/nimrodel/blob/master/LICENSE)\n\n\nA simple Bottle.py-wrapper to provide HTTP API access to any python object.\n\n# Requirements\n\n* Python 3.5 or higher\n\n# Quick Start\n\nInstall with\n\n```\npip install nimrodel\n```\n\nCreate your API with\n\n```python\n\nfrom nimrodel import API\n\nmyapi = API()\n```\n\nYou may optionally pass a port number with `port=42`, a path with `path=\"api\"` and whether you want to serve on IPv4 (`IPv6=False`).\nYou can also give the API object an existing bottle server (`server=bottleobject`), in which case your API will be served on the existing server. It is heavily recommended to also pass a path variable to separate API from regular routing of your server.\nYou may also pass a custom function with `parsedoc=yourfunction` that takes your method as input and returns a dictionary with the values `desc` for the function description, `params` for a dictionary of parameter names mapped to a dictionary and `returns` for a dictionary of the return value. Both return and param dictionaries can have the keys `type` and `desc` for data type and description respectively. By default nimrodel will attempt to parse your docstring according to the reST standard (Sphinx).\n\n\nThen make any class accessible with a decorator.\n\n```python\n\n@myapi.apiclass(\"group\")\nclass Group:\n\n\tdef __init__(self,name,apipath,songs):\n\t\t# some stuff\n\t\tself.__apiname__ = apipath\n```\n\nAny instance of that class is now accessible via the combination of class path and its individual path. Now just decorate the methods. All its arguments can be passed via URI query arguments.\n\n```python\n\t@myapi.get(\"songs\")\n\tdef get_songs(self,member):\n\t\treturn {\"songs\":[s[\"title\"] for s in self.songs if member in s[\"performers\"]]}\n```\n\nNow create an object and make sure it has an `__apiname__` attribute:\n\n```python\ne = Group(\"Exid\",\"exid\",exidsongs)\n```\n\nThen you can access its methods with simple HTTP calls like `/group/exid/songs?member=Junghwa`.\n\nThere is also an integrated graphical API explorer under `/api_explorer`.\n\nNimrodel also allows you to create a simple function-based API with the class `EAPI`.\n\n\nFor more in-depth exploration of the possibilities, refer to the file `example.py` included in the repository.\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Bottle-wrapper to make python objects accessible via HTTP API",
    "version": "0.8.0",
    "project_urls": {
        "documentation": "https://github.com/krateng/nimrodel",
        "homepage": "https://github.com/krateng/nimrodel",
        "repository": "https://github.com/krateng/nimrodel"
    },
    "split_keywords": [
        "library",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1174387a543d6495f3d4c84cd67519d31157acb62fe4b9bf33bff456d1cbd384",
                "md5": "116ad5e56576b43df474a3d42447ebde",
                "sha256": "08df134ac532e24189c037c61a2e4e7a817b198d604bcfc72f6eea5ef0e1a49d"
            },
            "downloads": -1,
            "filename": "nimrodel-0.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "116ad5e56576b43df474a3d42447ebde",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 29849,
            "upload_time": "2022-03-10T05:26:40",
            "upload_time_iso_8601": "2022-03-10T05:26:40.582894Z",
            "url": "https://files.pythonhosted.org/packages/11/74/387a543d6495f3d4c84cd67519d31157acb62fe4b9bf33bff456d1cbd384/nimrodel-0.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "090ebb8ce1a078dbab7665452c03c99b38b56561c16ae22033cddd1b2571fe5c",
                "md5": "1bd58c0f66015eafc7685f13fca1fac1",
                "sha256": "7fd5d5baf31730082a943c83b194c5ec07eaba3f4bff453fe3156c37e560b56d"
            },
            "downloads": -1,
            "filename": "nimrodel-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1bd58c0f66015eafc7685f13fca1fac1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 23362,
            "upload_time": "2022-03-10T05:26:42",
            "upload_time_iso_8601": "2022-03-10T05:26:42.071184Z",
            "url": "https://files.pythonhosted.org/packages/09/0e/bb8ce1a078dbab7665452c03c99b38b56561c16ae22033cddd1b2571fe5c/nimrodel-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-03-10 05:26:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "krateng",
    "github_project": "nimrodel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nimrodel"
}
        
Elapsed time: 0.16622s