Metadata-Version: 2.1
Name: sendgrid-async
Version: 2.0.1
Summary: SendGrid using a client based on httpx.
Home-page: https://github.com/EM51641/async-sendgrid/
License: MIT
Keywords: sendgrid,async,httpx
Author: Elyes Mahjoubo
Author-email: elyesmahjoubi@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: certifi (>=2024.6.2,<2025.0.0)
Requires-Dist: httpx (>=0.24.1,<0.25.0)
Requires-Dist: sendgrid (>=6.7.0,<7.0.0)
Requires-Dist: toml (>=0.10.2,<0.11.0)
Project-URL: Repository, https://github.com/EM51641/async-sendgrid/
Description-Content-Type: text/markdown

| | |
| --- | --- |
| 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")
```
