Package: bytespace
bytespace.pyBytespace (https://bytespace.network/) API library in Python.
This library makes connecting to the bytespace interfaces easier.FeaturesInterface managementCustom ExceptionsAutomatic token verificationSimple, fast, and easy to understandInterfacesDatabase InterfaceThis interface hosts the login API. By providing theappID(listed as key),username, andpasswordyou will receive a login token.
You can use the login token returned to get the unique user id which can be used to keep track of bytespace users in your database.frombytespace.interfacesimportDatabaseInterfaceinterface=DatabaseInterface(key="a5b98043-64f8-41cc-92c2-6da6fc4ff056")token=interface.connect(username="username",password="password")If anything information you provide is incorrect an exception will be raised.
The most notable exceptions areInvalidAppIDErrorandMissingParameterError.
Please check the exceptions section for more information.Auth InterfaceThis interface is used to verify whether a login token is valid or not.
By default, theDatabaseInterfacewill verify the login token for you.
However, if in any case you need to verify the token again,
or perhaps enough time has elapsed that verifying whether the token is still valid is justified.frombytespace.interfacesimportAuthInterfaceinterface=AuthInterface(key="a5b98043-64f8-41cc-92c2-6da6fc4ff056")interface.verify(token)Application InterfaceThis interface is used to get the user's unique 25 char long user id.
You can use this to keep track of the user as it is different for each bytespace member and does not change.
You are required to give the interface yourappID(called key here) andtoken(the login token obtained from theDatabaseInterface).frombytespace.interfacesimportApplicationInterfaceinterface=ApplicationInterface(key="a5b98043-64f8-41cc-92c2-6da6fc4ff056")interface.connect(token)Changing aspects of the interfaceChanging domain, protocol, etcThe domain, protocol, and directory are attributes of the interface class.
These attributes are used to build the urls before making a connection to the server.
So, we modify these attributes, the url built will change.
This was created for flexibility as you can modify the domain of where you want to connect to.
This means if bytespace ever changes domain, you can change this and the library will continue to work.This allows you to modify where, and how, the interface makes connections to.frombytespace.interfacesimportAuthInterfaceinterface=AuthInterface(key="a5b98043-64f8-41cc-92c2-6da6fc4ff056")print(interface.protocol)print(interface.domain)print(interface.directory)This code creates anAuthInterfaceand prints out all the attributes that makes up the domain built byAuthInterface.https
bytespace.network
IntefacesWe can change these by modifying them directly.frombytespace.interfacesimportAuthInterfaceinterface=AuthInterface()interface.protocol="http"interface.domain="example.com"interface.directory="api"This switches the doamin tohttp://example.com/api.
This means theAuthInterfacewill connect toexample.cominstead ofbytespace.network.Every interface also has the attributenamewhich is the name of the interface they are connecting to.
For AuthDatabase, this attribute is set to"AuthInterface".
You can also modify this, although it is not recommended.ContributorsContributing helps keep this library safe and up to date.
If you want to help, why not create an issue?