API
client.py
- class SlskdClient(host: str, api_key: str = None, url_base: str = '/', username: str = None, password: str = None, token: str = None, verify_ssl: bool = True)
The main class that allows access to the different APIs of a slskd instance. An API-Key with appropriate permissions (readwrite for most use cases) must be set in slskd config file. Alternatively, provide your username and password. Requests error status raise corresponding error. Usage:
slskd = slskd_api.SlskdClient(host, api_key, url_base) app_status = slskd.application.state()
- class MetricsApi(host: str, metrics_usr: str = 'slskd', metrics_pwd: str = 'slskd', metrics_url_base: str = '/metrics')
Getting the metrics works with a different endpoint. Default: <slskd_url>:5030/metrics. Metrics should be first activated in slskd config file. User/pass is independent from the main application and default value (slskd:slskd) should be changed. Usage:
metrics_api = slskd_api.MetricsApi(host, metrics_usr='slskd', metrics_pwd='slskd') metrics = metrics_api.get()
apis/application.py
- class ApplicationApi(api_url: str, session: Session)
This class contains the methods to interact with the Application API.
- stop()
Stops the application. Only works with token (usr/pwd login). ‘Unauthorized’ with API-Key.
- Returns:
bool– True if successful.
apis/conversations.py
- class ConversationsApi(api_url: str, session: Session)
This class contains the methods to interact with the Conversations API.
- acknowledge(username: str, id: int)
Acknowledges the given message id for the given username.
- Returns:
bool– True if successful.
- acknowledge_all(username: str)
Acknowledges all messages from the given username.
- Returns:
bool– True if successful.
- delete(username: str)
Closes the conversation associated with the given username.
- Returns:
bool– True if successful.
- get(username: str, includeMessages: bool = True)
Gets the conversation associated with the specified username.
- Return type:
- send(username: str, message: str)
Sends a private message to the specified username.
- Returns:
bool– True if successful.
apis/logs.py
apis/options.py
- class OptionsApi(api_url: str, session: Session)
This class contains the methods to interact with the Options API.
- debug()
Gets the debug view of the current application options. debug and remote_configuration must be set to true. Only works with token (usr/pwd login). ‘Unauthorized’ with API-Key.
- Return type:
- yaml_location()
Gets the path of the yaml config file. remote_configuration must be set to true. Only works with token (usr/pwd login). ‘Unauthorized’ with API-Key.
- Return type:
- download_yaml()
Gets the content of the yaml config file as text. remote_configuration must be set to true. Only works with token (usr/pwd login). ‘Unauthorized’ with API-Key.
- Return type:
apis/public_chat.py
apis/relay.py
- class RelayApi(api_url: str, session: Session)
[UNTESTED] This class contains the methods to interact with the Relay API.
- download_file(token: str)
Downloads a file from the connected controller.
- Returns:
bool– True if successful.
- upload_file(token: str)
Uploads a file from the connected controller.
- Returns:
bool– True if successful.
Uploads share information to the connected controller.
- Returns:
bool– True if successful.
apis/rooms.py
- class RoomsApi(api_url: str, session: Session)
This class contains the methods to interact with the Rooms API.
- get_joined(roomName: str)
Gets the specified room.
- Returns:
dict– room info: name, isPrivate, users, messages
- send(roomName: str, message: str)
Sends a message to the specified room.
- Returns:
bool– True if successful.
- set_ticker(roomName: str, ticker: str)
Sets a ticker for the specified room.
- Returns:
bool– True if successful.
- add_member(roomName: str, username: str)
Adds a member to a private room.
- Returns:
bool– True if successful.
apis/searches.py
- class SearchesApi(api_url: str, session: Session)
Class that handles operations on searches.
- search_text(searchText: str, id: str | None = None, fileLimit: int = 10000, filterResponses: bool = True, maximumPeerQueueLength: int = 30, minimumPeerUploadSpeed: int = 100000, minimumResponseFileCount: int = 1, responseLimit: int = 500, searchTimeout: int = 5000)
Performs a search for the specified request.
- Parameters:
searchText (
str) – Search queryid (
Optional[str]) – uuid of the search. One will be generated if None.fileLimit (
int) – Max number of file resultsfilterResponses (
bool) – Filter unreachable users from the resultsmaximumPeerQueueLength (
int) – Max queue lengthminimumPeerUploadSpeed (
int) – Min upload speed in bit/sminimumResponseFileCount (
int) – Min number of matching files per userresponseLimit (
int) – Max number of users resultssearchTimeout (
int) – Search timeout in ms
- Returns:
dict– Info about the search (no results!)
- state(id: str, includeResponses: bool = False)
Gets the state of the search corresponding to the specified id.
apis/server.py
apis/session.py
apis/transfers.py
- class TransfersApi(api_url: str, session: Session)
This class contains the methods to interact with the Transfers API.
- cancel_download(username: str, id: str, remove: bool = False)
Cancels the specified download.
- Returns:
bool– True if successful.
- remove_completed_downloads()
Removes all completed downloads, regardless of whether they failed or succeeded.
- Returns:
bool– True if successful.
- cancel_upload(username: str, id: str, remove: bool = False)
Cancels the specified upload.
- Returns:
bool– True if successful.
- remove_completed_uploads()
Removes all completed uploads, regardless of whether they failed or succeeded.
- Returns:
bool– True if successful.
- enqueue(username: str, files: list)
Enqueues the specified download.
- Parameters:
username (
str) – User to download from.files (
list) – A list of dictionaries in the same form as what’s returned bysearch_responses(): [{‘filename’: <filename>, ‘size’: <filesize>}…]
- Returns:
bool– True if successful.
apis/users.py
- class UsersApi(api_url: str, session: Session)
This class contains the methods to interact with the Users API.
- browsing_status(username: str)
Retrieves the status of the current browse operation for the specified username, if any. Will return error 404 if called after the browsing operation has ended. Best called asynchronously while
browse()is still running.- Return type: