8000 GitHub - dimagi/turn-python: Python package for turn.io WhatsApp API
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

dimagi/turn-python

Repository files navigation

turn-python

Documentation Links

Usage

  1. Get an API token from Turn (currently only tokens are supported, not username / passwords)

  2. Add this as an environment variable, or pass in to the turn client

    $ export TURN_AUTH_TOKEN={your token}
  3. Usage

    from turn import TurnClient
    
    turn_client = TurnClient(token={optionally add your token here})
    
    # Get a user's whatsapp id
    wa_id = turn_client.contacts.get_whatsapp_id('123456')
    
    # Send a message
    turn_client.messages.send_text(wa_id, 'Hello')
    
    # Send a media file
    with open("example.jpg", "rb") as file:
        turn_client.messages.send_media(
            whatsapp_id=wa_id,
            file=file,
            content_type="image/jpeg",
            media_type="image",
            caption="Here’s an image"
        )

About

Python package for turn.io WhatsApp API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages

0