Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/async/usage_async.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import asyncio
import os

import resend

if not os.environ["RESEND_API_KEY"]:
raise EnvironmentError("RESEND_API_KEY is missing")


async def main() -> None:
usage: resend.Usage.GetResponse = await resend.Usage.get_async()

print(f"Daily emails used: {usage['emails']['daily']['used']}")
print(f"Monthly emails used: {usage['emails']['monthly']['used']}")
print(f"Contacts used: {usage['contacts']['used']}")
print(f"Rate limit: {usage['rate_limit']['limit']} per {usage['rate_limit']['duration']}")


if __name__ == "__main__":
asyncio.run(main())
13 changes: 13 additions & 0 deletions examples/usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os

import resend

if not os.environ["RESEND_API_KEY"]:
raise EnvironmentError("RESEND_API_KEY is missing")

usage: resend.Usage.GetResponse = resend.Usage.get()

print(f"Daily emails used: {usage['emails']['daily']['used']}")
print(f"Monthly emails used: {usage['emails']['monthly']['used']}")
print(f"Contacts used: {usage['contacts']['used']}")
print(f"Rate limit: {usage['rate_limit']['limit']} per {usage['rate_limit']['duration']}")
15 changes: 15 additions & 0 deletions resend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
from .templates._templates import Templates
from .topics._topic import Topic
from .topics._topics import Topics
from .usage._usage import (AiCreditsUsage, AutomationRunsUsage,
BroadcastsUsage, ContactsUsage, DomainsUsage,
EmailsDailyUsage, EmailsMonthlyUsage, EmailsUsage,
RateLimitUsage, SegmentsUsage, Usage)
from .version import __version__, get_version
from .webhooks._webhook import (VerifyWebhookOptions, Webhook, WebhookEvent,
WebhookHeaders, WebhookStatus)
Expand Down Expand Up @@ -130,6 +134,7 @@
"OAuthGrants",
"Suppressions",
"SuppressionsBatch",
"Usage",
# Types
"Audience",
"Automation",
Expand Down Expand Up @@ -224,6 +229,16 @@
"EmailsReceiving",
"EmailAttachments",
"ContactsTopics",
"EmailsUsage",
"EmailsDailyUsage",
"EmailsMonthlyUsage",
"ContactsUsage",
"SegmentsUsage",
"BroadcastsUsage",
"AiCreditsUsage",
"AutomationRunsUsage",
"DomainsUsage",
"RateLimitUsage",
# HTTP Clients
"HTTPClient",
# Default HTTP Client
Expand Down
19 changes: 19 additions & 0 deletions resend/usage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from resend.usage._usage import (AiCreditsUsage, AutomationRunsUsage,
BroadcastsUsage, ContactsUsage, DomainsUsage,
EmailsDailyUsage, EmailsMonthlyUsage,
EmailsUsage, RateLimitUsage, SegmentsUsage,
Usage)

__all__ = [
"Usage",
"EmailsUsage",
"EmailsDailyUsage",
"EmailsMonthlyUsage",
"ContactsUsage",
"SegmentsUsage",
"BroadcastsUsage",
"AiCreditsUsage",
"AutomationRunsUsage",
"DomainsUsage",
"RateLimitUsage",
]
Loading
Loading