Git Product home page Git Product logo

stream-chat-python's Introduction

stream-chat-python

Build Status codecov PyPI version PyPI - Python Version

the official Python API client for Stream chat a service for building chat applications.

You can sign up for a Stream account at https://getstream.io/chat/get_started/.

You can use this library to access chat API endpoints server-side, for the client-side integrations (web and mobile) have a look at the Javascript, iOS and Android SDK libraries (https://getstream.io/chat/).

Installation

pip install stream-chat

Documentation

Official API docs

How to build a chat app with Python tutorial

Chat with Python, Django and React

Supported features

  • Chat channels
  • Messages
  • Chat channel types
  • User management
  • Moderation API
  • Push configuration
  • User devices
  • User search
  • Channel search

Quickstart

Sync

from stream_chat import StreamChat


def main():
    chat = StreamChat(api_key="STREAM_KEY", api_secret="STREAM_SECRET")

    # add a user
    chat.update_user({"id": "chuck", "name": "Chuck"})

    # create a channel about kung-fu
    channel = chat.channel("messaging", "kung-fu")
    channel.create("chuck")

    # add a first message to the channel
    channel.send_message({"text": "AMA about kung-fu"}, "chuck")


if __name__ == '__main__':
    main()

Async

import asyncio
from stream_chat import StreamChatAsync


async def main():
    async with StreamChatAsync(api_key="STREAM_KEY", api_secret="STREAM_SECRET") as chat:
        # add a user
        await chat.update_user({"id": "chuck", "name": "Chuck"})

        # create a channel about kung-fu
        channel = chat.channel("messaging", "kung-fu")
        await channel.create("chuck")

        # add a first message to the channel
        await channel.send_message({"text": "AMA about kung-fu"}, "chuck")


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(main())
    finally:
        loop.run_until_complete(loop.shutdown_asyncgens())
        loop.close()

Contributing

Install pytest and pytest-asyncio

pip install pytest
pip install pytest-asyncio

First, make sure you can run the test suite. Tests are run via py.test

export STREAM_KEY=my_api_key
export STREAM_SECRET=my_api_secret

make test

Install black and pycodestyle

pip install black
pip install pycodestyle

Run linters

make lint

Releasing a new version

In order to release new version you need to be a maintainer on Pypi.

  • Update CHANGELOG
  • Make sure you have twine installed (pip install twine)
  • Update the version on setup.py
  • Commit and push to Github
  • Create a new tag for the version (eg. v2.9.0)
  • Create a new dist with python python setup.py sdist
  • Upload the new distributable with twine twine upload dist/stream-chat-VERSION-NAME.tar.gz

If unsure you can also test using the Pypi test servers twine upload --repository-url https://test.pypi.org/legacy/ dist/stream-chat-VERSION-NAME.tar.gz

stream-chat-python's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.