https://github.com/sendgrid/java-http-client
SendGrid's Java HTTP Client for calling APIs
https://github.com/sendgrid/java-http-client
Last synced: 7 months ago
JSON representation
SendGrid's Java HTTP Client for calling APIs
- Host: GitHub
- URL: https://github.com/sendgrid/java-http-client
- Owner: sendgrid
- License: mit
- Created: 2016-03-09T21:59:49.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2023-04-10T00:22:01.000Z (almost 3 years ago)
- Last Synced: 2025-07-09T14:09:00.659Z (9 months ago)
- Language: Java
- Homepage: https://sendgrid.com
- Size: 2.66 MB
- Stars: 25
- Watchers: 155
- Forks: 78
- Open Issues: 5
-
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/java-http-client/actions/workflows/test-and-deploy.yml)
[](http://mvnrepository.com/artifact/com.sendgrid/java-http-client)
[](LICENSE)
[](https://twitter.com/sendgrid)
[](https://github.com/sendgrid/java-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-java).
# Table of Contents
* [Announcements](#announcements)
* [Installation](#installation)
* [Quick Start](#quick-start)
* [Usage](./USAGE.md)
* [How to Contribute](#contribute)
* [About](#about)
* [Support](#support)
* [License](#license)
All updates to this project are documented in our [CHANGELOG](CHANGELOG.md).
## Prerequisites
- Java 8, 11, or 17
## Install via Maven w/ Gradle
```groovy
...
dependencies {
...
compile 'com.sendgrid:java-http-client:4.5.1'
}
repositories {
mavenCentral()
}
...
```
### Maven
```xml
com.sendgrid
java-http-client
4.5.1
```
`mvn install`
## Dependencies
- Please see the [pom.xml file](pom.xml)
Here is a quick example:
`GET /your/api/{param}/call`
```java
Client client = new Client();
Request request = new Request();
request.setBaseUri("api.test.com");
request.setMethod(Method.GET);
String param = "param";
request.setEndpoint("/your/api/" + param + "/call");
try {
Response response = client.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
```
`POST /your/api/{param}/call` with headers, query parameters and a request body.
```java
request.addHeader("Authorization", "Bearer YOUR_API_KEY");
request.addQueryParam("limit", "100");
request.addQueryParam("offset", "0");
// Will be parsed to categories=cake&categories=pie&categories=baking
request.addQueryParam("categories", "cake&pie&baking");
request.setBody("{\"name\": \"My Request Body\"}");
request.setMethod(Method.POST);
String param = "param";
request.setEndpoint("/your/api/" + param + "/call");
try {
Response response = client.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
```
We encourage contribution to our projects please see our [CONTRIBUTING](CONTRIBUTING.md) guide for details.
Quick links:
- [Feature Request](CONTRIBUTING.md#feature-request)
- [Bug Reports](CONTRIBUTING.md#submit-a-bug-report)
- [Improvements to the Codebase](CONTRIBUTING.md#improvements-to-the-codebase)
- [Review Pull Requests](CONTRIBUTING.md#Code-Reviews)
java-http-client is maintained and funded by Twilio SendGrid, Inc. The names and logos for java-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).
If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!
# License
[The MIT License (MIT)](LICENSE)