Skip to main content

Texting python package which utilizes TextNow.

Project description

TextNow API

TNAPI is a python module that uses TextNow to enable free programmable texting

Credit

  • Developer: Leonardo Wu-Gomez
  • Reddit: leogomezz4t
  • Please tell me if you have any ideas for the API or reporting a bug

Installation

Method One: Using git clone

git clone https://github.com/WuGomezCode/TextNow-API.git

Method Two: Using pip

pip install PyTextNow

Note: If there is an unexplained error with the pip install, try adding the --user flag to it.

Usage

How to send an sms message

import TNAPI

client = TNAPI.Client("Email address", "Password", "Name") #The name is used for the message storing.

client.send_sms("18006969420", "Hello World!")

How to send an mms message

file_path = "./img.jpeg"
client.send_mms("18006969420", file_path)

How to get new messages

new_messages = client.get_new_messages() -> List
for message in new_messages:
    print(message)
    # Class Message | Class MultiMediaMessage
    # Message
    # content: "body of sms"
    # number: "number of sender"
    # date: datetime object of when the message was received
    # first_contact: bool if its the first time that number texted you
    # type: MESSAGE_TYPE if class is Message and MULTIMEDIAMESSAGE_TYPE if class is MultiMediaMessage

    # MultiMediaMessage
    # number: "number of sender"
    # date: datetime object of when the message was received
    # first_contact: bool if its the first time that number texted you
    # type: MESSAGE_TYPE if class is Message and MULTIMEDIAMESSAGE_TYPE if class is MultiMediaMessage
    # url: "url of the media"
    # raw_data: bytes of the media
    # content_type: str the MIME type ie. "image/jpeg" or "video/mp4"
    # extension: str of the file extension is. "jpeg" or "mp4"
    # Functions
    # mv(file_path): downloads the file to file_path

    print(message.number)
    print(message.content)

    # MultiMediaMessage

    print(message.content_type)
    message.mv("./image." + message.extension)

How to get all messages

messages = client.get_messages() -> List
# Same as above

How to get all sent messages

sent_messages = client.get_sent_messages() -> List
#Same as above

Custom Module Exceptions

FailedRequest:

This API runs on web requests and if the request fails this Exception will be raised

Patch Notes

1.0.0

  • Complete overhaul of the way this module works.

  • client.get_new_messages() is now deprecated and no longer in use. Instead of that use the new method client.get_unread_messages() which will return all unread messages. It will return the same thing each time unless you mark the messages as read with Message.mark_as_read()

  • Message and MultiMediaMessage class have a new mark_as_read() method to mark the message as read. mark_as_read() will make a POST to the textnow.com server.

  • client.get_messages() now returns a list of Message or MultiMediaMessage classes. For the old function which returned the raw dict use client.get_raw_messages()

  • client.get_sent_messages() is a new method that gets all messages you have sent

  • client.get_received_messages() is a new method that gets all messages you have received regardless of whether or not it has been read.

  • client.get_read_messages() is a new method that returns all messages that have been read by you.

0.9.8

  • Bug Fixes

0.9.7

  • Bug Fixes

0.9.6

  • Bug Fixes

0.9.5

  • Linux __file__ not absolute. Used os.path.abspath

0.9.4

  • Bug fixes

0.9.3

  • Added constants such as
    • SENT_MESSAGE_TYPE
    • RECEIVED_MESSAGE_TYPE
    • MESSAGE_TYPE
    • MULTIMEDIAMESSAGE_TYPE
  • Fixed MultiMediaMessage.mv() function

0.9.2

  • No longer have to use selenium to authenticate. Now you have to manually grab connect.sid cookie.

0.9.1

  • Nothing much

0.9.0

  • Using Message and MultiMediaMessage classes instead of dictionary for /get_new_messages/get_sent_messages
  • get_messages still returns old dictionary
  • Fixed user_sids.json overwrite problem

0.8.0

  • Fixed the receiving messages. Now working 100%

0.7.0

  • Added FailedRequest and InvalidFileType errors to Client instance

0.5.0

  • bug fixes

0.4.0

  • Added Client = TNAPI.Client in __init__.py
  • Fixed the failed login import in TNAPI.py

0.3.0

  • Receiving messages are better but not good

0.2.0

  • Nothing much

0.1.0

  • Initial Commit
  • Can send messages and photos/videos
  • receiving messages a work in progress

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyTextNow-1.0.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyTextNow-1.0.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file PyTextNow-1.0.0.tar.gz.

File metadata

  • Download URL: PyTextNow-1.0.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.2

File hashes

Hashes for PyTextNow-1.0.0.tar.gz
Algorithm Hash digest
SHA256 778d3cfdbc3d407de1261bbdba8a7975a474ebe9f50367cceb384af13567331b
MD5 4560d91a4e5438eb6a490b3895755547
BLAKE2b-256 ed1d22a1683fdfdc12b46231e2b77ebef928fde4a01431772e3cb0c11448e769

See more details on using hashes here.

File details

Details for the file PyTextNow-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: PyTextNow-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.2

File hashes

Hashes for PyTextNow-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43e4fb405226f77b138b35fa3f821ae613c03406987d9d1213e0eda2b87156b2
MD5 2e0dd602b7df443966fdca3271fa9ac6
BLAKE2b-256 876af919b4990067debbbb9788fb57c2b0af550df45cb2ef7d4ae484c52d6cbc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page