{"id":17342911,"url":"https://github.com/hay/chantek","last_synced_at":"2025-04-14T19:53:23.024Z","repository":{"id":23256041,"uuid":"26614195","full_name":"hay/chantek","owner":"hay","description":"An unaspiring read-only HTTP API server written in Python.","archived":false,"fork":false,"pushed_at":"2023-03-27T22:36:33.000Z","size":345,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T08:12:04.350Z","etag":null,"topics":["api","json","json-api","python","readonly","rest","wikidata","wikipedia-api"],"latest_commit_sha":null,"homepage":"http://api.haykranen.nl","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-14T00:11:56.000Z","updated_at":"2024-01-05T04:18:36.000Z","dependencies_parsed_at":"2022-08-21T22:10:45.921Z","dependency_job_id":null,"html_url":"https://github.com/hay/chantek","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hay%2Fchantek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hay%2Fchantek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hay%2Fchantek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hay%2Fchantek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hay","download_url":"https://codeload.github.com/hay/chantek/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248951963,"owners_count":21188420,"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":["api","json","json-api","python","readonly","rest","wikidata","wikipedia-api"],"created_at":"2024-10-15T16:07:28.170Z","updated_at":"2025-04-14T19:53:22.992Z","avatar_url":"https://github.com/hay.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Chantek\n=======\nAn unaspiring read-only HTTP API server written in Python 3.\n\nEasily extended with your own commands.\n\nIncludes default commands for querying Wikipedia, Wikidata and the Magic 8-Ball.\n\nTry the live demo: [http://api.haykranen.nl](http://api.haykranen.nl)\n\n## Reference\n* [Source on Github](http://github.com/hay/chantek)\n* Written by [Hay Kranen](http://github.com/hay)\n\n## Running (production)\nTo run the server simply run `server.py` in the root. There's also a `uwsgi.ini` configuration example for [production use](http://www.haykranen.nl/2014/11/15/running-a-python-flask-app-with-nginx-using-uwsgi/).\n\nAnother option is simply running this with an init / systemd script (see `etc/ubuntu-init.conf` for an example), and proxy the calls using something like Nginx. See `etc/nginx-example.conf` for an example.\n\n## Running (development)\n\nFor debugging purposes try running `server.py` with the `debug=1` flag:\n\n    $ python server.py --debug=1\n\nOr simply use `-d`\n\n    $ python server.py -d\n\nTo disable caching use the `-nc` flag.\n\nThis will run your Chantek server on port 5000.\n\nFor a list of all commands try going to `http://localhost:5000/_commands`.\n\nAll commands can be queried like this:\n\n    $ curl http://localhost:5000/\u003ccommand\u003e?param1=foo\u0026param2=bar\n\nCommands with methods (see below) can be called like this:\n\n    $ curl http://localhost:5000/\u003ccommand\u003e/\u003cmethod\u003e?param1=foo\u0026param2=bar\n\nCommands return their data as JSON following a consistent format:\n\n    $ curl http://localhost:5000/wikipedia/define?q=Chantek\n\n    {\n        // Contains the original parameters\n        \"params\": {\n            \"q\": \"Chantek\"\n        },\n\n        // Did an error occur during your call?\n        \"error\": false,\n\n        // Contains the original command\n        \"command\": \"wikipedia\",\n\n        // Response from the command\n        \"response\": {\n            \"extract\": \"Chantek (born December 17, 1977, at the Yerkes Regional Primate Research Center in Atlanta, Georgia) is a male orangutan who has mastered the use of a number of intellectual skills, including sign language, taught by American anthropologists Lyn Miles and Ann Southcombe. In Malay and Indonesian, cantik (pronounced chanteek) means \\\"lovely\\\" or \\\"beautiful\\\".\",\n            \"ns\": 0,\n            \"pageid\": 1577406,\n            \"title\": \"Chantek\"\n        },\n\n        // Version number\n        \"chantek\": \"0.1.0\"\n    }\n\nHTTP responses by default are [CORS](http://enable-cors.org/) enabled for use in web applications.\n\n## Chantek Commands\nCommands go in the `commands` folder. Every command should be in a subfolder, with at least a `__init__.py` file (this should be empty) and a `command.py` file.\n\nFor example:\n\n    chantek/\n        commands/\n            mycommand/\n                __init__.py\n                command.py\n                otherlib.py\n                data.json\n\nThe simplest `command.py` file has a structure like this:\n\n    def run(args):\n        return \"hello world\"\n\n`args` gives back all the url arguments given in the query as a dict.\n\nTo write a command with methods (like `command/verb`), write your command like this:\n\n    methods = (\"foo\")\n\n    def run(args, method):\n        if method == \"bar\":\n            return \"Bar!\"\n\nA command can be known under several aliases:\n\n    # hello.py\n\n    aliases = ['hola']\n\n    def run(args):\n        return \"hello world\"\n\n    # This command can be reached under both 'hello' and 'hola'\n\nTo indicate that a command is cacheable simple write a constant in your command like this:\n\n    CACHEABLE = True\n\nThis will save every unique URL query to an configured cache.\n\nYou can make only some methods cacheable, to do so, simply use a tuple instead of a bool\n\n    methods = (\"search\", \"random\")\n    CACHEABLE = (\"search\") # 'random' should not be cacheable\n\n## Caching\nCurrently there are two caching options: in-memory (this simply saves stuff to a dict), or [Redis](http://redis.io). Optionally, an expire timeout can be given in seconds. See the `config.py` file for instructions on how to configure your cache.\n\n# Packages you need\nI should probably make a `requirements.txt` file sometime, for now run this:\n\n    sudo pip install flask requests pyquery lxml redis xmltodict python-dateutil\n\n## TODO\nThings that are not working yet and should be done:\n* Commands should be self-documenting, and display help in the API\n* Going to the root of the server (e.g. `http://localhost:5000`) should return an interactive console\n* More commands!\n\n## Who's Chantek?\n\"Api\" pronounced in Dutch means \"monkey\", and [Chantek](https://en.wikipedia.org/wiki/Chantek) is a very special monkey indeed. He's mastered sign language, and even understands spoken English. Given the fact that API's are all about communication, it made sense to name a HTTP server after a monkey that speaks English.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhay%2Fchantek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhay%2Fchantek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhay%2Fchantek/lists"}