https://github.com/seamapi/java
Java library for accessing the Seam API
https://github.com/seamapi/java
java-client java-sdk
Last synced: 3 months ago
JSON representation
Java library for accessing the Seam API
- Host: GitHub
- URL: https://github.com/seamapi/java
- Owner: seamapi
- Created: 2023-05-29T03:53:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-08T17:32:24.000Z (12 months ago)
- Last Synced: 2025-03-19T09:42:56.132Z (3 months ago)
- Topics: java-client, java-sdk
- Language: Java
- Homepage: https://docs.seam.co
- Size: 1.17 MB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Seam Java Library
[](https://central.sonatype.com/artifact/io.github.seamapi/java)
[](https://buildwithfern.com/?utm_source=seamapi/java/readme)## Documentation
API documentation is available at https://docs.seam.co/latest/api-clients/overview.
## Install
### Gradle
Add the dependency in your `build.gradle`:
```groovy
dependencies {
implementation 'io.github.seamapi:java:0.x.x'
}
```### Maven
Add the dependency in your `pom.xml`:
```xml
io.github.seamapi
java
0.x.x```
## Usage
```java
import com.seam.api.Seam;
import com.seam.api.types.AccessCode;
import com.seam.api.resources.accesscodes.requests.AccessCodesCreateRequest;Seam seam = Seam.builder()
.token("MY_API_KEY")
.build();
AccessCode accessCode = seam.accessCodes().create(AccessCodesCreateRequest.builder()
.deviceId(someDevice.getDeviceId())
.name("Test code")
.code("4444")
.build());
System.out.println(accessCode);
```## Using PATs
If you're using access tokens to authenticate with the API, make sure
to supply the seam workspace when you construct the client.```java
import com.seam.api.Seam;
import com.seam.api.types.AccessCode;Seam seam = Seam.builder()
.token("YOUR_PAT")
.seamWorkspace("YOUR_WORKSPACE_ID")
.build();
```## Handling Errors
When the API returns a non-success status code (4xx or 5xx response),
a subclass of [ApiError](src/main/java/com/seam/api/core/ApiError.java)
will be thrown:```ts
import com.seam.api.core.ApiError;try {
seam.accessCodes().create(...);
} catch (ApiError error) {
System.out.println(error.getBody());
System.out.println(error.getStatusCode());
}
```## Staged Builders
The generated builders all follow the staged builder pattern.
Read more [here](https://immutables.github.io/immutable.html#staged-builder).
Staged builders only allow you to construct the object once all required
properties have been specified.For example, in the snippet below, you will not be able to access the build
method on `AccessCodesCreateRequest` until you have specified the mandatory
deviceId variable.```java
import com.seam.api.resources.accesscodes.requests.AccessCodesCreateRequest;AccessCodesCreateRequest.builder()
.deviceId(someDevice.getDeviceId())
.name("Test code")
.code("4444")
.build()
```## Beta status
This SDK is in beta, and there may be breaking changes between versions without a major version update.
Therefore, we recommend pinning the package version to a specific version in your build.gradle file.
This way, you can install the same version each time without breaking changes unless you are
intentionally looking for the latest version.## Contributing
While we value open-source contributions to this SDK, this library is generated programmatically.
Additions made directly to this library would have to be moved over to our generation code,
otherwise they would be overwritten upon the next generated release. Feel free to open a PR
as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!On the other hand, contributions to the README are always very welcome!