jetblack-tweeter


Namejetblack-tweeter JSON
Version 0.10.0 PyPI version JSON
download
home_pagehttps://github.com/rob-blackbourn/jetblack-tweeter
SummaryAn asyncio twitter client
upload_time2023-05-28 10:18:32
maintainer
docs_urlNone
authorRob Blackbourn
requires_python>=3.8,<4.0
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # jetblack-tweeter

A Python 3.8 asyncio twitter client.

This Twitter client is designed to support arbitrary HTTP clients. There is
currently support for
[bareClient](https://rob-blackbourn.github.io/bareClient/api/bareclient/)
and [aiohttp](https://docs.aiohttp.org/en/stable/index.html).

## Status

This is work in progress, but functional.

There is currently limited support for streaming, statuses and accounts. Only the 1.1 api is currently implemented.

## Installation

Install with `pip`, specifying the HTTP backend you wish to use.

For bareClient:

```bash
pip install jetblack-tweeter[bareclient]
```

For aiohttp:

```bash
pip install jetblack-tweeter[aiohttp]
```

## Usage

Here is an example:

```python
import asyncio
import os

from jetblack_tweeter import Tweeter
from jetblack_tweeter.clients.bareclient import BareTweeterSession

# Get the secrets from environment variables.
APP_KEY = os.environ["APP_KEY"]
APP_KEY_SECRET = os.environ["APP_KEY_SECRET"]
ACCESS_TOKEN = os.environ["ACCESS_TOKEN"]
ACCESS_TOKEN_SECRET = os.environ["ACCESS_TOKEN_SECRET"]


async def main():
    tweeter = Tweeter(
        BareTweeterSession(),
        APP_KEY,
        APP_KEY_SECRET,
        # Optional for user authentication.
        access_token=ACCESS_TOKEN,
        access_token_secret=ACCESS_TOKEN_SECRET
    )

    user_timeline = await tweeter.statuses.user_timeline()
    print(user_timeline)

    account_settings = await tweeter.account.settings()
    print(account_settings)

    account_verify_credentials = await tweeter.account.verify_credentials()
    print(account_verify_credentials)

    # Watch the random sampling of tweets chosen by twitter
    async for tweet in tweeter.stream.sample():
        print(tweet)

    # Stream tweets which have the tag "#python" from New York
    # and San Francisco.
    async for tweet in tweeter.stream.filter(
            track=['#python'],
            locations=[
                ((-122.75, 36.8), (-121.75, 37.8)),
                ((-74, 40), (-73, 41))
            ]
    ):
        print(tweet)

    result = await tweeter.statuses.update('Hello from jetblack-tweeter')
    print(result)

if __name__ == '__main__':
    asyncio.run(main())
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rob-blackbourn/jetblack-tweeter",
    "name": "jetblack-tweeter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Rob Blackbourn",
    "author_email": "rob.blackbourn@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f1/b5/bdd303e01289ec0e945cbc250f5a2577af2dcb88cb09bcfb89974c0cc58d/jetblack-tweeter-0.10.0.tar.gz",
    "platform": null,
    "description": "# jetblack-tweeter\n\nA Python 3.8 asyncio twitter client.\n\nThis Twitter client is designed to support arbitrary HTTP clients. There is\ncurrently support for\n[bareClient](https://rob-blackbourn.github.io/bareClient/api/bareclient/)\nand [aiohttp](https://docs.aiohttp.org/en/stable/index.html).\n\n## Status\n\nThis is work in progress, but functional.\n\nThere is currently limited support for streaming, statuses and accounts. Only the 1.1 api is currently implemented.\n\n## Installation\n\nInstall with `pip`, specifying the HTTP backend you wish to use.\n\nFor bareClient:\n\n```bash\npip install jetblack-tweeter[bareclient]\n```\n\nFor aiohttp:\n\n```bash\npip install jetblack-tweeter[aiohttp]\n```\n\n## Usage\n\nHere is an example:\n\n```python\nimport asyncio\nimport os\n\nfrom jetblack_tweeter import Tweeter\nfrom jetblack_tweeter.clients.bareclient import BareTweeterSession\n\n# Get the secrets from environment variables.\nAPP_KEY = os.environ[\"APP_KEY\"]\nAPP_KEY_SECRET = os.environ[\"APP_KEY_SECRET\"]\nACCESS_TOKEN = os.environ[\"ACCESS_TOKEN\"]\nACCESS_TOKEN_SECRET = os.environ[\"ACCESS_TOKEN_SECRET\"]\n\n\nasync def main():\n    tweeter = Tweeter(\n        BareTweeterSession(),\n        APP_KEY,\n        APP_KEY_SECRET,\n        # Optional for user authentication.\n        access_token=ACCESS_TOKEN,\n        access_token_secret=ACCESS_TOKEN_SECRET\n    )\n\n    user_timeline = await tweeter.statuses.user_timeline()\n    print(user_timeline)\n\n    account_settings = await tweeter.account.settings()\n    print(account_settings)\n\n    account_verify_credentials = await tweeter.account.verify_credentials()\n    print(account_verify_credentials)\n\n    # Watch the random sampling of tweets chosen by twitter\n    async for tweet in tweeter.stream.sample():\n        print(tweet)\n\n    # Stream tweets which have the tag \"#python\" from New York\n    # and San Francisco.\n    async for tweet in tweeter.stream.filter(\n            track=['#python'],\n            locations=[\n                ((-122.75, 36.8), (-121.75, 37.8)),\n                ((-74, 40), (-73, 41))\n            ]\n    ):\n        print(tweet)\n\n    result = await tweeter.statuses.update('Hello from jetblack-tweeter')\n    print(result)\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "An asyncio twitter client",
    "version": "0.10.0",
    "project_urls": {
        "Homepage": "https://github.com/rob-blackbourn/jetblack-tweeter",
        "Repository": "https://github.com/rob-blackbourn/jetblack-tweeter"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e2f2d9ae8ffe40465ddf93f04f9cfb2ce267834f4fdb1c097f2053d171e70f77",
                "md5": "9449a6cd0e68cfcdf55403c785950e8d",
                "sha256": "6c179a4609980c6465e891395dc5a3fbb62bdf2deec7fec5c35619ec8b448952"
            },
            "downloads": -1,
            "filename": "jetblack_tweeter-0.10.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9449a6cd0e68cfcdf55403c785950e8d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 26879,
            "upload_time": "2023-05-28T10:18:35",
            "upload_time_iso_8601": "2023-05-28T10:18:35.019075Z",
            "url": "https://files.pythonhosted.org/packages/e2/f2/d9ae8ffe40465ddf93f04f9cfb2ce267834f4fdb1c097f2053d171e70f77/jetblack_tweeter-0.10.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f1b5bdd303e01289ec0e945cbc250f5a2577af2dcb88cb09bcfb89974c0cc58d",
                "md5": "902d4d31f402f14edb729d53ff2a660c",
                "sha256": "177fac1acb87484d5a43368c3dc5de4992de2addbdaad3e88e7e1fbc3c72b0fa"
            },
            "downloads": -1,
            "filename": "jetblack-tweeter-0.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "902d4d31f402f14edb729d53ff2a660c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 20693,
            "upload_time": "2023-05-28T10:18:32",
            "upload_time_iso_8601": "2023-05-28T10:18:32.667548Z",
            "url": "https://files.pythonhosted.org/packages/f1/b5/bdd303e01289ec0e945cbc250f5a2577af2dcb88cb09bcfb89974c0cc58d/jetblack-tweeter-0.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-28 10:18:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rob-blackbourn",
    "github_project": "jetblack-tweeter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "jetblack-tweeter"
}
        
Elapsed time: 1.40499s