{"id":22415793,"url":"https://github.com/xmas7/sendgrid-api","last_synced_at":"2026-05-03T19:33:08.189Z","repository":{"id":143167484,"uuid":"541624842","full_name":"xmas7/sendgrid-api","owner":"xmas7","description":"A Ruby interface to the SendGrid API.","archived":false,"fork":false,"pushed_at":"2022-09-26T14:23:03.000Z","size":81,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T04:18:42.327Z","etag":null,"topics":["api","email","interface","rails","ruby","rubyonrails","sendgrid"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/xmas7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2022-09-26T14:20:27.000Z","updated_at":"2024-05-20T11:11:41.000Z","dependencies_parsed_at":"2023-04-15T20:33:17.965Z","dependency_job_id":null,"html_url":"https://github.com/xmas7/sendgrid-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xmas7/sendgrid-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmas7%2Fsendgrid-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmas7%2Fsendgrid-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmas7%2Fsendgrid-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmas7%2Fsendgrid-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xmas7","download_url":"https://codeload.github.com/xmas7/sendgrid-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmas7%2Fsendgrid-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32582697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api","email","interface","rails","ruby","rubyonrails","sendgrid"],"created_at":"2024-12-05T15:13:43.362Z","updated_at":"2026-05-03T19:33:08.165Z","avatar_url":"https://github.com/xmas7.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sendgrid::API\n\n[![Build Status](https://secure.travis-ci.org/renatosnrg/sendgrid-api.png?branch=master)][gem]\n[![Code Climate](https://codeclimate.com/github/renatosnrg/sendgrid-api.png)][codeclimate]\n[![Coverage Status](https://coveralls.io/repos/renatosnrg/sendgrid-api/badge.png?branch=master)][coveralls]\n\n[gem]: http://travis-ci.org/renatosnrg/sendgrid-api\n[codeclimate]: https://codeclimate.com/github/renatosnrg/sendgrid-api\n[coveralls]: https://coveralls.io/r/renatosnrg/sendgrid-api\n\nA Ruby interface to the SendGrid API.\n\n## API Coverage\n\nCheck which SendGrid APIs are currently being covered by this gem:\n\n[https://github.com/renatosnrg/sendgrid-api/wiki/SendGrid-API-Coverage][coverage]\n\n[coverage]: https://github.com/renatosnrg/sendgrid-api/wiki/SendGrid-API-Coverage\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'sendgrid-api'\n```\n\nAnd then execute:\n\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install sendgrid-api\n```\n\n## Configuration\n\n```ruby\nclient = Sendgrid::API::Client.new('YOUR_USER', 'YOUR_KEY')\n```\n\n## Web API\n\n### Profile\n\n```ruby\n# create a profile object\nprofile = Sendgrid::API::Entities::Profile.new(:first_name =\u003e 'Your first name',\n                                               :last_name =\u003e 'Your last name')\n# get your profile\nprofile = client.profile.get\n# modify your profile\nresponse = client.profile.set(profile)\n```\n\n### Mail\n\n```ruby\n# send basic text email\nresponse = client.mail.send(:to =\u003e 'johndoe@example.com',\n                            :from =\u003e 'brian@example.com',\n                            :subject =\u003e 'test using sendgrid api',\n                            :text =\u003e 'this is a test')\n# set SMTP API headers\nx_smtpapi = {:category =\u003e ['sendgrid-api test']}\nresponse = client.mail.send(:to =\u003e 'johndoe@example.com',\n                            :from =\u003e 'brian@example.com',\n                            :subject =\u003e 'test using sendgrid api',\n                            :text =\u003e 'this is a test',\n                            :x_smtpapi =\u003e x_smtpapi)\n# send files attached\ntext = StringIO.new(\"This is my file content\")\nfile = Faraday::UploadIO.new(text, 'plain/text', 'sample.txt')\nresponse = client.mail.send(:to =\u003e 'johndoe@example.com',\n                            :from =\u003e 'brian@example.com',\n                            :subject =\u003e 'test using sendgrid api',\n                            :text =\u003e 'this is a test',\n                            :files =\u003e {'sample.txt' =\u003e file})\n```\n\n### Statistics\n\n```ruby\n# get advanced statistics\nstats = client.stats.advanced(:start_date =\u003e '2013-01-01', :data_type =\u003e 'global')\n```\n\n## Marketing Email API\n\n### Lists\n\n```ruby\n# create a list object\nlist = Sendgrid::API::Entities::List.new(:list =\u003e 'sendgrid-api list test')\n# add a new list\nresponse = client.lists.add(list)\n# edit an existing list\nresponse = client.lists.edit(list, 'new name')\n# get an existing list\nselected_list = client.lists.get(list)\n# get all lists\nall_lists = client.lists.get\n# delete a list\nresponse = client.lists.delete(list)\n```\n\n### Emails\n\n```ruby\n# create email objects\nemail1 = Sendgrid::API::Entities::Email.new(\n            :email =\u003e 'johndoe@example.com',\n            :name =\u003e 'John Doe'\n         )\nemail2 = Sendgrid::API::Entities::Email.new(\n            :email =\u003e 'brian@example.com',\n            :name =\u003e 'Brian'\n         )\nemails = [email1, email2]\nlistname = 'sendgrid-api list test'\n# add emails to a list\nresponse = client.emails.add(listname, emails)\n# get all emails from a list\nall_emails = client.emails.get(listname)\n# get a specific email from a list\nselected_emails = client.emails.get(listname, email1)\n# delete an email from a list\nresponse = client.emails.delete(listname, email1)\n```\n\n### Sender Adresses\n\n```ruby\n# create sender address object\naddress = Sendgrid::API::Entities::SenderAddress.new(\n            :identity =\u003e 'sendgrid-api sender address test',\n            :name     =\u003e 'Sendgrid',\n            :email    =\u003e 'contact@sendgrid.com',\n            :address  =\u003e '1065 N Pacificenter Drive, Suite 425',\n            :city     =\u003e 'Anaheim',\n            :state    =\u003e 'CA',\n            :zip      =\u003e '92806',\n            :country  =\u003e 'US'\n          )\n# add a sender address\nresponse = client.sender_addresses.add(address)\n# edit a sender address\naddress.city = 'Pleasanton'\nresponse = client.sender_addresses.edit(address, 'new identity')\n# get all sender addresses\naddresses = client.sender_addresses.list\n# get a sender address\naddress = client.sender_addresses.get(address)\n# delete a sender address\nresponse = client.sender_addresses.delete(address)\n```\n\n### Marketing Emails\n\n```ruby\n# create marketing email object\nmarketing_email = Sendgrid::API::Entities::MarketingEmail.new(\n                    :identity =\u003e 'sendgrid-api sender address test',\n                    :name     =\u003e 'sendgrid-api marketing email test',\n                    :subject  =\u003e 'My Marketing Email Test',\n                    :text     =\u003e 'My text',\n                    :html     =\u003e 'My HTML'\n                  )\n# add a marketing email\nresponse = client.marketing_emails.add(marketing_email)\n# edit a marketing email\nmarketing_email.html = 'My new HTML'\nresponse = client.marketing_emails.edit(marketing_email, 'new name')\n# get a marketing email\nnewsletter = client.marketing_emails.get(marketing_email)\n# get all marketing emails\nnewsletters = client.marketing_emails.list\n# delete a marketing email\nresponse = client.marketing_emails.delete(marketing_email)\n```\n\n### Categories\n\n```ruby\n# create category object\ncategory = Sendgrid::API::Entities::Category.new(:category =\u003e 'sendgrid-api test')\nmarketing_email = 'sendgrid-api marketing email test'\n# add category\nresponse = client.categories.create(category)\n# add category to a marketing email\nresponse = client.categories.add(marketing_email, category)\n# remove category from a marketing email\nresponse = client.categories.remove(marketing_email, category)\n# get all categories\ncategories = client.categories.list\n```\n\n### Recipients\n\n```ruby\nlistname = 'sendgrid-api list test'\nmarketing_email = 'sendgrid-api marketing email test'\n# assign a recipient list to a marketing email\nresponse = client.recipients.add(listname, marketing_email)\n# get all lists assigned to a marketing email\nlists = client.recipients.get(marketing_email)\n# delete an assigned list from a marketing email\nresponse = client.recipients.delete(listname, marketing_email)\n```\n\n### Schedule\n\n```ruby\nmarketing_email = 'sendgrid-api marketing email test'\n# schedule a delivery time for a marketing email\nresponse = client.schedule.add(marketing_email) # imediately\nresponse = client.schedule.add(marketing_email, :after =\u003e 20) # 20 minutes from now\nresponse = client.schedule.add(marketing_email, :at =\u003e (Time.now + 10*60)) # 10 minutes from now\n# retrieve the scheduled delivery time for a marketing email\nschedule = client.schedule.get(marketing_email)\n# cancel a scheduled delivery time for a marketing email\nresponse = client.schedule.delete(marketing_email)\n```\n\n## Tests\n\nThis gem has offline and online tests written using RSpec. Offline tests use Webmock to stub HTTP requests, while online tests performs the requests to Sendgrid to ensure all the calls and responses are correctly.\n\nThe online tests are written in a way that they don't change the state of the objects already existing on SendGrid account. It means if something is added, it's removed at the end of the test. If something is changed, it's changed back after the test finishes. If it's necessary to remove something, it's added before the test starts.\n\nUse the SENDGRID_USER and SENDGRID_KEY environment variables to authenticate the online tests.\n\nTo run all tests (both offline and online):\n```bash\n$ ALL=1 SENDGRID_USER=your_user SENDGRID_KEY=your_key bundle exec rake spec\n```\n\nTo run only online tests:\n```bash\n$ SENDGRID_USER=your_user SENDGRID_KEY=your_key bundle exec rake spec[online]\n```\n\nTo run only offline tests (default):\n```bash\n$ bundle exec rake spec\n```\n\n## Contributing\n\nIf you want to contribute to cover more APIs or improve something already implemented, follow these steps:\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes - do not forget tests (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmas7%2Fsendgrid-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxmas7%2Fsendgrid-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmas7%2Fsendgrid-api/lists"}