screenshotapi 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +36 -0
  4. data/lib/screenshotapi.rb +41 -0
  5. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1a5b310d750811191811f5bed39a225899bcc78029c819a3e88a41dd3b8bfcf3
4
+ data.tar.gz: ff56d4db579e84bfba9602d3d2213975d24bc078ac3df33d4b2bfa2b02864dfc
5
+ SHA512:
6
+ metadata.gz: 91944ed250a005f39d6e3d420771135d7632733e82421777cde19a65149a8539414d2c4bb393fbbbdbc59d1f544a07813682babefbb1ced3ffa6d33e18c0d280
7
+ data.tar.gz: 375bba1405a02d67d06e75b4d99e74150046b59ee87e090cddb1f650f3ebc1a862ebdf64f52c6f80d743276425d948dc3b7a0339836a25439b0dbfc89af986da
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 EverAPI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # screenshotapi (Ruby)
2
+
3
+ Ruby client for the Screenshotbase Screenshot API.
4
+
5
+ - Docs & landing page: https://screenshotbase.com
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ gem install screenshotapi
11
+ ```
12
+
13
+ or in your Gemfile:
14
+
15
+ ```ruby
16
+ gem 'screenshotapi'
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require 'screenshotapi'
23
+
24
+ client = ScreenshotAPI::Client.new('YOUR-API-KEY')
25
+
26
+ # Status
27
+ puts client.status
28
+
29
+ # Take a screenshot
30
+ img = client.take(url: 'https://bbc.com', format: 'png', full_page: true)
31
+ File.binwrite('screenshot.png', img)
32
+ ```
33
+
34
+ ## License
35
+
36
+ MIT
@@ -0,0 +1,41 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+
5
+ module ScreenshotAPI
6
+ class Client
7
+ def initialize(api_key, base_url: 'https://api.screenshotbase.com')
8
+ raise ArgumentError, 'API key required' if api_key.to_s.strip.empty?
9
+ @api_key = api_key
10
+ @base_url = base_url.sub(%r{/*$}, '')
11
+ end
12
+
13
+ def status
14
+ uri = URI.parse(@base_url + '/v1/status')
15
+ req = Net::HTTP::Get.new(uri)
16
+ req['apikey'] = @api_key
17
+ res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') { |h| h.request(req) }
18
+ raise "HTTP #{res.code}: #{res.body}" unless res.is_a?(Net::HTTPSuccess)
19
+ JSON.parse(res.body)
20
+ end
21
+
22
+ # params: { url:, format:, quality:, full_page:, viewport_width:, viewport_height: }
23
+ def take(params)
24
+ raise ArgumentError, 'url required' unless params && params[:url]
25
+ qs = URI.encode_www_form(
26
+ url: params[:url],
27
+ format: params[:format],
28
+ quality: params[:quality],
29
+ full_page: params.key?(:full_page) ? (params[:full_page] ? '1' : '0') : nil,
30
+ viewport_width: params[:viewport_width],
31
+ viewport_height: params[:viewport_height]
32
+ )
33
+ uri = URI.parse(@base_url + '/v1/take?' + qs)
34
+ req = Net::HTTP::Get.new(uri)
35
+ req['apikey'] = @api_key
36
+ res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') { |h| h.request(req) }
37
+ raise "HTTP #{res.code}: #{res.body}" unless res.is_a?(Net::HTTPSuccess)
38
+ res.body # binary string
39
+ end
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: screenshotapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - martechdev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-09-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Official Ruby wrapper for screenshotbase.com Screenshot API.
14
+ email: martechdev@users.noreply.github.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - lib/screenshotapi.rb
22
+ homepage: https://github.com/everapihq/screenshotapi-ruby
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '3.0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubygems_version: 3.0.3.1
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Ruby client for the Screenshotbase API
45
+ test_files: []