{"id":11927,"date":"2019-11-07T12:07:10","date_gmt":"2019-11-07T03:07:10","guid":{"rendered":"https:\/\/sendgrid.kke.co.jp\/blog\/?p=11927"},"modified":"2025-11-26T13:27:43","modified_gmt":"2025-11-26T04:27:43","slug":"sendgrid-%e6%96%b0%e4%ba%ba%e6%88%90%e9%95%b7%e8%a8%98%e3%80%80%e7%ac%ac%e5%9b%9b%e5%9b%9e%e3%80%80python%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6web-api%e3%82%92%e5%91%bc%e3%81%b3%e5%87%ba%e3%81%99","status":"publish","type":"post","link":"https:\/\/sendgrid.kke.co.jp\/blog\/?p=11927","title":{"rendered":"\u3010SendGrid\u57fa\u672c\u8b1b\u5ea7 #4\u3011Python\u3092\u4f7f\u3063\u3066Web API\u3092\u547c\u3073\u51fa\u3059"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/11\/42f11c9080d67d5c5245fe26970551e1.png\" alt=\"\u3010SendGrid\u57fa\u672c\u8b1b\u5ea7 #4\u3011Python\u3092\u4f7f\u3063\u3066Web API\u3092\u547c\u3073\u51fa\u3059\" width=\"100%\" class=\"aligncenter size-full wp-image-19726\" srcset=\"https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/11\/42f11c9080d67d5c5245fe26970551e1.png 650w, https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/11\/42f11c9080d67d5c5245fe26970551e1-300x185.png 300w, https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/11\/42f11c9080d67d5c5245fe26970551e1-225x139.png 225w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>\u3053\u3093\u306b\u3061\u306f\uff01\u4eca\u56de\u306f\u3001\u3088\u304f\u77e5\u3089\u308c\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3092\u7528\u3044\u3066SendGrid\u306eWeb API\u3092\u547c\u3073\u51fa\u3059\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u3001\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u524d\u56de\u307e\u3067\u306e\u8a18\u4e8b\u3067\u306f\u3001API\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306eTry it out\u6a5f\u80fd\u3092\u7528\u3044\u3066\u7c21\u6613\u7684\u306b\u30e1\u30fc\u30eb\u306e\u9001\u4fe1\u3092\u884c\u3063\u3066\u304d\u307e\u3057\u305f\u3002\u4e00\u65b9\u3001\u5b9f\u969b\u306e\u904b\u7528\u3067\u30e6\u30fc\u30b6\u767b\u9332\u3084\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u30ea\u30bb\u30c3\u30c8\u3068\u3044\u3063\u305f\u5916\u90e8\u304b\u3089\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u30c8\u30ea\u30ac\u30fc\u306b\u30e1\u30fc\u30eb\u3092\u9001\u308d\u3046\u3068\u3059\u308b\u969b\u306b\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068SendGrid\u3092\u9023\u643a\u3055\u305b\u308b\u3053\u3068\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u304d\u307e\u3059\u3002\u305d\u308c\u3092\u5b9f\u73fe\u3055\u305b\u308b\u624b\u6bb5\u306e\u4e00\u3064\u3068\u3057\u3066\u3001SendGrid\u3067\u306f<a href=\"https:\/\/sendgrid.kke.co.jp\/docs\/Integrate\/libraries.html\" rel=\"noopener\" target=\"_blank\">\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u305f\u3081\u306e\u516c\u5f0f\u30e9\u30a4\u30d6\u30e9\u30ea<\/a>\u30927\u3064\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u7528\u610f\u3057\u3066\u3044\u307e\u3059\u3002\u4eca\u56de\u306f\u305d\u306e\u4e2d\u304b\u3089Python\u3092\u7528\u3044\u3066\u30e1\u30fc\u30eb\u9001\u4fe1\u3092\u3057\u3066\u307f\u307e\u3057\u305f\uff08Python\u3092\u9078\u3093\u3060\u306e\u306f\u79c1\u304c\u4ee5\u524d\u89e6\u3063\u305f\u3053\u3068\u306e\u3042\u308b\u8a00\u8a9e\u3060\u304b\u3089\u3068\u3044\u3046\u3060\u3051\u3067\u3001\u3042\u307e\u308a\u6df1\u3044\u7406\u7531\u306f\u3042\u308a\u307e\u305b\u3093\uff09\u3002<a href=\"https:\/\/github.com\/sendgrid\/sendgrid-python\" rel=\"noopener\" target=\"_blank\">\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u516c\u5f0f\u30da\u30fc\u30b8<\/a>\u306b\u57fa\u3065\u3044\u3066\u30011. API\u30ad\u30fc\u3092\u74b0\u5883\u5909\u6570\u306b\u8a2d\u5b9a\u3057\u30012. \u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u5b9f\u884c\u3059\u308b\u3001\u3068\u3044\u30462\u30b9\u30c6\u30c3\u30d7\u3067\u9032\u3081\u307e\u3059\u3002<\/p>\n<p><strong>1. \u74b0\u5883\u5909\u6570\u306e\u8a2d\u5b9a<\/strong><\/p>\n<p>\u8a8d\u8a3c\u60c5\u5831\u3092\u30b3\u30fc\u30c9\u306b\u30d9\u30bf\u66f8\u304d\u3059\u308b\u306e\u306f\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u671b\u307e\u3057\u304f\u306a\u3044\u306e\u3067\u3001\u53d6\u5f97\u3057\u305fAPI\u30ad\u30fc\u306f\u74b0\u5883\u5909\u6570\u3068\u3057\u3066\u8a2d\u5b9a\u3057\u3001\u30b3\u30fc\u30c9\u306e\u4e2d\u3067\u306f\u305d\u306e\u74b0\u5883\u5909\u6570\u3092\u53c2\u7167\u3059\u308b\u5f62\u306b\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002OS\u306b\u3088\u3063\u3066\u65b9\u6cd5\u304c\u7570\u306a\u308a\u307e\u3059\u304c\u3001macOS 10.14 Mojave\u306e\u5834\u5408\u3001~\/.bash_profile\u306b<br \/>\nexport SENDGRID_API_KEY=\u2019SG.XXX\u2019<br \/>\n\u3068\u3044\u3046\u6587\u5b57\u5217\u3092\u8ffd\u52a0\u3057\uff08SG.XXX\u306f\u53d6\u5f97\u3057\u305fAPI\u30ad\u30fc\uff09\u3001source\u30b3\u30de\u30f3\u30c9\u3067\u8a2d\u5b9a\u3092\u53cd\u6620\u3055\u305b\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n$ echo &quot;export SENDGRID_API_KEY=\u2019SG.XXX\u2019&quot; &gt; ~\/.bash_profile\r\n$ source ~\/.bash_profile\r\n<\/pre>\n<p><strong>2. \u516c\u5f0f\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u7528\u3044\u305f\u30b3\u30fc\u30c9\u306e\u4f5c\u6210<\/strong><\/p>\n<p>\u307e\u305a\u306f\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u30c4\u30fc\u30ebpip\u3092\u4f7f\u3063\u3066SendGrid\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n$ pip3 install sendgrid\r\n<\/pre>\n<p>\u3042\u3068\u306f\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u5b9f\u884c\u3059\u308c\u3070\u3001\u30e1\u30fc\u30eb\u304c\u9001\u4fe1\u3067\u304d\u307e\u3059\uff01<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nimport os\r\nfrom sendgrid import SendGridAPIClient\r\nfrom sendgrid.helpers.mail import Mail\r\n\r\nmessage = Mail(\r\n    from_email='from_address@example.com',\r\n    to_emails='&lt;&lt;YOUR_ADDRESS&gt;&gt;',\r\n    subject='Hello, World!',\r\n    plain_text_content='Hello, World!')\r\n\r\nsg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))\r\nresponse = sg.send(message)\r\nprint(response.status_code)\r\n<\/pre>\n<p>os.environ.get(&#8216;SENDGRID_API_KEY&#8217;)\u3067\u74b0\u5883\u5909\u6570\u304b\u3089API\u30ad\u30fc\u3092\u53d6\u5f97\u3057\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u5b9a\u7fa9\u3055\u308c\u305fSendGridAPIClient\u3068\u3044\u3046\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u5165\u308c\u307e\u3059\u3002\u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3042\u308bsend\u306b\u3001\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u305f\u3081\u306e\u60c5\u5831\u3092json\u5f62\u5f0f\u3067\u6e21\u3057\u3066\u3044\u307e\u3059\u3002&lt;&lt;YOUR_ADDRESS&gt;&gt;\u306f\u3054\u81ea\u8eab\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u6700\u5f8c\u306eprint\u6587\u3067\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u3092\u8868\u793a\u3055\u305b\u3066\u3044\u308b\u306e\u3067\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u306b202\u3068\u51fa\u305f\u3089\u9001\u4fe1\u51e6\u7406\u306f\u6210\u529f\u3067\u3059\u3002\u53d7\u4fe1\u7bb1\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3010\u88dc\u8db3\u3011 \u516c\u5f0f\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408<br \/>\n\u88dc\u8db3\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u306b\u516c\u5f0f\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u308f\u306a\u3044\u65b9\u6cd5\u3082\u7d39\u4ecb\u3057\u307e\u3059\u3002\u5b9f\u969b\u3001\u4e0a\u306e\u3088\u3046\u306a\u5358\u7d14\u306a\u3082\u306e\u3067\u3042\u308c\u3070\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u4e2d\u3067\u76f4\u63a5Web API\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u5148\u307b\u3069\u3068\u540c\u69d8\u306b\u74b0\u5883\u5909\u6570\u3092\u8a2d\u5b9a\u3057\u305f\u3089\u3001HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u7c21\u5358\u306b\u9001\u308c\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3042\u308brequests\u3092sendgrid\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u4ee3\u308f\u308a\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n$ pip3 install requests\r\n<\/pre>\n<p>\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nimport os, requests\r\n\r\nurl = 'https:\/\/api.sendgrid.com\/v3\/mail\/send'\r\nheaders = {'Authorization': f'Bearer {os.environ.get(&quot;SENDGRID_API_KEY&quot;)}'}\r\nmessage = {'personalizations': &#x5B;{'to': &#x5B;{'email': 'YOUR_ADDRESS'}], 'subject': 'Hello, World!'}],\r\n            'from': {'email': 'from_address@example.com'},\r\n            'content': &#x5B;{'type': 'text\/plain', 'value': 'Hello, World!'}]\r\n       \u3000 }\r\n\r\nresponse = requests.post(url, headers=headers, json=message)\r\nprint(response.status_code)\r\n<\/pre>\n<p>SendGrid\u516c\u5f0f\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u5834\u5408\u3068\u7570\u306a\u308b\u306e\u306f\u3001URL\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u3053\u3068\u3068\u3001<a href=\"https:\/\/sendgrid.kke.co.jp\/blog\/?p=11818\" rel=\"noopener\" target=\"_blank\">Try it out\u306e\u5834\u5408<\/a>\u3068\u540c\u69d8\u306b\u30d8\u30c3\u30c0\u30fc\u306bAPI\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u3053\u3068\u3067\u3059\u3002\u305d\u308c\u3067\u3082\u3001\u516c\u5f0f\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u5834\u5408\u3068\u3055\u307b\u3069\u5909\u308f\u3089\u306a\u3044\u30b3\u30fc\u30c9\u91cf\u3067\u30e1\u30fc\u30eb\u304c\u9001\u4fe1\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>Try it out\u3092\u4f7f\u3046\u3060\u3051\u3067\u306f\u5b9f\u969b\u306b\u30e1\u30fc\u30eb\u914d\u4fe1\u30b5\u30fc\u30d3\u30b9\u304c\u3069\u3046\u904b\u7528\u3055\u308c\u308b\u304b\u30a4\u30e1\u30fc\u30b8\u304c\u6e67\u304b\u306a\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304b\u3089\u30e1\u30fc\u30eb\u9001\u4fe1\u3057\u3066\u307f\u308b\u3053\u3068\u3067\u3001\u5916\u90e8\u306e\u30b7\u30b9\u30c6\u30e0\u3084\u30b5\u30fc\u30d3\u30b9\u3068\u9023\u643a\u3059\u308b\u305f\u3081\u306e\u7b2c\u4e00\u6b69\u304c\u8e0f\u307f\u51fa\u305b\u307e\u3057\u305f\u3002<\/p>\n<p>\u203b\u306a\u304a\u3001\u516c\u5f0f\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u95a2\u3059\u308b\u30b5\u30dd\u30fc\u30c8\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/support.sendgrid.kke.co.jp\/hc\/ja\/articles\/115000110181\" rel=\"noopener\" target=\"_blank\">\u3053\u3061\u3089<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\uff01\u4eca\u56de\u306f\u3001\u3088\u304f\u77e5\u3089\u308c\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3092\u7528\u3044\u3066SendGrid\u306eWeb API\u3092\u547c\u3073\u51fa\u3059\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u3001\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u524d\u56de\u307e\u3067\u306e\u8a18\u4e8b\u3067\u306f\u3001API\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306eTry it out\u6a5f\u80fd\u3092 <a class=\"read-more\" href=\"https:\/\/sendgrid.kke.co.jp\/blog\/?p=11927\">&#8230;\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":15,"featured_media":19726,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-11927","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-product"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11927"}],"version-history":[{"count":10,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11927\/revisions"}],"predecessor-version":[{"id":19737,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11927\/revisions\/19737"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/media\/19726"}],"wp:attachment":[{"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}