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()
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()
get()

Gets the Prometheus metrics as text.

Return type:

str

apis/application.py

class ApplicationApi(api_url: str, session: Session)

This class contains the methods to interact with the Application API.

state()

Gets the current state of the application.

Return type:

dict

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.

version()

Gets the current application version.

Return type:

str

check_updates(forceCheck: bool = False)

Checks for updates.

Return type:

dict

gc()

Forces garbage collection.

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:

dict

send(username: str, message: str)

Sends a private message to the specified username.

Returns:

bool – True if successful.

get_all(includeInactive: bool = False, unAcknowledgedOnly: bool = False)

Gets all active conversations.

Return type:

list

get_messages(username: str, unAcknowledgedOnly: bool = False)

Gets all messages associated with the specified username.

Return type:

list

apis/logs.py

class LogsApi(api_url: str, session: Session)

This class contains the methods to interact with the Logs API.

get()

Gets the last few application logs.

Return type:

list

apis/options.py

class OptionsApi(api_url: str, session: Session)

This class contains the methods to interact with the Options API.

get()

Gets the current application options.

Return type:

dict

get_startup()

Gets the application options provided at startup.

Return type:

dict

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:

str

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:

str

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:

str

upload_yaml(yaml_content: str)

Sets the content of the yaml config file. remote_configuration must be set to true. Only works with token (usr/pwd login). ‘Unauthorized’ with API-Key.

Returns:

bool – True if successful.

validate_yaml(yaml_content: str)

Validates the provided yaml string. remote_configuration must be set to true. Only works with token (usr/pwd login). ‘Unauthorized’ with API-Key.

Returns:

str – Empty string if validation successful. Error message otherwise.

apis/public_chat.py

class PublicChatApi(api_url: str, session: Session)

[UNTESTED] This class contains the methods to interact with the PublicChat API.

start()

Starts public chat.

Returns:

bool – True if successful.

stop()

Stops public chat.

Returns:

bool – True if successful.

apis/relay.py

class RelayApi(api_url: str, session: Session)

[UNTESTED] This class contains the methods to interact with the Relay API.

connect()

Connects to the configured controller.

Returns:

bool – True if successful.

disconnect()

Disconnects from the connected controller.

Returns:

bool – True if successful.

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.

upload_share_info(token: str)

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_all_joined()

Gets all joined rooms.

Returns:

list – Names of the joined rooms.

join(roomName: str)

Joins a room.

Returns:

dict – room info: name, isPrivate, users, messages

get_joined(roomName: str)

Gets the specified room.

Returns:

dict – room info: name, isPrivate, users, messages

leave(roomName: str)

Leaves a room.

Returns:

bool – True if successful.

send(roomName: str, message: str)

Sends a message to the specified room.

Returns:

bool – True if successful.

get_messages(roomName: str)

Gets the current list of messages for the specified room.

Return type:

list

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.

get_users(roomName: str)

Gets the current list of users for the specified joined room.

Return type:

list

get_all()

Gets a list of rooms from the server.

Return type:

list

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 = 1000000, minimumPeerUploadSpeed: int = 0, minimumResponseFileCount: int = 1, responseLimit: int = 100, searchTimeout: int = 15000)

Performs a search for the specified request.

Parameters:
  • searchText (str) – Search query

  • id (Optional[str]) – uuid of the search. One will be generated if None.

  • fileLimit (int) – Max number of file results

  • filterResponses (bool) – Filter unreachable users from the results

  • maximumPeerQueueLength (int) – Max queue length

  • minimumPeerUploadSpeed (int) – Min upload speed in bit/s

  • minimumResponseFileCount (int) – Min number of matching files per user

  • responseLimit (int) – Max number of users results

  • searchTimeout (int) – Search timeout in ms

Returns:

dict – Info about the search (no results!)

get_all()

Gets the list of active and completed searches.

Return type:

list

state(id: str, includeResponses: bool = False)

Gets the state of the search corresponding to the specified id.

Parameters:
  • id (str) – uuid of the search.

  • includeResponses (bool) – Include responses (search result list) in the returned dict

Returns:

dict – 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:

True if successful.

search_responses(id: str)

Gets search responses corresponding to the specified id.

Return type:

list

apis/server.py

class ServerApi(api_url: str, session: Session)

This class contains the methods to interact with the Server API.

connect()

Connects the client.

Returns:

bool – True if successful.

disconnect()

Disconnects the client.

Returns:

bool – True if successful.

state()

Retrieves the current state of the server.

Return type:

dict

apis/session.py

class SessionApi(api_url: str, session: Session)

This class contains the methods to interact with the Session API.

auth_valid()

Checks whether the provided authentication is valid.

Return type:

bool

login(username: str, password: str)

Logs in.

Returns:

dict – Session info for the given user incl. token.

security_enabled()

Checks whether security is enabled.

Return type:

bool

apis/shares.py

class SharesApi(api_url: str, session: Session)

This class contains the methods to interact with the Shares API.

get_all()

Gets the current list of shares.

Return type:

dict

start_scan()

Initiates a scan of the configured shares.

Returns:

bool – True if successful.

cancel_scan()

Cancels a share scan, if one is running.

Returns:

bool – True if successful.

get(id: str)

Gets the share associated with the specified id.

Return type:

dict

all_contents()

Returns a list of all shared directories and files.

Return type:

list

contents(id: str)

Gets the contents of the share associated with the specified id.

Return type:

list

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.

get_download(username: str, id: str)

Gets the specified download.

Return type:

dict

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.

get_upload(username: str, id: str)

Gets the specified upload.

Return type:

dict

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 by search_responses(): [{‘filename’: <filename>, ‘size’: <filesize>}…]

Returns:

bool – True if successful.

get_downloads(username: str)

Gets all downloads for the specified username.

Return type:

dict

get_all_downloads(includeRemoved: bool = False)

Gets all downloads.

Return type:

list

get_queue_position(username: str, id: str)

Gets the download for the specified username matching the specified filename, and requests the current place in the remote queue of the specified download.

Returns:

Union[int, str] – Queue position or error message

get_all_uploads(includeRemoved: bool = False)

Gets all uploads.

Return type:

list

get_uploads(username: str)

Gets all uploads for the specified username.

Return type:

dict

apis/users.py

class UsersApi(api_url: str, session: Session)

This class contains the methods to interact with the Users API.

address(username: str)

Retrieves the address of the specified username.

Return type:

dict

browse(username: str)

Retrieves the files shared by the specified username.

Return type:

dict

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:

dict

directory(username: str, directory: str)

Retrieves the files from the specified directory from the specified username.

Return type:

dict

info(username: str)

Retrieves information about the specified username.

Return type:

dict

status(username: str)

Retrieves status for the specified username.

Return type:

dict