Initializing the client

A client can be initialized in order to either make requests anonymously, or through an account, by instantiating a Client in an asynchronous context:

from __future__ import annotations

import asyncio

from planetcasio.client import Client


async def main() -> None:
    async with Client() as client:
        ...


asyncio.run(main())

If you wish to authenticate as an account in order to access operations that require it, you can pass the credentials of the user to authenticate as through the auth keyword parameter:

from __future__ import annotations

import asyncio

from planetcasio.client import Client


async def main() -> None:
    async with Client(auth=("<username>", "<password>")) as client:
        ...


asyncio.run(main())

You can obtain a session cookie to use in separate requests by calling Account.get_cookie():

from __future__ import annotations

import asyncio

from planetcasio.client import Client


async def main() -> None:
    async with Client(auth=("<username>", "<password>")) as client:
        token = await client.account.get_cookie()
        ...


asyncio.run(main())