{"id":13496028,"url":"https://github.com/sendgrid/sendgrid-python","last_synced_at":"2025-05-06T01:14:59.042Z","repository":{"id":2567129,"uuid":"3546794","full_name":"sendgrid/sendgrid-python","owner":"sendgrid","description":"The Official Twilio SendGrid Python API Library","archived":false,"fork":false,"pushed_at":"2025-05-05T10:35:49.000Z","size":2734,"stargazers_count":1588,"open_issues_count":56,"forks_count":723,"subscribers_count":217,"default_branch":"main","last_synced_at":"2025-05-06T01:14:51.689Z","etag":null,"topics":["email","python","sendgrid","transactional-emails"],"latest_commit_sha":null,"homepage":"https://sendgrid.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sendgrid.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-02-25T19:10:40.000Z","updated_at":"2025-05-05T10:35:43.000Z","dependencies_parsed_at":"2023-07-05T17:00:08.129Z","dependency_job_id":"77d6a9bb-0ddb-4e39-a440-59bf6ec1af08","html_url":"https://github.com/sendgrid/sendgrid-python","commit_stats":{"total_commits":1128,"total_committers":220,"mean_commits":5.127272727272727,"dds":0.7526595744680851,"last_synced_commit":"9515dce6c8229c9cf7272701d0c2664c05727f16"},"previous_names":[],"tags_count":124,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendgrid%2Fsendgrid-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendgrid%2Fsendgrid-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendgrid%2Fsendgrid-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendgrid%2Fsendgrid-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sendgrid","download_url":"https://codeload.github.com/sendgrid/sendgrid-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252601893,"owners_count":21774665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","python","sendgrid","transactional-emails"],"created_at":"2024-07-31T19:01:40.959Z","updated_at":"2025-05-06T01:14:58.964Z","avatar_url":"https://github.com/sendgrid.png","language":"Python","readme":"![SendGrid Logo](twilio_sendgrid_logo.png)\n\n[![BuildStatus](https://github.com/sendgrid/sendgrid-python/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/sendgrid/sendgrid-python/actions/workflows/test-and-deploy.yml)\n[![Docker Badge](https://img.shields.io/docker/automated/sendgrid/sendgrid-python.svg)](https://hub.docker.com/r/sendgrid/sendgrid-python/)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social\u0026label=Follow)](https://twitter.com/sendgrid)\n[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-python.svg)](https://github.com/sendgrid/sendgrid-python/graphs/contributors)\n[![Open Source Helpers](https://www.codetriage.com/sendgrid/sendgrid-python/badges/users.svg)](https://www.codetriage.com/sendgrid/sendgrid-python)\n\n**This library allows you to quickly and easily use the SendGrid Web API v3 via Python.**\n\nVersion 3.X.X+ of this library provides full support for all SendGrid [Web API v3](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) endpoints, including the new [v3 /mail/send](https://sendgrid.com/blog/introducing-v3mailsend-sendgrids-new-mail-endpoint).\n\nThis library represents the beginning of a new path for SendGrid. We want this library to be community driven and SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/sendgrid/sendgrid-python/issues) and [pull requests](CONTRIBUTING.md) or simply upvote or comment on existing issues or pull requests.\n\n**If you need help using SendGrid, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com).**\n\nPlease browse the rest of this README for further detail.\n\n# Table of Contents\n\n* [Installation](#installation)\n* [Quick Start](#quick-start)\n* [Processing Inbound Email](#inbound)\n* [Usage](#usage)\n* [Use Cases](#use-cases)\n* [Announcements](#announcements)\n* [How to Contribute](#contribute)\n* [Troubleshooting](#troubleshooting)\n* [About](#about)\n* [Support](#support)\n* [License](#license)\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n\n# Installation\n\n## Prerequisites\n\n- Python version 2.7+\n- The SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-python)\n\n## Setup Environment Variables\n### Mac\n\nUpdate the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys) (more info [here](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html)), for example:\n\n```bash\necho \"export SENDGRID_API_KEY='YOUR_API_KEY'\" \u003e sendgrid.env\necho \"sendgrid.env\" \u003e\u003e .gitignore\nsource ./sendgrid.env\n```\nSendGrid also supports local environment file `.env`. Copy or rename `.env_sample` into `.env` and update [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys) with your key.\n\n### Windows\nTemporarily set the environment variable(accessible only during the current cli session):\n```bash\nset SENDGRID_API_KEY=YOUR_API_KEY\n```\nPermanently set the environment variable(accessible in all subsequent cli sessions):\n```bash\nsetx SENDGRID_API_KEY \"YOUR_API_KEY\"\n```\n\n## Install Package\n```bash\npip install sendgrid\n```\n\n## Dependencies\n\n- [Python-HTTP-Client](https://github.com/sendgrid/python-http-client)\n- [ECDSA-Python](https://github.com/starkbank/ecdsa-python)\n\n\n\u003ca name=\"quick-start\"\u003e\u003c/a\u003e\n# Quick Start\n\n## Hello Email\n\nThe following is the minimum needed code to send an email with the [/mail/send Helper](sendgrid/helpers/mail) ([here](examples/helpers/mail_example.py#L9) is a full example):\n\n### With Mail Helper Class\n\n```python\nimport sendgrid\nimport os\nfrom sendgrid.helpers.mail import *\n\nsg = sendgrid.SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY'))\nfrom_email = Email(\"test@example.com\")\nto_email = To(\"test@example.com\")\nsubject = \"Sending with SendGrid is Fun\"\ncontent = Content(\"text/plain\", \"and easy to do anywhere, even with Python\")\nmail = Mail(from_email, to_email, subject, content)\nresponse = sg.client.mail.send.post(request_body=mail.get())\nprint(response.status_code)\nprint(response.body)\nprint(response.headers)\n```\n\nThe `Mail` constructor creates a [personalization object](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/personalizations.html) for you. [Here](examples/helpers/mail_example.py#L28) is an example of how to add it.\n\n### Without Mail Helper Class\n\nThe following is the minimum needed code to send an email without the /mail/send Helper ([here](examples/mail/mail.py#L27) is a full example):\n\n```python\nimport sendgrid\nimport os\n\nsg = sendgrid.SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY'))\ndata = {\n  \"personalizations\": [\n    {\n      \"to\": [\n        {\n          \"email\": \"test@example.com\"\n        }\n      ],\n      \"subject\": \"Sending with SendGrid is Fun\"\n    }\n  ],\n  \"from\": {\n    \"email\": \"test@example.com\"\n  },\n  \"content\": [\n    {\n      \"type\": \"text/plain\",\n      \"value\": \"and easy to do anywhere, even with Python\"\n    }\n  ]\n}\nresponse = sg.client.mail.send.post(request_body=data)\nprint(response.status_code)\nprint(response.body)\nprint(response.headers)\n```\n\n## General v3 Web API Usage (With [Fluent Interface](https://sendgrid.com/blog/using-python-to-implement-a-fluent-interface-to-any-rest-api/))\n\n```python\nimport sendgrid\nimport os\n\nsg = sendgrid.SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY'))\nresponse = sg.client.suppression.bounces.get()\nprint(response.status_code)\nprint(response.body)\nprint(response.headers)\n```\n\n## General v3 Web API Usage (Without Fluent Interface)\n\n```python\nimport sendgrid\nimport os\n\nsg = sendgrid.SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY'))\nresponse = sg.client._(\"suppression/bounces\").get()\nprint(response.status_code)\nprint(response.body)\nprint(response.headers)\n```\n\n\u003ca name=\"inbound\"\u003e\u003c/a\u003e\n# Processing Inbound Email\n\nPlease see [our helper](sendgrid/helpers/inbound) for utilizing our Inbound Parse webhook.\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n# Usage\n\n- [SendGrid Documentation](https://sendgrid.com/docs/API_Reference/index.html)\n- [Library Usage Documentation](USAGE.md)\n- [Example Code](examples)\n- [How-to: Migration from v2 to v3](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html)\n- [v3 Web API Mail Send Helper](sendgrid/helpers/mail) - build a request object payload for a v3 /mail/send API call.\n- [Processing Inbound Email](sendgrid/helpers/inbound)\n\n\u003ca name=\"use-cases\"\u003e\u003c/a\u003e\n# Use Cases\n\n[Examples of common API use cases](use_cases/README.md), such as how to send an email with a transactional template.\n\n\u003ca name=\"announcements\"\u003e\u003c/a\u003e\n# Announcements\n\nAll updates to this library are documented in our [CHANGELOG](CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-python/releases).\n\n\u003ca name=\"contribute\"\u003e\u003c/a\u003e\n# How to Contribute\n\nWe encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](CONTRIBUTING.md) guide for details.\n\nQuick links:\n\n- [Feature Request](CONTRIBUTING.md#feature-request)\n- [Bug Reports](CONTRIBUTING.md#submit-a-bug-report)\n- [Improvements to the Codebase](CONTRIBUTING.md#improvements-to-the-codebase)\n- [Review Pull Requests](CONTRIBUTING.md#code-reviews)\n\n\u003ca name=\"troubleshooting\"\u003e\u003c/a\u003e\n# Troubleshooting\n\nPlease see our [troubleshooting guide](TROUBLESHOOTING.md) for common library issues.\n\n\u003ca name=\"about\"\u003e\u003c/a\u003e\n# About\n\nsendgrid-python is maintained and funded by Twilio SendGrid, Inc. The names and logos for sendgrid-python are trademarks of Twilio SendGrid, Inc.\n\n\u003ca name=\"support\"\u003e\u003c/a\u003e\n# Support\n\nIf you need support, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com).\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n# License\n[The MIT License (MIT)](LICENSE)\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsendgrid%2Fsendgrid-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsendgrid%2Fsendgrid-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsendgrid%2Fsendgrid-python/lists"}