Basic client usage¶
To create the API client:
from vulcan import Vulcan
client = Vulcan(keystore, account)
To select a student:
await client.select_student() # select the first available student
print(client.student) # print the selected student
students = await client.get_students()
client.student = students[1] # select the second student
Simple data fetching¶
All data is fetched from the VulcanData
class,
available as client.data
variable.
Note
Read the VulcanData
docs to see
all public data fetching methods.
lucky_number = await client.data.get_lucky_number()
print(lucky_number)
Data fetching - technical info¶
All data getting methods are asynchronous.
There are three return types of those methods:
object - applies to methods returning a single object (e.g. the currently selected student, the today’s lucky number, the server date-time)
list - applies to
get_students()
. The list is either read from the server or the in-memory cache.AsyncIterator - applies to all other data fetching methods. The returned iterator may be used like this:
grades = await client.data.get_grades() # with a for loop async for grade in grades: print(grade) # convert to a list grades = [grade async for grade in grades] print(grades[0]) for grade in grades: print(grade)
Note
You cannot re-use the AsyncIterator (once iterated through). As it is asynchronous, you also cannot use the next() method on it.