sendgrid-async


Namesendgrid-async JSON
Version 2.0.1 PyPI version JSON
download
home_pagehttps://github.com/EM51641/async-sendgrid/
SummarySendGrid using a client based on httpx.
upload_time2024-06-04 08:45:53
maintainerNone
docs_urlNone
authorElyes Mahjoubo
requires_python<4.0,>=3.10
licenseMIT
keywords sendgrid async httpx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            | | |
| --- | --- |
| Python| ![Python](https://img.shields.io/pypi/pyversions/sendgrid-async) |
| Package | [![PyPI Latest Release](https://img.shields.io/pypi/v/sendgrid-async.svg)](https://pypi.org/project/sendgrid-async/) [![PyPI Downloads](https://img.shields.io/pypi/dm/sendgrid-async.svg?label=PyPI%20downloads)](https://pypi.org/project/sendgrid-async/) |
| Meta | [![License - MIT](https://img.shields.io/pypi/l/async_sendgrid.svg)](https://github.com/sensodevices/async_sendgrid/blob/main/LICENSE)|

# Async-Sendgrid

Sendgrid-Async is a simple asynchronous client built upon the httpx library.

# Installation

You can install Sendgrid-Async using pip with the following command:

```shell
pip install sendgrid-async
```

# Usage

Here is a brief script demonstrating how to send an email using Async-Sendgrid:

First, import the `SendgridAPI` from the `sendgrid-async` package. Then, create a SendgridAPI object using your API key.

```python
from async_sendgrid import SendgridAPI
import os

API_KEY = os.environ.get('SECRET_API_KEY')
sendgrid = SendgridAPI(API_KEY)
```

Next, we can create an email using the original `sendgrid` library as follows:

```python
from sendgrid.helpers.mail import Content, Email, Mail, To

from_email = Email("test@example.com")
to_email = To("test@example.com")
subject = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
content = Content("text/plain", "Sed varius ligula ac urna vehicula ultrices. Nunc ut dolor sem.")

mail = Mail(
    from_email=from_email,
    to_email=to_email,
    subject=subject,
    content=content
    )
```

An email can be sent to sendgrid servers with the  `send` API of the `SendgridAPI` instance:

```python
async with sendgrid as client:
    response = await client.send(data)
```

For testing purposes, you can modify the API endpoint as follows:

```python
sendgrid = SendgridAPI(api_key="SECRET_API_KEY", endpoint="https://localhost:3000/v3/mail/send")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/EM51641/async-sendgrid/",
    "name": "sendgrid-async",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "sendgrid, async, httpx",
    "author": "Elyes Mahjoubo",
    "author_email": "elyesmahjoubi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c9/d3/1f15af35a72f815555732132a8749b05d2be42847a0f2185839da5c1b3ea/sendgrid_async-2.0.1.tar.gz",
    "platform": null,
    "description": "| | |\n| --- | --- |\n| Python| ![Python](https://img.shields.io/pypi/pyversions/sendgrid-async) |\n| Package | [![PyPI Latest Release](https://img.shields.io/pypi/v/sendgrid-async.svg)](https://pypi.org/project/sendgrid-async/) [![PyPI Downloads](https://img.shields.io/pypi/dm/sendgrid-async.svg?label=PyPI%20downloads)](https://pypi.org/project/sendgrid-async/) |\n| Meta | [![License - MIT](https://img.shields.io/pypi/l/async_sendgrid.svg)](https://github.com/sensodevices/async_sendgrid/blob/main/LICENSE)|\n\n# Async-Sendgrid\n\nSendgrid-Async is a simple asynchronous client built upon the httpx library.\n\n# Installation\n\nYou can install Sendgrid-Async using pip with the following command:\n\n```shell\npip install sendgrid-async\n```\n\n# Usage\n\nHere is a brief script demonstrating how to send an email using Async-Sendgrid:\n\nFirst, import the `SendgridAPI` from the `sendgrid-async` package. Then, create a SendgridAPI object using your API key.\n\n```python\nfrom async_sendgrid import SendgridAPI\nimport os\n\nAPI_KEY = os.environ.get('SECRET_API_KEY')\nsendgrid = SendgridAPI(API_KEY)\n```\n\nNext, we can create an email using the original `sendgrid` library as follows:\n\n```python\nfrom sendgrid.helpers.mail import Content, Email, Mail, To\n\nfrom_email = Email(\"test@example.com\")\nto_email = To(\"test@example.com\")\nsubject = \"Lorem ipsum dolor sit amet, consectetur adipiscing elit\"\ncontent = Content(\"text/plain\", \"Sed varius ligula ac urna vehicula ultrices. Nunc ut dolor sem.\")\n\nmail = Mail(\n    from_email=from_email,\n    to_email=to_email,\n    subject=subject,\n    content=content\n    )\n```\n\nAn email can be sent to sendgrid servers with the  `send` API of the `SendgridAPI` instance:\n\n```python\nasync with sendgrid as client:\n    response = await client.send(data)\n```\n\nFor testing purposes, you can modify the API endpoint as follows:\n\n```python\nsendgrid = SendgridAPI(api_key=\"SECRET_API_KEY\", endpoint=\"https://localhost:3000/v3/mail/send\")\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "SendGrid using a client based on httpx.",
    "version": "2.0.1",
    "project_urls": {
        "Homepage": "https://github.com/EM51641/async-sendgrid/",
        "Repository": "https://github.com/EM51641/async-sendgrid/"
    },
    "split_keywords": [
        "sendgrid",
        " async",
        " httpx"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5246e8fa6b84b088383ee0aa80a1078ae38d0d8376e78213d809d6260ae76e37",
                "md5": "e721f3f0f538dc3259c25c452477addc",
                "sha256": "58f11063b264b61f6a154db40e0d2468bb28b8f2f6653b45c5d422a51d0bca0b"
            },
            "downloads": -1,
            "filename": "sendgrid_async-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e721f3f0f538dc3259c25c452477addc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 4664,
            "upload_time": "2024-06-04T08:45:52",
            "upload_time_iso_8601": "2024-06-04T08:45:52.416424Z",
            "url": "https://files.pythonhosted.org/packages/52/46/e8fa6b84b088383ee0aa80a1078ae38d0d8376e78213d809d6260ae76e37/sendgrid_async-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c9d31f15af35a72f815555732132a8749b05d2be42847a0f2185839da5c1b3ea",
                "md5": "070f340ac07bbc9828a7212dc32d3ca8",
                "sha256": "8a432eeb9883e41f63755473c87bcb0e3ae57bcbeeab1acfe058203bcf9d3796"
            },
            "downloads": -1,
            "filename": "sendgrid_async-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "070f340ac07bbc9828a7212dc32d3ca8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 3837,
            "upload_time": "2024-06-04T08:45:53",
            "upload_time_iso_8601": "2024-06-04T08:45:53.328649Z",
            "url": "https://files.pythonhosted.org/packages/c9/d3/1f15af35a72f815555732132a8749b05d2be42847a0f2185839da5c1b3ea/sendgrid_async-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-04 08:45:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "EM51641",
    "github_project": "async-sendgrid",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "sendgrid-async"
}
        
Elapsed time: 0.26138s