# Akinator-python
An API wrapper for the AkinatorAPI
### >>```pip install akinator-python```<<
### 日本語は -> [README_ja](https://github.com/taka-4602/Akinator-python/blob/main/README_ja.md)
## Requirement
- requests
- bs4
## Usage
Install this module, download example.py and run
#### example.py
```py
from akinator_python import Akinator
akinator=Akinator(lang="en")
akinator.start_game()
while True:
try:
print(akinator.question)
ans=input("answer:")
if ans=="b":
akinator.go_back()
else:
akinator.post_answer(ans)
if akinator.answer_id:
print(f"{akinator.name} / {akinator.description}")
ans=input("is it correct?:")
if ans=="n":
akinator.exclude()
elif ans=="y":
break
else:
break
except Exception as e:
print(e)
continue
```
I have prepared a super simple example code
You can just run and enjoy it in terminal :)
![0](https://raw.githubusercontent.com/taka-4602/Akinator-python/main/images/0.png)
## Know a little more
```Akinator()```
- You can set language, theme, child mode in arguments
- ```language=str```, The endpoint URL is determined based on this argument
If nothing is specified, ```lang=jp``` Japanese will be selected
- ```theme=str```, ```characters``` or ```objects``` or ```animals```
If nothing is specified, ```theme=characters``` characters will be selected
- ```child_mode=bool```
default is ```False```
```Akinator.start_game()```
- Start the Akinator game
it will return a first question in str
```Akinator.post_answer()```
- ```answer=str```
Answers are Yes : ```y``` No : ```n``` I don't know : ```idk``` probably : ```p``` probably not : ```pn```
```Akinator.go_back()```
- Yes, you can go back to the previous question
```Akinator.exclude()```
- If Akinator's answer is incorrect, you can restart the question
```Akinator.step```
- Always ```int```, you can check the number of questions
```Akinator.progression```
- Always ```float```, progress of Akinator's "guess"
```Akinator.question```
- Always ```str```, just a question
## When Akinator makes a guess
```Akinator.name```
- Default is ```None```, when it becomes available ```str```, Character name guessed by Akinator
```Akinator.description```
- Same as ```.name```, Character description guessed by Akinator
```Akinator.photo```
- Same as ```.name```, photo URL in ```str``` Character photo guessed by Akinator
# Supplement
```.post_ansewer()``` ```.go_back()``` ```.exclude()``` are return a dict
#### Question in progress
```
{'completion': 'OK', 'akitude': 'serein.png', 'step': '1', 'progression': '0.00000',
'question_id': '464', 'question': 'Is your character a girl?'}
```
#### When Akinator makes a guess
```
{'completion': 'OK', 'id_proposition': '309720', 'id_base_proposition': '10657795', 'valide_contrainte': '1',
'name_proposition': 'Arihara Nanami', 'description_proposition': 'Riddle Joker',
'flag_photo': '2', 'photo': 'https://photos.clarinea.fr/BL_2_en/600/partenaire/p/10657795__894179331.png', 'pseudo': 'MrSand', 'nb_elements': 1}
```
## Contacts
Discord server / https://discord.gg/aSyaAK7Ktm
Discord username / .taka.
Raw data
{
"_id": null,
"home_page": "https://github.com/taka-4602/Akinator-python",
"name": "Akinator-python",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "akinator",
"author": "taka4602",
"author_email": "shun4602@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f2/29/e9a16eeaca0da11faa2ff814827743a78624b98d29ba65a4c79c0455b011/Akinator-python-1.6.0.tar.gz",
"platform": null,
"description": "# Akinator-python\r\nAn API wrapper for the AkinatorAPI\r\n### >>```pip install akinator-python```<< \r\n### \u65e5\u672c\u8a9e\u306f -> [README_ja](https://github.com/taka-4602/Akinator-python/blob/main/README_ja.md)\r\n## Requirement\r\n- requests\r\n- bs4\r\n## Usage\r\nInstall this module, download example.py and run \r\n#### example.py\r\n```py\r\nfrom akinator_python import Akinator\r\n\r\nakinator=Akinator(lang=\"en\")\r\nakinator.start_game()\r\nwhile True:\r\n try:\r\n print(akinator.question)\r\n ans=input(\"answer\uff1a\")\r\n if ans==\"b\":\r\n akinator.go_back()\r\n else:\r\n akinator.post_answer(ans)\r\n if akinator.answer_id:\r\n print(f\"{akinator.name} / {akinator.description}\")\r\n ans=input(\"is it correct?\uff1a\")\r\n if ans==\"n\":\r\n akinator.exclude()\r\n elif ans==\"y\":\r\n break\r\n else:\r\n break\r\n except Exception as e:\r\n print(e)\r\n continue\r\n```\r\nI have prepared a super simple example code \r\nYou can just run and enjoy it in terminal :) \r\n![0](https://raw.githubusercontent.com/taka-4602/Akinator-python/main/images/0.png) \r\n## Know a little more\r\n```Akinator()``` \r\n- You can set language, theme, child mode in arguments \r\n- ```language=str```, The endpoint URL is determined based on this argument \r\n If nothing is specified, ```lang=jp``` Japanese will be selected \r\n- ```theme=str```, ```characters``` or ```objects``` or ```animals``` \r\n If nothing is specified, ```theme=characters``` characters will be selected\r\n- ```child_mode=bool``` \r\n default is ```False```\r\n\r\n```Akinator.start_game()``` \r\n- Start the Akinator game \r\n it will return a first question in str\r\n \r\n```Akinator.post_answer()``` \r\n- ```answer=str``` \r\n Answers are Yes : ```y``` No : ```n``` I don't know : ```idk``` probably : ```p``` probably not : ```pn```\r\n \r\n```Akinator.go_back()``` \r\n- Yes, you can go back to the previous question\r\n\r\n```Akinator.exclude()``` \r\n- If Akinator's answer is incorrect, you can restart the question\r\n\r\n```Akinator.step``` \r\n- Always ```int```, you can check the number of questions\r\n\r\n```Akinator.progression``` \r\n- Always ```float```, progress of Akinator's \"guess\"\r\n\r\n```Akinator.question``` \r\n- Always ```str```, just a question\r\n\r\n## When Akinator makes a guess\r\n```Akinator.name``` \r\n- Default is ```None```, when it becomes available ```str```, Character name guessed by Akinator\r\n\r\n```Akinator.description``` \r\n- Same as ```.name```, Character description guessed by Akinator\r\n\r\n```Akinator.photo``` \r\n- Same as ```.name```, photo URL in ```str``` Character photo guessed by Akinator\r\n# Supplement\r\n```.post_ansewer()``` ```.go_back()``` ```.exclude()``` are return a dict \r\n#### Question in progress\r\n```\r\n{'completion': 'OK', 'akitude': 'serein.png', 'step': '1', 'progression': '0.00000',\r\n 'question_id': '464', 'question': 'Is your character a girl?'}\r\n```\r\n#### When Akinator makes a guess\r\n```\r\n{'completion': 'OK', 'id_proposition': '309720', 'id_base_proposition': '10657795', 'valide_contrainte': '1',\r\n 'name_proposition': 'Arihara Nanami', 'description_proposition': 'Riddle Joker', \r\n 'flag_photo': '2', 'photo': 'https://photos.clarinea.fr/BL_2_en/600/partenaire/p/10657795__894179331.png', 'pseudo': 'MrSand', 'nb_elements': 1}\r\n``` \r\n## Contacts \r\nDiscord server / https://discord.gg/aSyaAK7Ktm \r\nDiscord username / .taka. \r\n",
"bugtrack_url": null,
"license": null,
"summary": "A API wrapper for the AkinatorAPI",
"version": "1.6.0",
"project_urls": {
"Homepage": "https://github.com/taka-4602/Akinator-python"
},
"split_keywords": [
"akinator"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f229e9a16eeaca0da11faa2ff814827743a78624b98d29ba65a4c79c0455b011",
"md5": "d5921317252d54e4282f12a1bec4d19c",
"sha256": "6dc0ecb14901a7ec77e12c99d9cc77647c624de0bb20e849c1c334e4ed2d615f"
},
"downloads": -1,
"filename": "Akinator-python-1.6.0.tar.gz",
"has_sig": false,
"md5_digest": "d5921317252d54e4282f12a1bec4d19c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 3923,
"upload_time": "2024-06-07T03:04:28",
"upload_time_iso_8601": "2024-06-07T03:04:28.870082Z",
"url": "https://files.pythonhosted.org/packages/f2/29/e9a16eeaca0da11faa2ff814827743a78624b98d29ba65a4c79c0455b011/Akinator-python-1.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-07 03:04:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "taka-4602",
"github_project": "Akinator-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "akinator-python"
}