novelai_api.NovelAI_API

class NovelAIAPI[source]

Bases: object

BASE_ADDRESS: str = 'https://api.novelai.net'

The base address for the API

LIB_ROOT: str = '/home/runner/work/novelai-api/novelai-api/novelai_api'
__init__(session: aiohttp.client.ClientSession | None = None, logger: logging.Logger | None = None)[source]

Create a new NovelAIAPI object, which can be used to interact with the API. Use the low_level and high_level attributes for this purpose

Use attach_session and detach_session to switch between synchronous and asynchronous requests by attaching a ClientSession

Parameters:
  • session – The ClientSession to use for requests (None for synchronous)

  • logger – The logger to use for the API (None for creating an empty default logger)

logger: logging.Logger

The logger for the API

session: aiohttp.client.ClientSession | None

The client session for the API (None if synchronous)

headers: multidict._multidict.CIMultiDict

The headers for a request

cookies: http.cookies.SimpleCookie

The cookies for a request

proxy: str | yarl.URL | None = None

The proxy for a request (None if no proxy)

proxy_auth: aiohttp.helpers.BasicAuth | None = None

The proxy authentication for a request (None if no proxy)

low_level: novelai_api._low_level.LowLevel

The low-level API (thin wrapper)

high_level: novelai_api._high_level.HighLevel

The high-level API (abstraction on top of low-level)

attach_session(session: aiohttp.client.ClientSession)[source]

Attach a ClientSession, making the requests asynchronous

detach_session()[source]

Detach the current ClientSession, making the requests synchronous

property timeout: float

The timeout for a request (in seconds)