Getting started

Installation

You can install vulcan-api using pip and git

# Linux and MacOS
pip3 install git+https://github.com/kapi2289/vulcan-api.git@async

# Windows
python -m pip install git+https://github.com/kapi2289/vulcan-api.git@async

API registration

To register the API as a mobile device, login to your e-register page (https://uonetplus.vulcan.net.pl/<symbol>) and go to the mobile access page.

_images/registration1.png _images/registration2.png

Then use the vulcan.Vulcan.register() function

from vulcan import Vulcan
import asyncio
import json

async def main():
    certificate = async Vulcan.register('<token>', '<symbol>', '<pin>')

Then save the generated certificate to a file

async def main():
    certificate = async Vulcan.register('<token>', '<symbol>', '<pin>')
    with open('cert.json', 'w') as f: # You can use other filename
        json.dump(certificate.json, f)

And finally run your code

if __name__ == '__main__':
    asyncio.run(main())

Basic usage

After registering API, now you can use it!

First of all, you need to load a certificate from a file

from vulcan import Vulcan
import asyncio
import json

with open('cert.json') as f:
    certificate = json.load(f)

and then, you need to create a client using the loaded certificate

client = await Vulcan.create(certificate)

API automatically sets the first available student as default. If your account has more than one student, you can fetch all students using vulcan.Vulcan.get_students() and set one of them as default

for student in await alist(client.get_students()):
    if student.name == "Jan Kowalski":
        client.set_student(student)
        break

Fetching data

Now you can fetch any data from your account, for example grades

Ostrzeżenie

Remember that functions return async_generators, NOT lists. If you want to get a list, you need to use async for and lists comprehension. Also, in some cases you can use await async_gen.__anext__(). e.g. grade_list = [_ async for _ in await client.get_grades()] You can find alias of this in from vulcan._utils import alist coroutine.

from vulcan._utils import alist

for grade in await alist(client.get_grades()):
    print(grade.content)
    print(grade.subject.name)
    print(grade.teacher.name)