python-tweet


Namepython-tweet JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryA Python library for retrieving tweets from X (f.k.a. Twitter)
upload_time2024-06-21 21:25:17
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseThe MIT License (MIT) Copyright (c) 2024 to present Vladyslav Novotnyi and individual contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords twitter x tweet api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Tweet

![PyPI - Version](https://img.shields.io/pypi/v/python-tweet?labelColor=%232e343b&label=pypi%20package)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/python-tweet?labelColor=%232e343b)
![PyPI - License](https://img.shields.io/pypi/l/python-tweet?labelColor=%232e343b)
[![Tests](https://github.com/fabelx/py-tweet/actions/workflows/tests.yml/badge.svg)](https://github.com/fabelx/py-tweet/actions/workflows/tests.yml)


## About
`pytweet` is a simple Python library with one goal: to retrieve tweet information from **X** for free.

_Inspired by [React-tweet](https://github.com/vercel/react-tweet) project._

### Key Feature
- doesn't require an [X](https://x.com/) (formerly known as **Twitter**) API token
___

## Installation
```bash
pip install python-tweet
```
From source:
```bash
make install
```
or
```bash
pip install .
```
___

## Usage
> ### It may cause conflicts with [PyTweet](https://pypi.org/project/PyTweet/) if you are using it in your project.

#### Async way:
```python
import asyncio
import json

from pytweet import get_tweet


async def main():
    tweet_id = "1803774806980022720"
    data = await get_tweet(tweet_id)
    with open(f"{tweet_id}.json", "w") as f:
        json.dump(data, f, indent=2)


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

```

#### Sync way:
```python
import json

from pytweet.sync import get_tweet


def main():
    tweet_id = "1803774806980022720"
    data = get_tweet(tweet_id)
    with open(f"{tweet_id}.json", "w") as f:
        json.dump(data, f, indent=2)


if __name__ == '__main__':
    main()

```

#### Pydantic mode:
If you prefer working with object-oriented concepts, you may prefer receiving a class.
However, be aware that the returned JSON from [syndication](https://cdn.syndication.twimg.com/tweet-result) is undocumented, so errors or data loss may occur during conversion to a class.

Requires the installation of [pydantic](https://docs.pydantic.dev/latest/).
```bash
pip install python-tweet[pydantic]
```
```python
import asyncio
import json

from pytweet import get_tweet


async def main():
    tweet_id = "1803774806980022720"
    tweet = await get_tweet(tweet_id)
    with open(f"{tweet_id}.json", "w") as f:
        json.dump(tweet.model_dump(mode="json"), f, indent=2)


if __name__ == '__main__':
    asyncio.run(main())
```
If you are using Pydantic but want to receive a `dict`, pass the `as_dict` argument to the `get_tweet` function.
___

### To-do
- [x] Return a Tweet class instead a raw dict.
___

## License
`python-tweet` is released under the MIT License.
See the [LICENSE](https://github.com/fabelx/pycrossword/blob/main/LICENSE) file for license information.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "python-tweet",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": "Vladyslav Novotnyi <psejjkuczo@proxiedmail.com>",
    "keywords": "twitter, x, tweet, api",
    "author": null,
    "author_email": "Vladyslav Novotnyi <psejjkuczo@proxiedmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ef/76/c8c2893e648d8789206af876b3bd2e4edd34cb5377c368969ccbf88fcaa5/python_tweet-0.2.0.tar.gz",
    "platform": null,
    "description": "# Python Tweet\n\n![PyPI - Version](https://img.shields.io/pypi/v/python-tweet?labelColor=%232e343b&label=pypi%20package)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/python-tweet?labelColor=%232e343b)\n![PyPI - License](https://img.shields.io/pypi/l/python-tweet?labelColor=%232e343b)\n[![Tests](https://github.com/fabelx/py-tweet/actions/workflows/tests.yml/badge.svg)](https://github.com/fabelx/py-tweet/actions/workflows/tests.yml)\n\n\n## About\n`pytweet` is a simple Python library with one goal: to retrieve tweet information from **X** for free.\n\n_Inspired by [React-tweet](https://github.com/vercel/react-tweet) project._\n\n### Key Feature\n- doesn't require an [X](https://x.com/) (formerly known as **Twitter**) API token\n___\n\n## Installation\n```bash\npip install python-tweet\n```\nFrom source:\n```bash\nmake install\n```\nor\n```bash\npip install .\n```\n___\n\n## Usage\n> ### It may cause conflicts with [PyTweet](https://pypi.org/project/PyTweet/) if you are using it in your project.\n\n#### Async way:\n```python\nimport asyncio\nimport json\n\nfrom pytweet import get_tweet\n\n\nasync def main():\n    tweet_id = \"1803774806980022720\"\n    data = await get_tweet(tweet_id)\n    with open(f\"{tweet_id}.json\", \"w\") as f:\n        json.dump(data, f, indent=2)\n\n\nif __name__ == '__main__':\n    asyncio.run(main())\n\n```\n\n#### Sync way:\n```python\nimport json\n\nfrom pytweet.sync import get_tweet\n\n\ndef main():\n    tweet_id = \"1803774806980022720\"\n    data = get_tweet(tweet_id)\n    with open(f\"{tweet_id}.json\", \"w\") as f:\n        json.dump(data, f, indent=2)\n\n\nif __name__ == '__main__':\n    main()\n\n```\n\n#### Pydantic mode:\nIf you prefer working with object-oriented concepts, you may prefer receiving a class.\nHowever, be aware that the returned JSON from [syndication](https://cdn.syndication.twimg.com/tweet-result) is undocumented, so errors or data loss may occur during conversion to a class.\n\nRequires the installation of [pydantic](https://docs.pydantic.dev/latest/).\n```bash\npip install python-tweet[pydantic]\n```\n```python\nimport asyncio\nimport json\n\nfrom pytweet import get_tweet\n\n\nasync def main():\n    tweet_id = \"1803774806980022720\"\n    tweet = await get_tweet(tweet_id)\n    with open(f\"{tweet_id}.json\", \"w\") as f:\n        json.dump(tweet.model_dump(mode=\"json\"), f, indent=2)\n\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\nIf you are using Pydantic but want to receive a `dict`, pass the `as_dict` argument to the `get_tweet` function.\n___\n\n### To-do\n- [x] Return a Tweet class instead a raw dict.\n___\n\n## License\n`python-tweet` is released under the MIT License.\nSee the [LICENSE](https://github.com/fabelx/pycrossword/blob/main/LICENSE) file for license information.\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2024 to present Vladyslav Novotnyi and individual contributors.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A Python library for retrieving tweets from X (f.k.a. Twitter)",
    "version": "0.2.0",
    "project_urls": {
        "Bug Reports": "https://github.com/fabelx/py-tweet/issues",
        "Homepage": "https://github.com/fabelx/py-tweet",
        "Source": "https://github.com/fabelx/py-tweet"
    },
    "split_keywords": [
        "twitter",
        " x",
        " tweet",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "679ebf3b2f2fb7e332acf449d5dec3ae40549a7915ade1c04b90d5808f18b3ab",
                "md5": "edb1221d01db087fe1fdaa575d27ed2d",
                "sha256": "b1374e230183fcfbfd6de6c48c88c3540a72503b717b38a36798011b0ef2d730"
            },
            "downloads": -1,
            "filename": "python_tweet-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "edb1221d01db087fe1fdaa575d27ed2d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 8954,
            "upload_time": "2024-06-21T21:25:16",
            "upload_time_iso_8601": "2024-06-21T21:25:16.205869Z",
            "url": "https://files.pythonhosted.org/packages/67/9e/bf3b2f2fb7e332acf449d5dec3ae40549a7915ade1c04b90d5808f18b3ab/python_tweet-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef76c8c2893e648d8789206af876b3bd2e4edd34cb5377c368969ccbf88fcaa5",
                "md5": "4f82a05c2ed39a77973c20fef91ac91b",
                "sha256": "9cc9499b298240055edc26715976437222e97ced3f5ae3b7ea535545ec3ff3a4"
            },
            "downloads": -1,
            "filename": "python_tweet-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4f82a05c2ed39a77973c20fef91ac91b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 7125,
            "upload_time": "2024-06-21T21:25:17",
            "upload_time_iso_8601": "2024-06-21T21:25:17.860913Z",
            "url": "https://files.pythonhosted.org/packages/ef/76/c8c2893e648d8789206af876b3bd2e4edd34cb5377c368969ccbf88fcaa5/python_tweet-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-21 21:25:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fabelx",
    "github_project": "py-tweet",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "python-tweet"
}
        
Elapsed time: 0.31423s