novelai-api


Namenovelai-api JSON
Version 0.26.0 PyPI version JSON
download
home_pagehttps://github.com/Aedial/novelai-api
SummaryPython API for the NovelAI REST API
upload_time2024-04-07 12:45:43
maintainerNone
docs_urlNone
authorAedial
requires_python<4.0.0,>=3.8.10
licenseMIT
keywords python novelai nai api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # novelai-api
Python API for the NovelAI REST API

This module is intended to be used by developers as a helper for using NovelAI's REST API.

| Category         | Badges                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Pypi             | [![PyPI](https://img.shields.io/pypi/v/novelai-api)](https://pypi.org/project/novelai-api) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/novelai-api)](https://pypi.org/project/novelai-api) [![PyPI - License](https://img.shields.io/pypi/l/novelai-api)](https://pypi.org/project/novelai-api/) [![PyPI - Format](https://img.shields.io/pypi/format/novelai-api)](https://pypi.org/project/novelai-api/)                                                                                                                                                                                                                                                                                               |
| Quality checking | [![Python package](https://github.com/Aedial/novelai-api/actions/workflows/python-package.yml/badge.svg)](https://github.com/Aedial/novelai-api/actions/workflows/python-package.yml) [![Python package](https://github.com/Aedial/novelai-api/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/Aedial/novelai-api/actions/workflows/codeql-analysis.yml) [![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint) [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) |
| Stats            | [![GitHub top language](https://img.shields.io/github/languages/top/Aedial/novelai-api)](https://github.com/Aedial/novelai-api/search?l=python) ![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/Aedial/novelai-api) ![GitHub repo size](https://img.shields.io/github/repo-size/Aedial/novelai-api) ![Pypi package size](https://byob.yarr.is/Aedial/novelai-api/pypi-size) ![GitHub issues](https://img.shields.io/github/issues-raw/Aedial/novelai-api) ![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/Aedial/novelai-api)                                                                                                                                 |
| Activity         | ![GitHub last commit](https://img.shields.io/github/last-commit/Aedial/novelai-api) ![GitHub commits since tagged version](https://img.shields.io/github/commits-since/Aedial/novelai-api/v0.26.0) ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/Aedial/novelai-api)                                                                                                                                                                                                                                                                                                                                                                                                                    |

Retired versions: 3.7.2
Final commit of retired versions can be found with the tag `py<version>` (e.g. `py3.7.2`).

# Usage
Download via [pip](https://pypi.org/project/novelai-api):
```
pip install novelai-api
```

## Using the module via Command Line

### Get access key
Get the access key for your account. This key is used to login to the API through the /login endpoint.
```bash
python -m novelai_api get_access_key <username> <password>
```

### Get access token
Login to the API and get the access token. This token is valid 30 days and is required to use most of the API.
```bash
python -m novelai_api get_access_token <username> <password>
```

### Sanity check
Run a sanity check on your user content. It will print what content couldn't be decrypted.
```bash
python -m novelai_api sanity_check <username> <password>
```

### Decode
Decode a b64 encoded tokenized text. This will print the tokens and the decoded text.
```bash
python -m novelai_api decode <model> <data>
```

## Using the module in your code
A full list of examples is available in the [example](example) directory

The API works through the NovelAIAPI object.
It is split in 2 groups: NovelAIAPI.low_level and NovelAIAPI.high_level

### low_level
The low level interface is a strict implementation of the official API (<https://api.novelai.net/docs>).
It only checks for input types via assert, and output schema if NovelAIAPI.low_level.is_schema_validation_enabled is True

### high_level
The high level interface builds on the low level one for easier handling of complex settings.
It handles many tasks from the frontend


# Development
All relevant objects are in the [novelai_api](novelai_api) directory.
The [Poetry](https://pypi.org/project/poetry/) package is required (`pip install poetry`) as the venv manager.

## Contributing
You can contribute features and enhancements through PR. Any PR should pass the tests and the pre-commits before submission.
The pre-commit hook can be installed via
```
poetry run nai-pre-commit
```

## Testing against the API
To run against the API, you can use `poetry run nai-test-api`.

[API](tests/api)

## Testing against the mocked API
To run against the mocked API, you can use `poetry run nai-test-mock`.

| :warning: WIP, does not work yet :warning: |
|--------------------------------------------|

[Mock](tests/mock)

## Docs
To build the docs, run
```
poetry run nai-build-docs
```
The docs will be locally viewable at docs/build/html/index.html

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Aedial/novelai-api",
    "name": "novelai-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.8.10",
    "maintainer_email": null,
    "keywords": "python, NovelAI, NAI, API",
    "author": "Aedial",
    "author_email": "aedial.dev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a0/75/e8e7bd2b4a3423e95db203f4f25b91e87e29cef1560ba38da6963e72f411/novelai_api-0.26.0.tar.gz",
    "platform": null,
    "description": "# novelai-api\nPython API for the NovelAI REST API\n\nThis module is intended to be used by developers as a helper for using NovelAI's REST API.\n\n| Category         | Badges                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Pypi             | [![PyPI](https://img.shields.io/pypi/v/novelai-api)](https://pypi.org/project/novelai-api) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/novelai-api)](https://pypi.org/project/novelai-api) [![PyPI - License](https://img.shields.io/pypi/l/novelai-api)](https://pypi.org/project/novelai-api/) [![PyPI - Format](https://img.shields.io/pypi/format/novelai-api)](https://pypi.org/project/novelai-api/)                                                                                                                                                                                                                                                                                               |\n| Quality checking | [![Python package](https://github.com/Aedial/novelai-api/actions/workflows/python-package.yml/badge.svg)](https://github.com/Aedial/novelai-api/actions/workflows/python-package.yml) [![Python package](https://github.com/Aedial/novelai-api/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/Aedial/novelai-api/actions/workflows/codeql-analysis.yml) [![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint) [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) |\n| Stats            | [![GitHub top language](https://img.shields.io/github/languages/top/Aedial/novelai-api)](https://github.com/Aedial/novelai-api/search?l=python) ![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/Aedial/novelai-api) ![GitHub repo size](https://img.shields.io/github/repo-size/Aedial/novelai-api) ![Pypi package size](https://byob.yarr.is/Aedial/novelai-api/pypi-size) ![GitHub issues](https://img.shields.io/github/issues-raw/Aedial/novelai-api) ![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/Aedial/novelai-api)                                                                                                                                 |\n| Activity         | ![GitHub last commit](https://img.shields.io/github/last-commit/Aedial/novelai-api) ![GitHub commits since tagged version](https://img.shields.io/github/commits-since/Aedial/novelai-api/v0.26.0) ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/Aedial/novelai-api)                                                                                                                                                                                                                                                                                                                                                                                                                    |\n\nRetired versions: 3.7.2\nFinal commit of retired versions can be found with the tag `py<version>` (e.g. `py3.7.2`).\n\n# Usage\nDownload via [pip](https://pypi.org/project/novelai-api):\n```\npip install novelai-api\n```\n\n## Using the module via Command Line\n\n### Get access key\nGet the access key for your account. This key is used to login to the API through the /login endpoint.\n```bash\npython -m novelai_api get_access_key <username> <password>\n```\n\n### Get access token\nLogin to the API and get the access token. This token is valid 30 days and is required to use most of the API.\n```bash\npython -m novelai_api get_access_token <username> <password>\n```\n\n### Sanity check\nRun a sanity check on your user content. It will print what content couldn't be decrypted.\n```bash\npython -m novelai_api sanity_check <username> <password>\n```\n\n### Decode\nDecode a b64 encoded tokenized text. This will print the tokens and the decoded text.\n```bash\npython -m novelai_api decode <model> <data>\n```\n\n## Using the module in your code\nA full list of examples is available in the [example](example) directory\n\nThe API works through the NovelAIAPI object.\nIt is split in 2 groups: NovelAIAPI.low_level and NovelAIAPI.high_level\n\n### low_level\nThe low level interface is a strict implementation of the official API (<https://api.novelai.net/docs>).\nIt only checks for input types via assert, and output schema if NovelAIAPI.low_level.is_schema_validation_enabled is True\n\n### high_level\nThe high level interface builds on the low level one for easier handling of complex settings.\nIt handles many tasks from the frontend\n\n\n# Development\nAll relevant objects are in the [novelai_api](novelai_api) directory.\nThe [Poetry](https://pypi.org/project/poetry/) package is required (`pip install poetry`) as the venv manager.\n\n## Contributing\nYou can contribute features and enhancements through PR. Any PR should pass the tests and the pre-commits before submission.\nThe pre-commit hook can be installed via\n```\npoetry run nai-pre-commit\n```\n\n## Testing against the API\nTo run against the API, you can use `poetry run nai-test-api`.\n\n[API](tests/api)\n\n## Testing against the mocked API\nTo run against the mocked API, you can use `poetry run nai-test-mock`.\n\n| :warning: WIP, does not work yet :warning: |\n|--------------------------------------------|\n\n[Mock](tests/mock)\n\n## Docs\nTo build the docs, run\n```\npoetry run nai-build-docs\n```\nThe docs will be locally viewable at docs/build/html/index.html\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python API for the NovelAI REST API",
    "version": "0.26.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/Aedial/novelai-api/issues",
        "Homepage": "https://github.com/Aedial/novelai-api",
        "Repository": "https://github.com/Aedial/novelai-api"
    },
    "split_keywords": [
        "python",
        " novelai",
        " nai",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9badb300c8e1c3e826baa9fe240ea6115bde7c62cee6b8cec1b5c19230f4e0bc",
                "md5": "7d3cd1c56a542adb9f41599c43ed4a10",
                "sha256": "ddb93841f132a5f1b25e5b211dd6078666e42e6d58cf5667b67d8d834eb95e23"
            },
            "downloads": -1,
            "filename": "novelai_api-0.26.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7d3cd1c56a542adb9f41599c43ed4a10",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.8.10",
            "size": 4079620,
            "upload_time": "2024-04-07T12:45:40",
            "upload_time_iso_8601": "2024-04-07T12:45:40.022900Z",
            "url": "https://files.pythonhosted.org/packages/9b/ad/b300c8e1c3e826baa9fe240ea6115bde7c62cee6b8cec1b5c19230f4e0bc/novelai_api-0.26.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a075e8e7bd2b4a3423e95db203f4f25b91e87e29cef1560ba38da6963e72f411",
                "md5": "e624d0b743a54b2d6d3a83bf31018823",
                "sha256": "5c6f711db4be44318fdf745d6a164919235af5c495de1f002bd8e78451ad406f"
            },
            "downloads": -1,
            "filename": "novelai_api-0.26.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e624d0b743a54b2d6d3a83bf31018823",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.8.10",
            "size": 4022775,
            "upload_time": "2024-04-07T12:45:43",
            "upload_time_iso_8601": "2024-04-07T12:45:43.100783Z",
            "url": "https://files.pythonhosted.org/packages/a0/75/e8e7bd2b4a3423e95db203f4f25b91e87e29cef1560ba38da6963e72f411/novelai_api-0.26.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-07 12:45:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Aedial",
    "github_project": "novelai-api",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "novelai-api"
}
        
Elapsed time: 0.22405s