-
Notifications
You must be signed in to change notification settings - Fork 0
Usage Tips
seria edited this page May 15, 2024
·
2 revisions
Remember to call start
and close
or use the async with
syntax!
import yatta
async with yatta.YattaAPI() as api:
...
# Or
api = yatta.YattaAPI()
await api.start()
...
await api.close()
If you're using an IDE like pycharm or VSCode, you can alt + left click
on a variable and it will lead you the source code of the wrapper, from there you can see the model's docstring.
class BookSeries(BaseModel):
"""Represents a series of books.
Attributes:
id (int): The ID of the series.
name (str): The name of the series.
story (str): The story of the series.
image_list (list[str]): A list of image URLs.
"""
All exception classes can be found in ambr/exceptions.py, Catch them with try-except
.
import yatta
async with yatta.YattaAPI() as api:
try:
await api.fetch_character(0)
except yatta.exceptions.DataNotFoundError:
print("Character does not exist.")