Python API for the NovelAI REST API
Project description
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 | |
Quality checking | |
Stats | |
Activity |
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:
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.
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.
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.
python -m novelai_api sanity_check <username> <password>
Decode
Decode a b64 encoded tokenized text. This will print the tokens and the decoded text.
python -m novelai_api decode <model> <data>
Using the module in your code
A full list of examples is available in the 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 directory.
The 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
.
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: |
---|
Docs
To build the docs, run
poetry run nai-build-docs
The docs will be locally viewable at docs/build/html/index.html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file novelai_api-0.30.0.tar.gz
.
File metadata
- Download URL: novelai_api-0.30.0.tar.gz
- Upload date:
- Size: 4.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.0 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddd536eae6553029323e0cd9b0c6ab3ba10193014b5e73904c5b01aeae46485a |
|
MD5 | 003ded32ba8d25731d061358689f25be |
|
BLAKE2b-256 | 4241bca62d74bb6d649988898fb45a66f7f9f8a82349c441910076e9cc5abc7a |
File details
Details for the file novelai_api-0.30.0-py3-none-any.whl
.
File metadata
- Download URL: novelai_api-0.30.0-py3-none-any.whl
- Upload date:
- Size: 4.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.0 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb6490ab8bccddda72edc15d8227f163d7183e8af0ceeb5d56a75f7f3d6fd4a2 |
|
MD5 | b28ee7211f2e10aae16407e6eb74904d |
|
BLAKE2b-256 | d0e0608ff6686c9c4a3c70f3629e7ec0165bbaa6fb18fc6fecd98fcfefe364e2 |