nusuGraph


NamenusuGraph JSON
Version 3.3 PyPI version JSON
download
home_pagehttps://github.com/Nusab19/nusuGraph
SummaryAn asynchronous and simplified Telegraph API Wrapper in Python
upload_time2024-08-24 06:47:45
maintainerNone
docs_urlNone
authorNusab Taha
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # nusuGraph

An asynchronous and simplified wrapper for the Telegraph API.

## Installation

```bash
pip install -U nusugraph
```

## Usage

```python
import asyncio
from nusugraph import Telegraph


async def main():
    graph = Telegraph(
        token=None,  # if no token was passed, then an anonymous account will be created
        tokenList=None,  # list of tokens to be used in a cycle
        timeout=10,  # timeout for httpx.AsyncClient
    )

    # Create a Page
    text = "Hello, world!"

    # Account will be created if no token was passed
    response = await graph.createPage(
        author="Nusab Taha", htmlContent="<b>Hello</b>", title="Just Saying Hello"
    )
    url = response["url"]
    print(url)  # https://telegra.ph/Just-Saying-Hello-12-28-4

    # Upload Media from local file
    imagePath = "assets/sample.jpg"
    url = await graph.uploadMediaFromFile(imagePath)
    print(url)  # https://telegra.ph/file/daf9c776a1c25264321cd.jpg

    # Upload Media from it's bytes content
    with open(imagePath, "rb") as file:
        imageBytes = file.read()

    url = await graph.uploadMediaFromBytes(content=imageBytes, fileType="image/jpeg")
    print(url)  # https://telegra.ph/file/3406d7261c8c62869ab91.jpg


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

## WHY?

I needed a simple and asynchronous wrapper for the Telegraph API, with the ability to use multiple tokens in a cycle. That's the reason.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Nusab19/nusuGraph",
    "name": "nusuGraph",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Nusab Taha",
    "author_email": "nusabtaha33@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0d/0b/010c63842632fad7c5ace473b8f3200dfe536dd27ea002fbe2cd6ed9a4c6/nusugraph-3.3.tar.gz",
    "platform": null,
    "description": "# nusuGraph\r\n\r\nAn asynchronous and simplified wrapper for the Telegraph API.\r\n\r\n## Installation\r\n\r\n```bash\r\npip install -U nusugraph\r\n```\r\n\r\n## Usage\r\n\r\n```python\r\nimport asyncio\r\nfrom nusugraph import Telegraph\r\n\r\n\r\nasync def main():\r\n    graph = Telegraph(\r\n        token=None,  # if no token was passed, then an anonymous account will be created\r\n        tokenList=None,  # list of tokens to be used in a cycle\r\n        timeout=10,  # timeout for httpx.AsyncClient\r\n    )\r\n\r\n    # Create a Page\r\n    text = \"Hello, world!\"\r\n\r\n    # Account will be created if no token was passed\r\n    response = await graph.createPage(\r\n        author=\"Nusab Taha\", htmlContent=\"<b>Hello</b>\", title=\"Just Saying Hello\"\r\n    )\r\n    url = response[\"url\"]\r\n    print(url)  # https://telegra.ph/Just-Saying-Hello-12-28-4\r\n\r\n    # Upload Media from local file\r\n    imagePath = \"assets/sample.jpg\"\r\n    url = await graph.uploadMediaFromFile(imagePath)\r\n    print(url)  # https://telegra.ph/file/daf9c776a1c25264321cd.jpg\r\n\r\n    # Upload Media from it's bytes content\r\n    with open(imagePath, \"rb\") as file:\r\n        imageBytes = file.read()\r\n\r\n    url = await graph.uploadMediaFromBytes(content=imageBytes, fileType=\"image/jpeg\")\r\n    print(url)  # https://telegra.ph/file/3406d7261c8c62869ab91.jpg\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    asyncio.run(main())\r\n```\r\n\r\n## WHY?\r\n\r\nI needed a simple and asynchronous wrapper for the Telegraph API, with the ability to use multiple tokens in a cycle. That's the reason.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An asynchronous and simplified Telegraph API Wrapper in Python",
    "version": "3.3",
    "project_urls": {
        "Download": "https://github.com/Nusab19/nusuGraph/archive/v3.3.zip",
        "Homepage": "https://github.com/Nusab19/nusuGraph"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0d0b010c63842632fad7c5ace473b8f3200dfe536dd27ea002fbe2cd6ed9a4c6",
                "md5": "473e175702d06a09c1473b2fde0e640a",
                "sha256": "f98f4089e0186dc0a50ff8e571585969598c75fe4dadc6c2cd78f0d130386dc1"
            },
            "downloads": -1,
            "filename": "nusugraph-3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "473e175702d06a09c1473b2fde0e640a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11031,
            "upload_time": "2024-08-24T06:47:45",
            "upload_time_iso_8601": "2024-08-24T06:47:45.778819Z",
            "url": "https://files.pythonhosted.org/packages/0d/0b/010c63842632fad7c5ace473b8f3200dfe536dd27ea002fbe2cd6ed9a4c6/nusugraph-3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-24 06:47:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Nusab19",
    "github_project": "nusuGraph",
    "github_not_found": true,
    "lcname": "nusugraph"
}
        
Elapsed time: 1.18251s