or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

advanced.mdauth.mdchannels.mdchat.mdfiles.mdindex.mdinteractive.mdrtm.mdsearch.mdusers.md
tile.json

tessl/pypi-slacker

Slack API client providing comprehensive Python interface for messaging, file sharing, user management, and team communication features.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/slacker@0.14.x

To install, run

npx @tessl/cli install tessl/pypi-slacker@0.14.0

index.mddocs/

Slacker

A comprehensive Python interface for the Slack API, enabling developers to integrate with Slack's messaging, file sharing, user management, and team communication features. It offers a complete set of API endpoints wrapped in an object-oriented design with support for real-time messaging, file operations, authentication, and advanced features like reactions, pins, and webhooks.

Package Information

  • Package Name: slacker
  • Language: Python
  • Installation: pip install slacker

Core Imports

from slacker import Slacker

Basic Usage

from slacker import Slacker

# Initialize with your Slack API token
slack = Slacker('<your-slack-api-token-goes-here>')

# Send a message to a channel
response = slack.chat.post_message('#general', 'Hello fellow slackers!')

# Get users list
response = slack.users.list()
users = response.body['members']

# Upload a file
slack.files.upload('hello.txt')

# Advanced: Use requests.Session for connection pooling
from requests.sessions import Session
with Session() as session:
    slack = Slacker(token, session=session)
    slack.chat.post_message('#general', 'All these requests')
    slack.chat.post_message('#general', 'go through')
    slack.chat.post_message('#general', 'a single https connection')

Architecture

The Slacker library is organized around a central Slacker client class that provides access to various Slack API endpoint groups. Each endpoint group is implemented as a separate class inheriting from BaseAPI:

  • Slacker: Main client providing access to all API endpoints
  • BaseAPI: Base class handling HTTP requests, rate limiting, and error handling
  • Response: Wrapper for API responses with convenient access methods
  • Error: Custom exception for API errors
  • Endpoint Classes: Specialized classes for each API area (Chat, Users, Files, etc.)

This design allows for organized access to Slack's extensive API while providing common functionality like authentication, error handling, and rate limiting across all endpoints.

Capabilities

Authentication & Authorization

Handle user authentication, token validation, and OAuth flows for Slack applications.

class Auth(BaseAPI):
    def test(self): ...
    def revoke(self, test=True): ...

class OAuth(BaseAPI):
    def access(self, client_id, client_secret, code, redirect_uri=None): ...
    def token(self, client_id, client_secret, code, redirect_uri=None, single_channel=None): ...

Authentication & Authorization

Chat & Messaging

Send, update, and manage messages across channels, direct messages, and group conversations.

class Chat(BaseAPI):
    def post_message(self, channel, text=None, username=None, as_user=None, parse=None, link_names=None, attachments=None, unfurl_links=None, unfurl_media=None, icon_url=None, icon_emoji=None, thread_ts=None, reply_broadcast=None, blocks=None, mrkdwn=True): ...
    def update(self, channel, ts, text, attachments=None, parse=None, link_names=False, as_user=None, blocks=None): ...
    def delete(self, channel, ts, as_user=False): ...
    def post_ephemeral(self, channel, text, user, as_user=None, attachments=None, link_names=None, parse=None, blocks=None): ...

Chat & Messaging

Channel Management

Create, manage, and interact with public channels, private groups, and conversations.

class Channels(BaseAPI):
    def create(self, name): ...
    def info(self, channel): ...
    def list(self, exclude_archived=None, exclude_members=None): ...
    def history(self, channel, latest=None, oldest=None, count=None, inclusive=False, unreads=False): ...
    def join(self, name): ...
    def leave(self, channel): ...
    def invite(self, channel, user): ...
    def kick(self, channel, user): ...
    def get_channel_id(self, channel_name): ...

class Conversations(BaseAPI):
    def create(self, name, user_ids=None, is_private=None): ...
    def list(self, cursor=None, exclude_archived=None, types=None, limit=None): ...
    def history(self, channel, cursor=None, inclusive=None, latest=None, oldest=None, limit=None): ...
    def members(self, channel, cursor=None, limit=None): ...

Channel Management

User Management

Manage users, user profiles, presence status, and user groups within your Slack workspace.

class Users(BaseAPI):
    def info(self, user, include_locale=False): ...
    def list(self, presence=False): ...
    def identity(self): ...
    def set_active(self): ...
    def get_presence(self, user): ...
    def set_presence(self, presence): ...
    def get_user_id(self, user_name): ...

class UserGroups(BaseAPI):
    def list(self, include_disabled=None, include_count=None, include_users=None): ...
    def create(self, name, handle=None, description=None, channels=None, include_count=None): ...
    def update(self, usergroup, name=None, handle=None, description=None, channels=None, include_count=None): ...

User Management

File Operations

Upload, download, manage, and share files within Slack channels and conversations.

class Files(BaseAPI):
    def list(self, user=None, ts_from=None, ts_to=None, types=None, count=None, page=None, channel=None): ...
    def info(self, file_, count=None, page=None): ...
    def upload(self, file_=None, content=None, filetype=None, filename=None, title=None, initial_comment=None, channels=None, thread_ts=None): ...
    def delete(self, file_): ...
    def revoke_public_url(self, file_): ...
    def shared_public_url(self, file_): ...

File Operations

Search & Discovery

Search across messages, files, and other content within your Slack workspace.

class Search(BaseAPI):
    def all(self, query, sort=None, sort_dir=None, highlight=None, count=None, page=None): ...
    def files(self, query, sort=None, sort_dir=None, highlight=None, count=None, page=None): ...
    def messages(self, query, sort=None, sort_dir=None, highlight=None, count=None, page=None): ...

Search & Discovery

Real-time Messaging

Connect to Slack's Real Time Messaging API for live message streams and event handling.

class RTM(BaseAPI):
    def start(self, simple_latest=False, no_unreads=False, mpim_aware=False): ...
    def connect(self): ...

Real-time Messaging

Interactive Features

Manage reactions, starred items, pinned messages, and other interactive Slack features.

class Reactions(BaseAPI):
    def add(self, name, file_=None, file_comment=None, channel=None, timestamp=None): ...
    def get(self, file_=None, file_comment=None, channel=None, timestamp=None, full=None): ...
    def list(self, user=None, full=None, count=None, page=None): ...
    def remove(self, name, file_=None, file_comment=None, channel=None, timestamp=None): ...

class Stars(BaseAPI):
    def add(self, file_=None, file_comment=None, channel=None, timestamp=None): ...
    def list(self, user=None, count=None, page=None): ...
    def remove(self, file_=None, file_comment=None, channel=None, timestamp=None): ...

class Pins(BaseAPI):
    def add(self, channel, file_=None, file_comment=None, timestamp=None): ...
    def remove(self, channel, file_=None, file_comment=None, timestamp=None): ...
    def list(self, channel): ...

Interactive Features

Advanced Features

Additional Slack functionality including webhooks, dialogs, presence management, Do Not Disturb settings, reminders, team administration, bot management, migration utilities, and direct messaging.

class IncomingWebhook:
    def post(self, data): ...

class Dialog(BaseAPI):
    def open(self, dialog, trigger_id): ...

class Presence(BaseAPI):
    def set(self, presence): ...

class DND(BaseAPI):
    def team_info(self, users=None): ...
    def set_snooze(self, num_minutes): ...
    def info(self, user=None): ...
    def end_dnd(self): ...
    def end_snooze(self): ...

class Reminders(BaseAPI):
    def add(self, text, time, user=None): ...
    def complete(self, reminder): ...
    def delete(self, reminder): ...
    def info(self, reminder): ...
    def list(self): ...

Advanced Features

Types

class Slacker:
    """
    Main Slack API client.
    
    Args:
        token (str): Slack API token
        incoming_webhook_url (str, optional): URL for incoming webhooks
        timeout (int): HTTP request timeout in seconds (default: 10)
        http_proxy (str, optional): HTTP proxy URL
        https_proxy (str, optional): HTTPS proxy URL
        session (requests.Session, optional): Custom requests session for connection pooling
        rate_limit_retries (int): Number of retries for rate-limited requests (default: 0)
    """
    def __init__(self, token, incoming_webhook_url=None, timeout=DEFAULT_TIMEOUT, http_proxy=None, https_proxy=None, session=None, rate_limit_retries=DEFAULT_RETRIES): ...

class Response:
    """
    Wrapper for Slack API responses.
    
    Attributes:
        raw (str): Raw response text
        body (dict): Parsed JSON response
        successful (bool): Whether the API call was successful
        error (str, optional): Error message if unsuccessful
    """
    def __init__(self, body): ...
    def __str__(self): ...

class Error(Exception):
    """Custom exception for Slack API errors."""
    pass

class BaseAPI:
    """
    Base class for all API endpoint classes.
    
    Args:
        token (str, optional): Slack API token
        timeout (int): HTTP request timeout (default: 10)
        proxies (dict, optional): Proxy configuration
        session (requests.Session, optional): Custom session
        rate_limit_retries (int): Rate limit retry count (default: 0)
    """
    def __init__(self, token=None, timeout=DEFAULT_TIMEOUT, proxies=None, session=None, rate_limit_retries=DEFAULT_RETRIES): ...
    def get(self, api, **kwargs): ...
    def post(self, api, **kwargs): ...

Utility Functions

def get_api_url(method):
    """
    Build Slack API URL for given method.
    
    Args:
        method (str): API method name (e.g., 'chat.postMessage')
    
    Returns:
        str: Complete API URL
    """

def get_item_id_by_name(list_dict, key_name):
    """
    Find item ID by name in list of dictionaries.
    
    Args:
        list_dict (list): List of dictionaries with 'name' and 'id' keys
        key_name (str): Name to search for
    
    Returns:
        str or None: Item ID if found, None otherwise
    """