api2convert 10.2.0 → 10.2.1
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.
- checksums.yaml +4 -4
- data/README.md +38 -0
- data/docs/CHANGELOG.md +4 -2
- data/examples/add_watermark.rb +36 -0
- data/examples/audio_operations.rb +21 -0
- data/examples/authentication.rb +13 -0
- data/examples/capture_website.rb +29 -0
- data/examples/compare_files.rb +34 -0
- data/examples/compress_files.rb +18 -0
- data/examples/convert_files.rb +24 -0
- data/examples/create_archives.rb +29 -0
- data/examples/create_hashes.rb +19 -0
- data/examples/create_thumbnails.rb +22 -0
- data/examples/extract_assets.rb +16 -0
- data/examples/file_analysis.rb +17 -0
- data/examples/image_operations.rb +21 -0
- data/examples/job_lifecycle.rb +29 -0
- data/examples/presets.rb +14 -0
- data/examples/quickstart.rb +22 -0
- data/examples/rate_limits.rb +12 -0
- data/examples/statistics.rb +12 -0
- data/examples/uploading_files.rb +27 -0
- data/examples/webhooks.rb +24 -0
- data/lib/api2convert/version.rb +1 -1
- metadata +22 -3
- data/examples/convert.rb +0 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 39056074d7f58decce593b6b8baae8d93bf51f1b5e8bc28d4f803febccedd74a
|
|
4
|
+
data.tar.gz: 268f0497c655e8cbe40aef88b56642b803f7def33d6dbf06495979977d94967e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 107965e469189bae258af1ec97409a89db7a0b1b898295a1322b0701d0c49e2544850ca439caa3459d46637eff51e1b4cc926f5d21dfdea5aa8235596a353242
|
|
7
|
+
data.tar.gz: 446402026e834fcb47a077a64db9f5cee4442e07056700b5770bfe98332c7560799228d25fb88a633f919c2fdb12965fba1423fd4b24a2e208476ad8ad8d258a
|
data/README.md
CHANGED
|
@@ -150,6 +150,44 @@ Live conformance tests hit the real API and are skipped unless a key is present:
|
|
|
150
150
|
$ API2CONVERT_API_KEY=<your key> bundle exec rake spec:live
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
+
Each guide has a runnable, self-contained example under [`examples/`](examples/),
|
|
154
|
+
and the [live conformance suite](spec/live/conformance_spec.rb) mirrors every one
|
|
155
|
+
of them (same operation, plus assertions) so a published version is always
|
|
156
|
+
verified end to end. It runs automatically against the real API on every release
|
|
157
|
+
tag (see `.github/workflows/live-conformance.yml`).
|
|
158
|
+
|
|
159
|
+
| # | Example | What it shows |
|
|
160
|
+
|---|---------|---------------|
|
|
161
|
+
| 1 | [`quickstart.rb`](examples/quickstart.rb) | Convert a remote URL, fetch the job, download the output |
|
|
162
|
+
| 2 | [`convert_files.rb`](examples/convert_files.rb) | Browse the conversions catalog, then convert |
|
|
163
|
+
| 3 | [`uploading_files.rb`](examples/uploading_files.rb) | One-call upload + convert of a local file |
|
|
164
|
+
| 4 | [`job_lifecycle.rb`](examples/job_lifecycle.rb) | Drive create → add input → start → wait → outputs by hand |
|
|
165
|
+
| 5 | [`add_watermark.rb`](examples/add_watermark.rb) | Stamp a PDF with an image (two remote inputs) |
|
|
166
|
+
| 6 | [`create_thumbnails.rb`](examples/create_thumbnails.rb) | Render a thumbnail of the first PDF page |
|
|
167
|
+
| 7 | [`compress_files.rb`](examples/compress_files.rb) | Compress an image with the compress operation |
|
|
168
|
+
| 8 | [`create_archives.rb`](examples/create_archives.rb) | Bundle remote files into a ZIP |
|
|
169
|
+
| 9 | [`create_hashes.rb`](examples/create_hashes.rb) | Compute a file's SHA-256 checksum |
|
|
170
|
+
| 10 | [`extract_assets.rb`](examples/extract_assets.rb) | Extract embedded assets from a document |
|
|
171
|
+
| 11 | [`file_analysis.rb`](examples/file_analysis.rb) | Extract file metadata as JSON |
|
|
172
|
+
| 12 | [`compare_files.rb`](examples/compare_files.rb) | Diff two images with compare-image |
|
|
173
|
+
| 13 | [`capture_website.rb`](examples/capture_website.rb) | Screenshot a page with the screenshot engine |
|
|
174
|
+
| 14 | [`audio_operations.rb`](examples/audio_operations.rb) | Re-encode audio to AAC |
|
|
175
|
+
| 15 | [`image_operations.rb`](examples/image_operations.rb) | Resize an image |
|
|
176
|
+
| 16 | [`webhooks.rb`](examples/webhooks.rb) | Start an async job with a callback URL |
|
|
177
|
+
| 17 | [`presets.rb`](examples/presets.rb) | List saved conversion presets |
|
|
178
|
+
| 18 | [`statistics.rb`](examples/statistics.rb) | Read monthly API usage |
|
|
179
|
+
| 19 | [`rate-limits.rb`](examples/rate-limits.rb) | Inspect the account's contracts |
|
|
180
|
+
| 20 | [`authentication.rb`](examples/authentication.rb) | Verify the API key by listing jobs |
|
|
181
|
+
|
|
182
|
+
A companion [`webhook.rb`](examples/webhook.rb) is a tiny Rack receiver that
|
|
183
|
+
verifies the callback signature — the other side of example 16.
|
|
184
|
+
|
|
185
|
+
Run any example with your key in the environment:
|
|
186
|
+
|
|
187
|
+
```console
|
|
188
|
+
$ API2CONVERT_API_KEY=<your key> ruby -Ilib examples/quickstart.rb
|
|
189
|
+
```
|
|
190
|
+
|
|
153
191
|
If your machine's Ruby is older than the gem targets, run the guardrail on a
|
|
154
192
|
supported Ruby with the bundled `Dockerfile`:
|
|
155
193
|
|
data/docs/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,8 @@ All notable changes to the API2Convert Ruby SDK are documented here. The five
|
|
|
4
4
|
official SDKs (PHP, Python, Java, Node.js, Ruby) version together against the
|
|
5
5
|
shared [`SDK_CONTRACT.md`](SDK_CONTRACT.md).
|
|
6
6
|
|
|
7
|
-
## [
|
|
7
|
+
## [10.2.1] - 2026-07-08
|
|
8
8
|
|
|
9
|
-
-
|
|
9
|
+
- Lock-step version bump to keep all API2Convert SDKs on 10.2.1. No library changes since 10.2.0
|
|
10
|
+
(the redirect / download-password hardening already shipped); added a runnable example per
|
|
11
|
+
documented guide and expanded the live-conformance suite to seven canonical scenarios.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Add a Watermark — stamp a PDF with an image using two remote inputs.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/add_watermark.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
PDF = "https://example-files.online-convert.com/document/pdf/example.pdf"
|
|
10
|
+
PNG = "https://example-files.online-convert.com/raster%20image/png/example.png"
|
|
11
|
+
|
|
12
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
13
|
+
|
|
14
|
+
# Create a job with two inputs (the document and the stamp image) and start it.
|
|
15
|
+
job = client.jobs.create(
|
|
16
|
+
{
|
|
17
|
+
"process" => true,
|
|
18
|
+
"input" => [
|
|
19
|
+
{ "type" => "remote", "source" => PDF },
|
|
20
|
+
{ "type" => "remote", "source" => PNG }
|
|
21
|
+
],
|
|
22
|
+
"conversion" => [
|
|
23
|
+
{
|
|
24
|
+
"category" => "document",
|
|
25
|
+
"target" => "pdf",
|
|
26
|
+
"options" => { "stamp" => true, "alignment" => "center" }
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
done = client.jobs.wait(job.id)
|
|
33
|
+
puts "job #{done.id} is #{done.status.code}"
|
|
34
|
+
|
|
35
|
+
outputs = client.jobs.outputs(job.id)
|
|
36
|
+
outputs.each { |output| puts output.uri }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Audio Operations — re-encode a WAV to AAC with explicit codec settings.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/audio_operations.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
WAV = "https://example-files.online-convert.com/audio/wav/example.wav"
|
|
10
|
+
|
|
11
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
12
|
+
|
|
13
|
+
result = client.convert(
|
|
14
|
+
WAV,
|
|
15
|
+
"aac",
|
|
16
|
+
{ "audio_codec" => "aac", "audio_bitrate" => 192, "channels" => "stereo", "frequency" => 44_100 },
|
|
17
|
+
category: "audio"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
path = result.save("output/")
|
|
21
|
+
puts "saved #{path} (#{File.size(path)} bytes)"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Authentication — verify your API key by listing your jobs.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/authentication.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
10
|
+
|
|
11
|
+
# A successful, authenticated call returns your jobs (empty on a fresh account).
|
|
12
|
+
jobs = client.jobs.list
|
|
13
|
+
puts "authenticated: #{jobs.length} job(s) visible"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Capture a Website — screenshot a page with the screenshot engine.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/capture_website.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
10
|
+
|
|
11
|
+
job = client.jobs.create(
|
|
12
|
+
{
|
|
13
|
+
"process" => true,
|
|
14
|
+
"input" => [
|
|
15
|
+
{
|
|
16
|
+
"type" => "remote",
|
|
17
|
+
"source" => "https://www.online-convert.com",
|
|
18
|
+
"engine" => "screenshot",
|
|
19
|
+
"options" => { "screen_width" => 1280, "screen_height" => 1024, "device_scale_factor" => 1 }
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"conversion" => [{ "category" => "image", "target" => "png" }]
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
done = client.jobs.wait(job.id)
|
|
27
|
+
puts "job #{done.id} is #{done.status.code}"
|
|
28
|
+
|
|
29
|
+
client.jobs.outputs(job.id).each { |output| puts output.uri }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Compare Files — diff two images with the compare-image operation.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/compare_files.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
JPG_SMALL = "https://example-files.online-convert.com/raster%20image/jpg/example_small.jpg"
|
|
10
|
+
JPG = "https://example-files.online-convert.com/raster%20image/jpg/example.jpg"
|
|
11
|
+
|
|
12
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
13
|
+
|
|
14
|
+
job = client.jobs.create(
|
|
15
|
+
{
|
|
16
|
+
"process" => true,
|
|
17
|
+
"input" => [
|
|
18
|
+
{ "type" => "remote", "source" => JPG_SMALL },
|
|
19
|
+
{ "type" => "remote", "source" => JPG }
|
|
20
|
+
],
|
|
21
|
+
"conversion" => [
|
|
22
|
+
{
|
|
23
|
+
"category" => "operation",
|
|
24
|
+
"target" => "compare-image",
|
|
25
|
+
"options" => { "method" => "ssim", "threshold" => 5, "diff_color" => "red" }
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
done = client.jobs.wait(job.id)
|
|
32
|
+
puts "job #{done.id} is #{done.status.code}"
|
|
33
|
+
|
|
34
|
+
client.jobs.outputs(job.id).each { |output| puts output.uri }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Compress Files — shrink an image with the compress operation.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/compress_files.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
JPG = "https://example-files.online-convert.com/raster%20image/jpg/example.jpg"
|
|
10
|
+
|
|
11
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
12
|
+
|
|
13
|
+
result = client.convert(
|
|
14
|
+
JPG, "compress", { "compression_level" => "high" }, category: "operation"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
path = result.save("output/")
|
|
18
|
+
puts "saved #{path} (#{File.size(path)} bytes)"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Convert Files — browse the conversions catalog, then convert.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/convert_files.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
JPG = "https://example-files.online-convert.com/raster%20image/jpg/example.jpg"
|
|
10
|
+
|
|
11
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
12
|
+
|
|
13
|
+
# The whole catalog: every supported target and its options.
|
|
14
|
+
all = client.conversions.list
|
|
15
|
+
puts "#{all.length} conversions available"
|
|
16
|
+
|
|
17
|
+
# Narrow it down: which conversions produce a PNG image?
|
|
18
|
+
png = client.conversions.list("image", "png")
|
|
19
|
+
puts "#{png.length} way(s) to produce png"
|
|
20
|
+
|
|
21
|
+
# Now convert a JPG to PNG.
|
|
22
|
+
result = client.convert(JPG, "png", category: "image")
|
|
23
|
+
path = result.save("convert-files-output.png")
|
|
24
|
+
puts "saved #{path} (#{File.size(path)} bytes)"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Create Archives — bundle several remote files into a single ZIP.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/create_archives.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
PDF = "https://example-files.online-convert.com/document/pdf/example.pdf"
|
|
10
|
+
PNG = "https://example-files.online-convert.com/raster%20image/png/example.png"
|
|
11
|
+
|
|
12
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
13
|
+
|
|
14
|
+
job = client.jobs.create(
|
|
15
|
+
{
|
|
16
|
+
"process" => true,
|
|
17
|
+
"input" => [
|
|
18
|
+
{ "type" => "remote", "source" => PDF },
|
|
19
|
+
{ "type" => "remote", "source" => PNG }
|
|
20
|
+
],
|
|
21
|
+
"conversion" => [{ "category" => "archive", "target" => "zip" }]
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
done = client.jobs.wait(job.id)
|
|
26
|
+
puts "job #{done.id} is #{done.status.code}"
|
|
27
|
+
|
|
28
|
+
outputs = client.jobs.outputs(job.id)
|
|
29
|
+
outputs.each { |output| puts output.uri }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Create Hashes — compute the SHA-256 checksum of a remote file.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/create_hashes.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
ZIP = "https://example-files.online-convert.com/archive/zip/example.zip"
|
|
10
|
+
|
|
11
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
12
|
+
|
|
13
|
+
result = client.convert(ZIP, "sha256", category: "hash")
|
|
14
|
+
|
|
15
|
+
# The hash is returned as the output file's contents.
|
|
16
|
+
puts "sha256: #{result.contents}"
|
|
17
|
+
|
|
18
|
+
path = result.save("output/")
|
|
19
|
+
puts "saved #{path} (#{File.size(path)} bytes)"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Create Thumbnails — render a thumbnail of the first PDF page.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/create_thumbnails.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
PDF = "https://example-files.online-convert.com/document/pdf/example.pdf"
|
|
10
|
+
|
|
11
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
12
|
+
|
|
13
|
+
result = client.convert(
|
|
14
|
+
PDF,
|
|
15
|
+
"thumbnail",
|
|
16
|
+
{ "thumbnail_target" => "png", "width" => 300, "pages" => "first", "dpi" => 150 },
|
|
17
|
+
category: "operation"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# Save into a directory so the API-provided filename is kept.
|
|
21
|
+
path = result.save("output/")
|
|
22
|
+
puts "saved #{path} (#{File.size(path)} bytes)"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Extract Assets — pull the embedded assets out of a document.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/extract_assets.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
DOCX = "https://example-files.online-convert.com/document/docx/example.docx"
|
|
10
|
+
|
|
11
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
12
|
+
|
|
13
|
+
result = client.convert(DOCX, "extract-assets", category: "operation")
|
|
14
|
+
puts "job #{result.job.id} is #{result.job.status.code}"
|
|
15
|
+
|
|
16
|
+
result.outputs.each { |output| puts output.uri }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# File Analysis — extract a file's metadata as JSON.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/file_analysis.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
JPG = "https://example-files.online-convert.com/raster%20image/jpg/example.jpg"
|
|
10
|
+
|
|
11
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
12
|
+
|
|
13
|
+
result = client.convert(JPG, "json", category: "metadata")
|
|
14
|
+
puts "job #{result.job.id} is #{result.job.status.code}"
|
|
15
|
+
|
|
16
|
+
# The analysis result is the output file's JSON body.
|
|
17
|
+
puts result.contents
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Image Operations — resize an image with the resize-image operation.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/image_operations.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
JPG = "https://example-files.online-convert.com/raster%20image/jpg/example.jpg"
|
|
10
|
+
|
|
11
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
12
|
+
|
|
13
|
+
result = client.convert(
|
|
14
|
+
JPG,
|
|
15
|
+
"resize-image",
|
|
16
|
+
{ "width" => 800, "height" => 600, "resize_by" => "px", "resize_handling" => "keep_aspect_ratio_crop" },
|
|
17
|
+
category: "operation"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
path = result.save("output/")
|
|
21
|
+
puts "saved #{path} (#{File.size(path)} bytes)"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Job Lifecycle — drive create -> add input -> start -> wait -> outputs by hand.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/job_lifecycle.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
JPG = "https://example-files.online-convert.com/raster%20image/jpg/example.jpg"
|
|
10
|
+
|
|
11
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
12
|
+
|
|
13
|
+
# Stage a job (process: false) so we can attach inputs before starting.
|
|
14
|
+
job = client.jobs.create(
|
|
15
|
+
{ "process" => false, "conversion" => [{ "category" => "image", "target" => "png" }] }
|
|
16
|
+
)
|
|
17
|
+
puts "created job #{job.id}"
|
|
18
|
+
|
|
19
|
+
# Attach a remote input, then start processing.
|
|
20
|
+
client.jobs.add_input(job.id, { "type" => "remote", "source" => JPG })
|
|
21
|
+
client.jobs.start(job.id)
|
|
22
|
+
|
|
23
|
+
# Poll to a terminal status (raises on a failed job by default).
|
|
24
|
+
done = client.jobs.wait(job.id)
|
|
25
|
+
puts "job #{done.id} is #{done.status.code}"
|
|
26
|
+
|
|
27
|
+
# List the produced outputs.
|
|
28
|
+
outputs = client.jobs.outputs(job.id)
|
|
29
|
+
outputs.each { |output| puts output.uri }
|
data/examples/presets.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Presets — list your saved conversion presets.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/presets.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
10
|
+
|
|
11
|
+
presets = client.presets.list(category: "video", target: "mp4")
|
|
12
|
+
puts "#{presets.length} preset(s)"
|
|
13
|
+
|
|
14
|
+
presets.each { |preset| puts "#{preset.id}: #{preset.name} -> #{preset.target}" }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Quickstart — convert a remote file, inspect the job, download the result.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/quickstart.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
JPG = "https://example-files.online-convert.com/raster%20image/jpg/example.jpg"
|
|
10
|
+
|
|
11
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
12
|
+
|
|
13
|
+
# One-call convert of a remote URL (create -> poll -> ready to download).
|
|
14
|
+
result = client.convert(JPG, "png", category: "image")
|
|
15
|
+
|
|
16
|
+
# Fetch the finished job by id and print its status.
|
|
17
|
+
job = client.jobs.get(result.job.id)
|
|
18
|
+
puts "job #{job.id} is #{job.status.code}"
|
|
19
|
+
|
|
20
|
+
# Download the produced output.
|
|
21
|
+
path = result.save("quickstart-output.png")
|
|
22
|
+
puts "saved #{path} (#{File.size(path)} bytes)"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Rate Limits — inspect your account's contracts (quotas and limits).
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/rate_limits.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
10
|
+
|
|
11
|
+
contracts = client.contracts.get
|
|
12
|
+
puts contracts.inspect
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Statistics — read your API usage for a given month.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/statistics.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
|
|
9
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
10
|
+
|
|
11
|
+
stats = client.stats.month("2026-06")
|
|
12
|
+
puts stats.inspect
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Uploading Files — convert a local file in one call (convert() uploads it).
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/uploading_files.rb
|
|
6
|
+
|
|
7
|
+
require "api2convert"
|
|
8
|
+
require "base64"
|
|
9
|
+
require "tmpdir"
|
|
10
|
+
|
|
11
|
+
# A minimal valid 1x1 PNG so the example needs no binary fixture on disk.
|
|
12
|
+
ONE_PX_PNG = Base64.decode64(
|
|
13
|
+
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
17
|
+
|
|
18
|
+
Dir.mktmpdir("a2c-upload") do |dir|
|
|
19
|
+
source = File.join(dir, "pixel.png")
|
|
20
|
+
File.binwrite(source, ONE_PX_PNG)
|
|
21
|
+
|
|
22
|
+
# Hand convert() a local path — it stages the job, uploads the file to the
|
|
23
|
+
# per-job upload server, starts it and polls to completion.
|
|
24
|
+
result = client.convert(source, "png", category: "image")
|
|
25
|
+
path = result.save("uploading-files-output.png")
|
|
26
|
+
puts "saved #{path} (#{File.size(path)} bytes)"
|
|
27
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Webhooks — start a conversion and be notified via a callback URL.
|
|
4
|
+
#
|
|
5
|
+
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/webhooks.rb
|
|
6
|
+
#
|
|
7
|
+
# convert_async returns immediately with a started job; the API POSTs to your
|
|
8
|
+
# callback when it finishes. See examples/webhook.rb for a receiver that verifies
|
|
9
|
+
# the callback signature.
|
|
10
|
+
|
|
11
|
+
require "api2convert"
|
|
12
|
+
|
|
13
|
+
DOCX = "https://example-files.online-convert.com/document/docx/example.docx"
|
|
14
|
+
|
|
15
|
+
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
16
|
+
|
|
17
|
+
job = client.convert_async(
|
|
18
|
+
DOCX, "pdf",
|
|
19
|
+
callback: "https://your-app.example.com/api2convert/webhook",
|
|
20
|
+
category: "document"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
puts "started job #{job.id} (#{job.status.code})"
|
|
24
|
+
puts "the API will POST to the callback URL when it completes"
|
data/lib/api2convert/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: api2convert
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 10.2.
|
|
4
|
+
version: 10.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Qaamgo Media GmbH
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-07-
|
|
11
|
+
date: 2026-07-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Convert, compress and transform images, documents, audio, video, ebooks,
|
|
14
14
|
archives and CAD — and run operations like OCR, merge, thumbnail and website capture
|
|
@@ -23,8 +23,27 @@ files:
|
|
|
23
23
|
- README.md
|
|
24
24
|
- docs/CHANGELOG.md
|
|
25
25
|
- docs/SDK_CONTRACT.md
|
|
26
|
-
- examples/
|
|
26
|
+
- examples/add_watermark.rb
|
|
27
|
+
- examples/audio_operations.rb
|
|
28
|
+
- examples/authentication.rb
|
|
29
|
+
- examples/capture_website.rb
|
|
30
|
+
- examples/compare_files.rb
|
|
31
|
+
- examples/compress_files.rb
|
|
32
|
+
- examples/convert_files.rb
|
|
33
|
+
- examples/create_archives.rb
|
|
34
|
+
- examples/create_hashes.rb
|
|
35
|
+
- examples/create_thumbnails.rb
|
|
36
|
+
- examples/extract_assets.rb
|
|
37
|
+
- examples/file_analysis.rb
|
|
38
|
+
- examples/image_operations.rb
|
|
39
|
+
- examples/job_lifecycle.rb
|
|
40
|
+
- examples/presets.rb
|
|
41
|
+
- examples/quickstart.rb
|
|
42
|
+
- examples/rate_limits.rb
|
|
43
|
+
- examples/statistics.rb
|
|
44
|
+
- examples/uploading_files.rb
|
|
27
45
|
- examples/webhook.rb
|
|
46
|
+
- examples/webhooks.rb
|
|
28
47
|
- lib/api2convert.rb
|
|
29
48
|
- lib/api2convert/client.rb
|
|
30
49
|
- lib/api2convert/config.rb
|
data/examples/convert.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Minimal synchronous conversion example.
|
|
4
|
-
#
|
|
5
|
-
# API2CONVERT_API_KEY=<your key> ruby -Ilib examples/convert.rb path/to/photo.png jpg out.jpg
|
|
6
|
-
#
|
|
7
|
-
# Falls back to converting a public sample image when no source is given.
|
|
8
|
-
|
|
9
|
-
require "api2convert"
|
|
10
|
-
|
|
11
|
-
source = ARGV[0] || "https://example-files.online-convert.com/raster%20image/jpg/example.jpg"
|
|
12
|
-
target = ARGV[1] || "png"
|
|
13
|
-
destination = ARGV[2] || "output.#{target}"
|
|
14
|
-
|
|
15
|
-
client = Api2Convert::Client.new # reads API2CONVERT_API_KEY
|
|
16
|
-
|
|
17
|
-
result = client.convert(source, target)
|
|
18
|
-
path = result.save(destination)
|
|
19
|
-
|
|
20
|
-
puts "Converted #{source} -> #{path} (#{File.size(path)} bytes)"
|