https://github.com/screenshotone/jsdk
A Java SDK for the ScreenshotOne.com API to take screenshots of any URL
https://github.com/screenshotone/jsdk
screenshot screenshot-api screenshot-as-a-service screenshot-bot screenshot-generator screenshot-library screenshot-testing screenshots screenshotscloud
Last synced: 18 days ago
JSON representation
A Java SDK for the ScreenshotOne.com API to take screenshots of any URL
- Host: GitHub
- URL: https://github.com/screenshotone/jsdk
- Owner: screenshotone
- License: mit
- Created: 2022-06-02T14:05:10.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-03T07:52:05.000Z (over 2 years ago)
- Last Synced: 2025-03-24T04:23:28.586Z (about 1 month ago)
- Topics: screenshot, screenshot-api, screenshot-as-a-service, screenshot-bot, screenshot-generator, screenshot-library, screenshot-testing, screenshots, screenshotscloud
- Language: Java
- Homepage: https://screenshotone.com
- Size: 70.3 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsdk
[](https://github.com/screenshotone/jsdk/actions/workflows/build.yml)
An official [Screenshot API](https://screenshotone.com/) client for Java.
It takes minutes to start taking screenshots. Just [sign up](https://screenshotone.com/) to get access and secret keys, import the client, and you are ready to go.
The SDK client is synchronized with the latest [screenshot API options](https://screenshotone.com/docs/options/).
## Installation
Add the library as a dependency to your Maven project:
```
com.screenshotone.jsdk
screenshotone-api-jsdk
1.0.0
```Or Gradle:
```
dependencies {
compile 'com.screenshotone.jsdk:screenshotone-api-jsdk:1.0.0'
}
```## Usage
Generate a screenshot URL without executing request:
```java
import com.screenshotone.jsdk.Client;
import com.screenshotone.jsdk.TakeOptions;public class App {
public static void main(String[] args) throws Exception {
final Client client = Client.withKeys("IVmt2ghj9TG_jQ", "Sxt94yAj9aQSgg");
TakeOptions takeOptions = TakeOptions.url("https://scalabledeveloper.com")
.fullPage(true)
.deviceScaleFactor(1)
.viewportHeight(1200)
.viewportWidth(1200)
.format("png")
.omitBackground(true);
final String url = client.generateTakeUrl(takeOptions);System.out.println(url);
// Output: https://api.screenshotone.com/take?access_key=IVmt2ghj9TG_jQ&device_scale_factor=1&format=png&full_page=true&omit_background=true&url=https%3A%2F%2Fscalabledeveloper.com&viewport_height=1200&viewport_width=1200&signature=3c0c5543599067322e8c84470702330e3687c6a08eef6b7311b71c32d04e1bd5
}
}
```Take a screenshot and save the image in the file:
```java
import com.screenshotone.jsdk.Client;
import com.screenshotone.jsdk.TakeOptions;import java.io.File;
import java.nio.file.Files;public class App {
public static void main(String[] args) throws Exception {
final Client client = Client.withKeys("IVmt2ghj9TG_jQ", "Sxt94yAj9aQSgg");
TakeOptions takeOptions = TakeOptions.url("https://scalabledeveloper.com")
.fullPage(true)
.deviceScaleFactor(1)
.viewportHeight(1200)
.viewportWidth(1200)
.format("png")
.omitBackground(true);
final byte[] image = client.take();Files.write(new File("./example.png").toPath(), image);
}
}
```## Tests
To run tests, just execute:
```shell
./gradlew test
```## License
`screenshotone/jsdk` is released under [the MIT license](LICENSE).