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, timeout: float = None)
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()
apis/_types.py
- class AppVersion
TypedDict describing application version. Returned by
check_updates().
- class AppState
TypedDict describing application state. Returned by
state().-
version:
AppVersion
-
server:
ServerState
-
version:
- class Message
TypedDict describing a message. Element of
Conversation.
- class Event
TypedDict describing an event. Single element of list returned by
get().
- class Directory
TypedDict describing a directory in the downloads or incomplete folder. See
FilesApi.
- class RoomInfo
TypedDict describing room info.
- class RoomUser
TypedDict describing a room user.
- class Room
TypedDict describing a room. Returned by
join()andget_joined().-
messages:
list[RoomMessage]
-
messages:
- class SearchFile
TypedDict describing a single search file result. Element found in
SearchResponseItem.
- class SearchResponseItem
TypedDict describing a search response item. Single element of list returned by
search_responses().-
files:
list[SearchFile]
-
lockedFiles:
list[SearchFile]
-
files:
- class SearchState
TypedDict describing search state. Returned by
state().-
responses:
list[SearchResponseItem]
-
responses:
TypedDict describing a shared directory. Returned by
get().
TypedDict describing all shares (local or from relays). Returned by
get_all().
- class TransferedFile
TypedDict describing a transfered file. Element found in
TransferedDirectory.
- class TransferedDirectory
TypedDict describing a transfered directory. Element found in
Transfer.-
files:
list[TransferedFile]
-
files:
- class Transfer
TypedDict describing transfer(s) to/from a given user. See
TransfersApi.-
directories:
list[TransferedDirectory]
-
directories:
- class BrowsingStatus
TypedDict describing browsing status of a user’s shares. Returned by
browsing_status().
- class FileAttribute
TypedDict describing a file attribute. Defined attributes are added as new keys to
UserFile.
- class UserFile
TypedDict describing a user file. Found in
UserDirectory.-
attributes:
list[FileAttribute]
-
attributes:
- class UserDirectory
TypedDict describing a user directory either locked or not. See
UserRootDir.
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.
- restart()
Restarts 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/events.py
apis/files.py
- class FilesApi(api_url: str, session: Session)
This class contains the methods to interact with the Files API. In order to delete files/directory you need to set remoteFileManagement: true in slskd.yml.
- get_downloaded_directory(dir_name: str, recursive: bool = False)
Lists the contents of the specified subdirectory within the downloads directory.
- delete_downloaded_directory(dir_name: str)
Deletes the specified subdirectory within the downloads directory.
- Return type:
- delete_downloaded_file(file_name: str)
Deletes the specified file within the downloads directory.
- Return type:
- get_incomplete_directory(dir_name: str, recursive: bool = False)
Lists the contents of the specified subdirectory within the incomplete directory.
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/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.
- 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, fileLimit: int = 10000, filterResponses: bool = True, maximumPeerQueueLength: int = 1000000, minimumPeerUploadSpeed: int = 0, minimumResponseFileCount: int = 1, responseLimit: int = 100, searchTimeout: int = 15000)
Performs a search for the specified request.
- Parameters:
searchText (
str) – Search queryid (
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:
SearchState– Info about the search (no results!)
- get_all()
Gets the list of active and completed searches.
- Return type:
- state(id: str, includeResponses: bool = False)
Gets the state of the search corresponding to the specified id.
- Parameters:
- Returns:
SearchState– Info about the search
- stop(id: str)
Stops the search corresponding to the specified id.
- Returns:
bool– True if successful.
- delete(id: str)
Deletes the search corresponding to the specified id.
- Returns:
bool– True if successful.
- search_responses(id: str)
Gets search responses corresponding to the specified id.
- Parameters:
id (
str) – uuid of the search.- Returns:
list[SearchResponseItem] – Search responses.
apis/server.py
apis/session.py
apis/telemetry.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:
- directory(username: str, directory: str)
Retrieves the specified directory from the specified user. This returns a list (usually with a single element).
- Return type: