{"library":"pyslack","title":"pyslack","description":"pyslack is a Python API client for interacting with the Slack API. Last updated in September 2019 (version 0.5.0), it provides a synchronous interface for basic Slack operations. It has largely been superseded by the official and actively maintained `slack_sdk` library, which offers a broader feature set, asynchronous support, and better alignment with modern Slack API best practices.","language":"python","status":"deprecated","last_verified":"Thu Apr 16","install":{"commands":["pip install pyslack"],"cli":null},"imports":["from slack import Slack"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom slack import Slack\n\nSLACK_API_TOKEN = os.environ.get('SLACK_API_TOKEN', 'YOUR_SLACK_API_TOKEN')\n\n# Ensure you replace 'YOUR_SLACK_API_TOKEN' with an actual legacy token or bot token\n# and 'CHANNEL_ID' with the ID of the channel you want to post to.\n# For modern Slack apps, consider using slack_sdk with Bot User OAuth Tokens.\n\nif not SLACK_API_TOKEN or SLACK_API_TOKEN == 'YOUR_SLACK_API_TOKEN':\n    print(\"Error: SLACK_API_TOKEN environment variable not set or is default. Please set your Slack API token.\")\nelse:\n    try:\n        client = Slack(token=SLACK_API_TOKEN)\n        \n        # Example: Post a simple message to a channel\n        response = client.chat_postMessage(\n            channel='CHANNEL_ID',\n            text='Hello from pyslack!'\n        )\n        \n        if response.get('ok'):\n            print(f\"Message sent successfully: {response.get('ts')}\")\n        else:\n            print(f\"Error sending message: {response.get('error')}\")\n\n        # Example: Get information about the authenticated user\n        user_info = client.auth_test()\n        if user_info.get('ok'):\n            print(f\"Authenticated as: {user_info.get('user')}\")\n        else:\n            print(f\"Auth test failed: {user_info.get('error')}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"Initializes the `pyslack` client with a Slack API token and sends a basic message to a specified channel, then performs an authentication test. This requires a Slack API token (e.g., a legacy token or a bot token) and a channel ID. For new applications, `slack_sdk` is recommended due to its modern authentication and feature set.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}