https://github.com/screenshotone/gosdk
A Go SDK for the ScreenshotOne.com API to take screenshots of any URL
https://github.com/screenshotone/gosdk
go go-library go-package golang golang-library golang-package screenshot screenshot-api screenshot-as-a-service screenshot-comparison screenshot-comparison-tests screenshot-generator screenshot-library screenshot-taker screenshot-testing screenshot-utility screenshots screenshots-generated
Last synced: 17 days ago
JSON representation
A Go SDK for the ScreenshotOne.com API to take screenshots of any URL
- Host: GitHub
- URL: https://github.com/screenshotone/gosdk
- Owner: screenshotone
- License: mit
- Created: 2022-05-31T14:53:07.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-23T13:41:16.000Z (almost 3 years ago)
- Last Synced: 2024-06-19T19:47:49.441Z (10 months ago)
- Topics: go, go-library, go-package, golang, golang-library, golang-package, screenshot, screenshot-api, screenshot-as-a-service, screenshot-comparison, screenshot-comparison-tests, screenshot-generator, screenshot-library, screenshot-taker, screenshot-testing, screenshot-utility, screenshots, screenshots-generated
- Language: Go
- Homepage: https://screenshotone.com
- Size: 21.5 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gosdk
[](https://github.com/screenshotone/gosdk/actions/workflows/build.yml)
[](https://goreportcard.com/report/github.com/screenshotone/gosdk)
[](https://godoc.org/github.com/screenshotone/gosdk)An official [Screenshot API](https://screenshotone.com/) client for Go.
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
```shell
go get github.com/screenshotone/gosdk
```## Usage
Import the library:
```go
import screenshots "github.com/screenshotone/gosdk"
```Generate a screenshot URL without executing request:
```go
client, err := screenshots.NewClient("IVmt2ghj9TG_jQ", "Sxt94yAj9aQSgg")
if err != nil {
// ...
}options := screenshots.NewTakeOptions("https://scalabledeveloper.com").
Format("png").
FullPage(true).
DeviceScaleFactor(2).
BlockAds(true).
BlockTrackers(true)u, err := client.GenerateTakeURL(options)
if err != nil {
// ...
}fmt.Println(u.String())
// Output: https://api.screenshotone.com/take?access_key=IVmt2ghj9TG_jQ&block_ads=true&block_trackers=true&device_scale_factor=2&format=png&full_page=true&url=https%3A%2F%2Fscalabledeveloper.com&signature=85aabf7ac251563ec6158ef6839dd019bb79ce222cc85288a2e8cea0291a824e
```Take a screenshot and save the image in the file:
```go
client, err := screenshots.NewClient("IVmt2ghj9TG_jQ", "Sxt94yAj9aQSgg")
if err != nil {
// ...
}options := screenshots.NewTakeOptions("https://example.com").
Format("png").
FullPage(true).
DeviceScaleFactor(2).
BlockAds(true).
BlockTrackers(true)image, _, err := client.Take(context.TODO(), options)
if err != nil {
// ...
}out, err := os.Create("example.png")
if err != nil {
// ...
}
defer out.Close()_, err = out.Write(out, image)
if err != nil {
// ...
}
```## Tests
To run tests, just execute:
```
$ go test .
```## License
`screenshotone/gosdk` is released under [the MIT license](LICENSE).