https://github.com/sendgrid/ruby-http-client
SendGrid's Ruby HTTP Client for calling APIs
https://github.com/sendgrid/ruby-http-client
Last synced: 7 months ago
JSON representation
SendGrid's Ruby HTTP Client for calling APIs
- Host: GitHub
- URL: https://github.com/sendgrid/ruby-http-client
- Owner: sendgrid
- License: mit
- Created: 2016-03-11T15:13:04.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2024-07-16T19:16:08.000Z (over 1 year ago)
- Last Synced: 2025-08-09T21:08:45.465Z (8 months ago)
- Language: Ruby
- Homepage: https://sendgrid.com
- Size: 332 KB
- Stars: 22
- Watchers: 120
- Forks: 56
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

[](https://github.com/sendgrid/ruby-http-client/actions/workflows/test-and-deploy.yml)
[](https://badge.fury.io/rb/ruby_http_client)
[](LICENSE)
[](https://twitter.com/sendgrid)
[](https://github.com/sendgrid/ruby-http-client/graphs/contributors)
**Quickly and easily access any RESTful or RESTful-like API.**
If you are looking for the SendGrid API client library, please see [this repo](https://github.com/sendgrid/sendgrid-ruby).
# Announcements
All updates to this library are documented in our [CHANGELOG](CHANGELOG.md).
# Table of Contents
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [How to Contribute](#contribute)
- [About](#about)
- [Support](#support)
- [License](#license)
## Prerequisites
- Ruby version >= 2.4
## Setup Environment Variables
### Environment Variable
Update the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys), for example:
```bash
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env
```
## Install Package
```bash
gem install ruby_http_client
```
`GET /your/api/{param}/call`
```ruby
require 'ruby_http_client'
global_headers = {'Authorization' => 'Bearer XXXXXXX' }
client = SendGrid::Client.new(host: 'base_url', request_headers: global_headers)
client.your.api._(param).call.get
puts response.status_code
puts response.body
puts response.headers
```
`POST /your/api/{param}/call` with headers, query parameters and a request body with versioning.
```ruby
require 'ruby_http_client'
global_headers = {'Authorization' => 'Bearer XXXXXXX' }
client = SendGrid::Client.new(host: 'base_url', request_headers: global_headers)
query_params = { 'hello' => 0, 'world' => 1 }
request_headers = { 'X-Test' => 'test' }
data = { 'some' => 1, 'awesome' => 2, 'data' => 3}
response = client.your.api._(param).call.post(request_body: data,
query_params: query_params,
request_headers: request_headers)
puts response.status_code
puts response.body
puts response.headers
```
- [Example Code](examples)
We encourage contribution to our libraries, please see our [CONTRIBUTING](CONTRIBUTING.md) guide for details.
Quick links:
- [Improvements to the Codebase](CONTRIBUTING.md#improvements-to-the-codebase)
- [Review Pull Requests](CONTRIBUTING.md#code-reviews)
ruby-http-client is maintained and funded by Twilio SendGrid, Inc. The names and logos for ruby-http-client are trademarks of Twilio SendGrid, Inc.
If you need help using SendGrid, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com).
# License
[The MIT License (MIT)](LICENSE)