pythontextnow


Namepythontextnow JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryA Python wrapper for TextNow.
upload_time2024-09-03 03:22:31
maintainerNone
docs_urlNone
authorJoey Greco
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">

<br>
<br>
<img src="https://raw.githubusercontent.com/joeyagreco/pythontextnow/main/img/pythontextnow_logo_.png" alt="pythontextnow logo" width="450"/>

Send SMS messages from Python!\
A Python wrapper for TextNow. 

[TextNow Website](https://www.textnow.com/)

[![PyPi Version](https://img.shields.io/pypi/v/pythontextnow)](https://pypi.org/project/pythontextnow/)
<br>
<a target="_blank" href="https://www.python.org/downloads/" title="Python version"><img src="https://img.shields.io/badge/python-%3E=_3.10-teal.svg"></a>
![Main Build](https://github.com/joeyagreco/pythontextnow/actions/workflows/main-build.yml/badge.svg)
![Last Commit](https://img.shields.io/github/last-commit/joeyagreco/pythontextnow)
</div>

### Table of Contents

- [Installation](https://github.com/joeyagreco/pythontextnow#installation)
- [Usage](https://github.com/joeyagreco/pythontextnow#usage)
    - [Configure Client](https://github.com/joeyagreco/pythontextnow#configure-client)
    - [Get Messages](https://github.com/joeyagreco/pythontextnow#get-messages)
    - [Send a Message](https://github.com/joeyagreco/pythontextnow#send-a-message)
    - [Send Media](https://github.com/joeyagreco/pythontextnow#send-media)
    - [Mark a Message as Read](https://github.com/joeyagreco/pythontextnow#mark-a-message-as-read)
    - [Delete a Message](https://github.com/joeyagreco/pythontextnow#delete-a-message)
    - [Delete a Conversation](https://github.com/joeyagreco/pythontextnow#delete-a-conversation)
- [Setup](https://github.com/joeyagreco/pythontextnow#setup)
    - [Obtaining Your Username](https://github.com/joeyagreco/pythontextnow#obtaining-your-username)
    - [Obtaining Your Cookies](https://github.com/joeyagreco/pythontextnow#obtaining-your-cookies)
- [Running Tests](https://github.com/joeyagreco/pythontextnow#running-tests)
- [Contributing](https://github.com/joeyagreco/pythontextnow#contributing)
- [License](https://github.com/joeyagreco/pythontextnow#license)

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install.

```bash
pip install pythontextnow
```

## Usage

Make sure you have the following before you begin:

- TextNow username
- SID cookie

For a guide on how to obtain these for your account, check [here](https://github.com/joeyagreco/pythontextnow#setup).

### Configure Client

Before you can call any methods, you must first set up your client config.

```python3
from pythontextnow import Client

USERNAME = "{your_username}"
SID_COOKIE = "{your_sid_cookie}"

Client.set_client_config(username=USERNAME, sid_cookie=SID_COOKIE)
```

The ConversationService is how you will perform any action.

It takes a list of phone numbers which define the conversation you would like to perform your actions on.

<!---
// @formatter:off
-->
**All phone numbers must be given in [E.164 format](https://help.aircall.io/en/articles/4350988-what-is-e-164-format).**
<!---
// @formatter:on
-->

```python3
from pythontextnow import ConversationService

PHONE_NUMBER_1 = "{some_phone_number}"
PHONE_NUMBER_2 = "{some_other_phone_number}"
conversation_service = ConversationService(conversation_phone_numbers=[PHONE_NUMBER_1, PHONE_NUMBER_2])
```

### Get Messages

The `get_messages()` method will return a [generator object](https://docs.python.org/3/glossary.html#term-generator).

This will return the messages from most -> least recent.

You can call `next()` with the returned generator each time you want to get the next group of messages.

```python3
messages_generator = conversation_service.get_messages()

messages = next(messages_generator)
```

You can also use a for loop to get all messages in a conversation.

```python3
messages_generator = conversation_service.get_messages()

all_messages = list()
for message_list in messages_generator:
    all_messages += message_list
```

You can specify how many messages back you would like to be retrieved by using the `num_messages` keyword argument.

```python3
messages_generator = conversation_service.get_messages(num_messages=10)

last_10_messages = list()
for message_list in messages_generator:
    last_10_messages += message_list
```

### Send a Message

To send a text message, use the `send_message()` method.

```python3
conversation_service.send_message(message="Hello World!")
```

### Send Media

To send media, use the `send_media()` method.

You can send:

- Images
- Videos
- GIFs

```python3
conversation_service.send_message(file_path="C:\\my_media.png")
```

### Mark a Message as Read

To mark a message as read, use the `mark_as_read()` method.

Mark a single message as read.

```python3
# assume you had a Message object saved to the variable "message_obj"

conversation_service.mark_as_read(message=message_obj)
```

Mark a list of messages as read.

```python3
# assume you had a list of Message objects saved to the variable "message_list"

conversation_service.mark_as_read(messages=message_list)
```

### Delete a Message

To delete a message, use the `delete_message()` method.

Delete a message by its ID.

```python3
conversation_service.delete_message(message_id="123456")
```

<!---
// @formatter:off
-->
Delete a message with its [Message](https://github.com/joeyagreco/pythontextnow/blob/main/pythontextnow/model/Message.py) object.
<!---
// @formatter:on
-->

```python3
# assume you had a Message object saved to the variable "message_obj"

conversation_service.delete_message(message=message_obj)
```

### Delete a Conversation

To delete a conversation, use the `delete_conversation()` method.

```python3
conversation_service.delete_conversation()
```

## Setup

### Obtaining Your Username

You will need to know your TextNow username to utilize this library.

This is the same username that you would use to log in.

To find this username:

- Go to [TextNow's messaging page](https://www.textnow.com/messaging) (make sure you are logged in)
- Click "Settings"
- Your username will be listed under "Account"

### Obtaining Your Cookie

You will need an SID cookie to utilize this library.

To find this cookie:

- Go to [TextNow's messaging page](https://www.textnow.com/messaging) (make sure you are logged in to your account)

> In **Chrome**:
> - Access [Developer Tools](https://developer.chrome.com/docs/devtools/open/) in your browser
> - Click on the "Application" tab
> - Click on the "Network" tab
> - Find a request under "Fetch/XHR"
> - Go to the "Headers" tab in the given request
> - Find the "Request Headers" section
> - Locate the "Cookie" field

> In **Firefox**
> - Access [Developer Tools](https://firefox-source-docs.mozilla.org/devtools-user/) in your browser
> - Click on the "Network" tab
> - Find a request under "XHR"
> - Go to the "Headers" tab in the given request
> - Find the "Request Headers" section
> - Locate the "Cookie" field

- Locate the "connect.sid" field, the value will be your SID cookie

## Running Tests

To run tests, run the following command:

```bash
  pytest
```

## 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](https://choosealicense.com/licenses/mit/)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pythontextnow",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Joey Greco",
    "author_email": "joeyagreco@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2c/79/ed74a79ddb7a7ee84d3f442530f66def37e85f116a34ace0176fa5da2657/pythontextnow-1.1.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n\n<br>\n<br>\n<img src=\"https://raw.githubusercontent.com/joeyagreco/pythontextnow/main/img/pythontextnow_logo_.png\" alt=\"pythontextnow logo\" width=\"450\"/>\n\nSend SMS messages from Python!\\\nA Python wrapper for TextNow. \n\n[TextNow Website](https://www.textnow.com/)\n\n[![PyPi Version](https://img.shields.io/pypi/v/pythontextnow)](https://pypi.org/project/pythontextnow/)\n<br>\n<a target=\"_blank\" href=\"https://www.python.org/downloads/\" title=\"Python version\"><img src=\"https://img.shields.io/badge/python-%3E=_3.10-teal.svg\"></a>\n![Main Build](https://github.com/joeyagreco/pythontextnow/actions/workflows/main-build.yml/badge.svg)\n![Last Commit](https://img.shields.io/github/last-commit/joeyagreco/pythontextnow)\n</div>\n\n### Table of Contents\n\n- [Installation](https://github.com/joeyagreco/pythontextnow#installation)\n- [Usage](https://github.com/joeyagreco/pythontextnow#usage)\n    - [Configure Client](https://github.com/joeyagreco/pythontextnow#configure-client)\n    - [Get Messages](https://github.com/joeyagreco/pythontextnow#get-messages)\n    - [Send a Message](https://github.com/joeyagreco/pythontextnow#send-a-message)\n    - [Send Media](https://github.com/joeyagreco/pythontextnow#send-media)\n    - [Mark a Message as Read](https://github.com/joeyagreco/pythontextnow#mark-a-message-as-read)\n    - [Delete a Message](https://github.com/joeyagreco/pythontextnow#delete-a-message)\n    - [Delete a Conversation](https://github.com/joeyagreco/pythontextnow#delete-a-conversation)\n- [Setup](https://github.com/joeyagreco/pythontextnow#setup)\n    - [Obtaining Your Username](https://github.com/joeyagreco/pythontextnow#obtaining-your-username)\n    - [Obtaining Your Cookies](https://github.com/joeyagreco/pythontextnow#obtaining-your-cookies)\n- [Running Tests](https://github.com/joeyagreco/pythontextnow#running-tests)\n- [Contributing](https://github.com/joeyagreco/pythontextnow#contributing)\n- [License](https://github.com/joeyagreco/pythontextnow#license)\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install.\n\n```bash\npip install pythontextnow\n```\n\n## Usage\n\nMake sure you have the following before you begin:\n\n- TextNow username\n- SID cookie\n\nFor a guide on how to obtain these for your account, check [here](https://github.com/joeyagreco/pythontextnow#setup).\n\n### Configure Client\n\nBefore you can call any methods, you must first set up your client config.\n\n```python3\nfrom pythontextnow import Client\n\nUSERNAME = \"{your_username}\"\nSID_COOKIE = \"{your_sid_cookie}\"\n\nClient.set_client_config(username=USERNAME, sid_cookie=SID_COOKIE)\n```\n\nThe ConversationService is how you will perform any action.\n\nIt takes a list of phone numbers which define the conversation you would like to perform your actions on.\n\n<!---\n// @formatter:off\n-->\n**All phone numbers must be given in [E.164 format](https://help.aircall.io/en/articles/4350988-what-is-e-164-format).**\n<!---\n// @formatter:on\n-->\n\n```python3\nfrom pythontextnow import ConversationService\n\nPHONE_NUMBER_1 = \"{some_phone_number}\"\nPHONE_NUMBER_2 = \"{some_other_phone_number}\"\nconversation_service = ConversationService(conversation_phone_numbers=[PHONE_NUMBER_1, PHONE_NUMBER_2])\n```\n\n### Get Messages\n\nThe `get_messages()` method will return a [generator object](https://docs.python.org/3/glossary.html#term-generator).\n\nThis will return the messages from most -> least recent.\n\nYou can call `next()` with the returned generator each time you want to get the next group of messages.\n\n```python3\nmessages_generator = conversation_service.get_messages()\n\nmessages = next(messages_generator)\n```\n\nYou can also use a for loop to get all messages in a conversation.\n\n```python3\nmessages_generator = conversation_service.get_messages()\n\nall_messages = list()\nfor message_list in messages_generator:\n    all_messages += message_list\n```\n\nYou can specify how many messages back you would like to be retrieved by using the `num_messages` keyword argument.\n\n```python3\nmessages_generator = conversation_service.get_messages(num_messages=10)\n\nlast_10_messages = list()\nfor message_list in messages_generator:\n    last_10_messages += message_list\n```\n\n### Send a Message\n\nTo send a text message, use the `send_message()` method.\n\n```python3\nconversation_service.send_message(message=\"Hello World!\")\n```\n\n### Send Media\n\nTo send media, use the `send_media()` method.\n\nYou can send:\n\n- Images\n- Videos\n- GIFs\n\n```python3\nconversation_service.send_message(file_path=\"C:\\\\my_media.png\")\n```\n\n### Mark a Message as Read\n\nTo mark a message as read, use the `mark_as_read()` method.\n\nMark a single message as read.\n\n```python3\n# assume you had a Message object saved to the variable \"message_obj\"\n\nconversation_service.mark_as_read(message=message_obj)\n```\n\nMark a list of messages as read.\n\n```python3\n# assume you had a list of Message objects saved to the variable \"message_list\"\n\nconversation_service.mark_as_read(messages=message_list)\n```\n\n### Delete a Message\n\nTo delete a message, use the `delete_message()` method.\n\nDelete a message by its ID.\n\n```python3\nconversation_service.delete_message(message_id=\"123456\")\n```\n\n<!---\n// @formatter:off\n-->\nDelete a message with its [Message](https://github.com/joeyagreco/pythontextnow/blob/main/pythontextnow/model/Message.py) object.\n<!---\n// @formatter:on\n-->\n\n```python3\n# assume you had a Message object saved to the variable \"message_obj\"\n\nconversation_service.delete_message(message=message_obj)\n```\n\n### Delete a Conversation\n\nTo delete a conversation, use the `delete_conversation()` method.\n\n```python3\nconversation_service.delete_conversation()\n```\n\n## Setup\n\n### Obtaining Your Username\n\nYou will need to know your TextNow username to utilize this library.\n\nThis is the same username that you would use to log in.\n\nTo find this username:\n\n- Go to [TextNow's messaging page](https://www.textnow.com/messaging) (make sure you are logged in)\n- Click \"Settings\"\n- Your username will be listed under \"Account\"\n\n### Obtaining Your Cookie\n\nYou will need an SID cookie to utilize this library.\n\nTo find this cookie:\n\n- Go to [TextNow's messaging page](https://www.textnow.com/messaging) (make sure you are logged in to your account)\n\n> In **Chrome**:\n> - Access [Developer Tools](https://developer.chrome.com/docs/devtools/open/) in your browser\n> - Click on the \"Application\" tab\n> - Click on the \"Network\" tab\n> - Find a request under \"Fetch/XHR\"\n> - Go to the \"Headers\" tab in the given request\n> - Find the \"Request Headers\" section\n> - Locate the \"Cookie\" field\n\n> In **Firefox**\n> - Access [Developer Tools](https://firefox-source-docs.mozilla.org/devtools-user/) in your browser\n> - Click on the \"Network\" tab\n> - Find a request under \"XHR\"\n> - Go to the \"Headers\" tab in the given request\n> - Find the \"Request Headers\" section\n> - Locate the \"Cookie\" field\n\n- Locate the \"connect.sid\" field, the value will be your SID cookie\n\n## Running Tests\n\nTo run tests, run the following command:\n\n```bash\n  pytest\n```\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python wrapper for TextNow.",
    "version": "1.1.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f627ec268b18dbbb14100fc6f646433c6bb38328c01706a56b17f919a53ce3f3",
                "md5": "e082c8e1d5599e36c7b55d01886d921b",
                "sha256": "8f4b0e0d9da0f1e9ec044d4c3070aa67071be90625d1c833297e012c28f3abc8"
            },
            "downloads": -1,
            "filename": "pythontextnow-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e082c8e1d5599e36c7b55d01886d921b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 22971,
            "upload_time": "2024-09-03T03:22:29",
            "upload_time_iso_8601": "2024-09-03T03:22:29.612852Z",
            "url": "https://files.pythonhosted.org/packages/f6/27/ec268b18dbbb14100fc6f646433c6bb38328c01706a56b17f919a53ce3f3/pythontextnow-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2c79ed74a79ddb7a7ee84d3f442530f66def37e85f116a34ace0176fa5da2657",
                "md5": "c35294d7f1a13f5ed7d9a41bed4f54d1",
                "sha256": "1557a7db0dadfef49c2fcdacb92a4f33f5de7ffa61845e86d824c6cc8beace3d"
            },
            "downloads": -1,
            "filename": "pythontextnow-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c35294d7f1a13f5ed7d9a41bed4f54d1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18502,
            "upload_time": "2024-09-03T03:22:31",
            "upload_time_iso_8601": "2024-09-03T03:22:31.010797Z",
            "url": "https://files.pythonhosted.org/packages/2c/79/ed74a79ddb7a7ee84d3f442530f66def37e85f116a34ace0176fa5da2657/pythontextnow-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-03 03:22:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pythontextnow"
}
        
Elapsed time: 0.30935s