Interfaces ๐งฉ#
The Interface โจ#
The easiest way to retrieve data from the Nova api using NovaUniverse.py is by using the interfaces available to you. As of March 2023, this api wrapper covers some of the novauniverse apiโs endpoints with an interface.
Hereโs a quick showcase on how to use them.
Getting Discord Stats:
from novauniverse import Discord # Get discord server stats. discord_stats = Discord().get_stats() # Prints out the member count. print(f"There are {discord_stats.member_count.members} members on the Nova Universe discord server.")Getting Newsletters:
from novauniverse import News # Get latest newsletter. latest_newsletter = News().get_latest() # Print it. print(f"The url for the news letter '{latest_newsletter.title}' is '{latest_newsletter.full_url}'.")Getting online players:
from novauniverse import Server # Get all online players on the minecraft server. online_players = Server().get_online_players() # Print all online players on the minecraft server. for player in online_players: print(f"{player.username} is online on the '{player.server_name}' server.")Getting tournament results:
from novauniverse import NovaGames, MCF # Get the latest Nova Games tournament. nova_games = NovaGames().get_latest() # Prints out how much each player scored in that tournament and also how many kills they achieved. for player in nova_games.players: print(f"'{player.username}' got {player.kills} kill(s) and scored {player.score} point(s) in the Nova Games hosted on {nova_games.date.date()}.")Note
MCF interface also exists this same way.
Neat right ๐.
The Search interface ๐#
Some interfaces/endpoints obtain search features, specially those that inherited from SearchInterface.
Here we are searching by id:
from novauniverse import News, Search newsletter = News().search(Search(id=17)) print(f"Name of news letter --> {newsletter.name}") print(f"ID of news letter --> {newsletter.id}")Here we are searching by name:
from novauniverse import News, Search newsletter = News().search(Search(name="Api Wrappers")) print(f"Name of news letter --> {newsletter.name}") print(f"ID of news letter --> {newsletter.id}")Warning
Each interface supports itโs own SearchBy options. For example News() might support searching by id but not support searching by name. If this is the case
SearchNotCompletelySupported()
will be raised.More examples:
from novauniverse import MCF, Search mcf = MCF().search(Search(id=17)) for player in mcf.players: print(f"'{player.username}' got {player.kills} kill(s) and scored {player.score} point(s) in the MCF hosted on {mcf.date.date()}.")Note
If you would like more help, you may open a Github issue or help ticket on the NovaUniverse Discord.
Interface Reference#
- class novauniverse.interfaces.BasicInterface[source]#
Bases:
Interface
A basic interface, nothing moreโฆ nothing lessโฆ
- class novauniverse.interfaces.Interface[source]#
Bases:
object
The base interface where all NovaUniverse.py endpoint interfaces inherit from.