bytespace.py
Bytespace (https://bytespace.network/) API library in Python. This library makes connecting to the bytespace interfaces easier.
Features
- Interface management
- Custom Exceptions
- Automatic token verification
- Simple, fast, and easy to understand
Interfaces
Database Interface
This interface hosts the login API. By providing the appID (listed as key), username, and password you 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.
from bytespace.interfaces import DatabaseInterface
interface = 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 are InvalidAppIDError and MissingParameterError.
Please check the exceptions section for more information.
Auth Interface
This interface is used to verify whether a login token is valid or not.
By default, the DatabaseInterface will 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.
from bytespace.interfaces import AuthInterface
interface = AuthInterface(key="a5b98043-64f8-41cc-92c2-6da6fc4ff056")
interface.verify(token)
Application Interface
This 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 your appID (called key here) and token (the login token obtained from the DatabaseInterface).
from bytespace.interfaces import ApplicationInterface
interface = ApplicationInterface(key="a5b98043-64f8-41cc-92c2-6da6fc4ff056")
interface.connect(token)
Changing aspects of the interface
Changing domain, protocol, etc
The 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.
from bytespace.interfaces import AuthInterface
interface = AuthInterface(key="a5b98043-64f8-41cc-92c2-6da6fc4ff056")
print(interface.protocol)
print(interface.domain)
print(interface.directory)
This code creates an AuthInterface and prints out all the attributes that makes up the domain built by AuthInterface.
https
bytespace.network
Intefaces
We can change these by modifying them directly.
from bytespace.interfaces import AuthInterface
interface = AuthInterface()
interface.protocol = "http"
interface.domain = "example.com"
interface.directory = "api"
This switches the doamin to http://example.com/api.
This means the AuthInterface will connect to example.com instead of bytespace.network.
Every interface also has the attribute name which 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.
Contributors
Contributing helps keep this library safe and up to date. If you want to help, why not create an issue?
Metadata
Release files for bytespace 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bytespace-1.1.0.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bytespace-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.8 kB
Release files / bytespace-1.1.0.tar.gz
| Download URL | bytespace-1.1.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f7200476aecc792be855cf00a61959a7d682bda595d38917d383f973ed09e35
|
|
BLAKE2b-256 checksum How to use checksums |
da2e3524fe9c4ec584abc17d0376a436d2567a04584884160abf6ff831d9ab38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Release files / bytespace-1.1.0-py3-none-any.whl
| Download URL | bytespace-1.1.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eff2cf8de55f38aa145d7e455556537e2a7b6d55b1ae76336554636e1c16b00f
|
|
BLAKE2b-256 checksum How to use checksums |
1aa5f6fb93dcfa96165f5d15768d93871755edb9017ec704c838c4b7b1db1f84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|