firecrawl-sdk 1.3.1 → 1.4.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.
- checksums.yaml +4 -4
- data/lib/firecrawl/client.rb +98 -0
- data/lib/firecrawl/http_client.rb +10 -0
- data/lib/firecrawl/models/monitor.rb +68 -0
- data/lib/firecrawl/version.rb +1 -1
- data/lib/firecrawl.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60a3360b0facad41a4d3c0a1a94e520f675ce5b6f72487665ead37f1b988de50
|
|
4
|
+
data.tar.gz: 51ced5462346c81d02327786e5022cd5789fed14940346e231c8619eb5b686b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e7a56e1fc2bd3b56b88337047f7c655c7ac78e6d43de94f4ee89c9b67701be95b45232d17ce6383023bd3d59199388012257c32d36c10c61823b02f5574f931
|
|
7
|
+
data.tar.gz: f2be762f47550bfa3bda7e7d8e7833b404b30d5447558893bc36ffe5de13953cc02bc00efe09d51f91eec9c1715701275e50336d154d2c47f4d5121a424aeb87
|
data/lib/firecrawl/client.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
|
+
require "uri"
|
|
4
5
|
|
|
5
6
|
module Firecrawl
|
|
6
7
|
# Client for the Firecrawl v2 API.
|
|
@@ -280,6 +281,83 @@ module Firecrawl
|
|
|
280
281
|
Models::MapData.new(data)
|
|
281
282
|
end
|
|
282
283
|
|
|
284
|
+
# ================================================================
|
|
285
|
+
# MONITOR
|
|
286
|
+
# ================================================================
|
|
287
|
+
|
|
288
|
+
def create_monitor(name:, schedule:, targets:, webhook: nil, notification: nil, retention_days: nil)
|
|
289
|
+
body = {
|
|
290
|
+
"name" => name,
|
|
291
|
+
"schedule" => schedule,
|
|
292
|
+
"targets" => targets,
|
|
293
|
+
"webhook" => webhook,
|
|
294
|
+
"notification" => notification,
|
|
295
|
+
"retentionDays" => retention_days,
|
|
296
|
+
}.compact
|
|
297
|
+
raw = @http.post("/v2/monitor", body)
|
|
298
|
+
Models::Monitor.new(raw["data"] || raw)
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
def list_monitors(limit: nil, offset: nil)
|
|
302
|
+
raw = @http.get("/v2/monitor#{query(limit: limit, offset: offset)}")
|
|
303
|
+
(raw["data"] || []).map { |item| Models::Monitor.new(item) }
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def get_monitor(monitor_id)
|
|
307
|
+
raise ArgumentError, "Monitor ID is required" if monitor_id.nil?
|
|
308
|
+
|
|
309
|
+
raw = @http.get("/v2/monitor/#{monitor_id}")
|
|
310
|
+
Models::Monitor.new(raw["data"] || raw)
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
def update_monitor(monitor_id, **attrs)
|
|
314
|
+
raise ArgumentError, "Monitor ID is required" if monitor_id.nil?
|
|
315
|
+
|
|
316
|
+
body = {
|
|
317
|
+
"name" => attrs[:name],
|
|
318
|
+
"status" => attrs[:status],
|
|
319
|
+
"schedule" => attrs[:schedule],
|
|
320
|
+
"webhook" => attrs[:webhook],
|
|
321
|
+
"notification" => attrs[:notification],
|
|
322
|
+
"targets" => attrs[:targets],
|
|
323
|
+
"retentionDays" => attrs[:retention_days],
|
|
324
|
+
}.compact
|
|
325
|
+
raw = @http.patch("/v2/monitor/#{monitor_id}", body)
|
|
326
|
+
Models::Monitor.new(raw["data"] || raw)
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def delete_monitor(monitor_id)
|
|
330
|
+
raise ArgumentError, "Monitor ID is required" if monitor_id.nil?
|
|
331
|
+
|
|
332
|
+
@http.delete("/v2/monitor/#{monitor_id}")["success"] == true
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def run_monitor(monitor_id)
|
|
336
|
+
raise ArgumentError, "Monitor ID is required" if monitor_id.nil?
|
|
337
|
+
|
|
338
|
+
raw = @http.post("/v2/monitor/#{monitor_id}/run", {})
|
|
339
|
+
Models::MonitorCheck.new(raw["data"] || raw)
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def list_monitor_checks(monitor_id, limit: nil, offset: nil)
|
|
343
|
+
raise ArgumentError, "Monitor ID is required" if monitor_id.nil?
|
|
344
|
+
|
|
345
|
+
raw = @http.get("/v2/monitor/#{monitor_id}/checks#{query(limit: limit, offset: offset)}")
|
|
346
|
+
(raw["data"] || []).map { |item| Models::MonitorCheck.new(item) }
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
def get_monitor_check(monitor_id, check_id, limit: nil, skip: nil, status: nil, auto_paginate: true)
|
|
350
|
+
raise ArgumentError, "Monitor ID is required" if monitor_id.nil?
|
|
351
|
+
raise ArgumentError, "Check ID is required" if check_id.nil?
|
|
352
|
+
|
|
353
|
+
params = query(limit: limit, skip: skip, status: status)
|
|
354
|
+
raw = @http.get("/v2/monitor/#{monitor_id}/checks/#{check_id}#{params}")
|
|
355
|
+
data = raw["data"] || raw
|
|
356
|
+
data["next"] = raw["next"] if raw["next"]
|
|
357
|
+
check = Models::MonitorCheckDetail.new(data)
|
|
358
|
+
auto_paginate ? paginate_monitor_check(check) : check
|
|
359
|
+
end
|
|
360
|
+
|
|
283
361
|
# ================================================================
|
|
284
362
|
# SEARCH
|
|
285
363
|
# ================================================================
|
|
@@ -378,6 +456,11 @@ module Firecrawl
|
|
|
378
456
|
|
|
379
457
|
private
|
|
380
458
|
|
|
459
|
+
def query(**params)
|
|
460
|
+
compact = params.compact
|
|
461
|
+
compact.empty? ? "" : "?#{URI.encode_www_form(compact)}"
|
|
462
|
+
end
|
|
463
|
+
|
|
381
464
|
def poll_crawl(job_id, poll_interval, timeout)
|
|
382
465
|
deadline = Time.now + timeout
|
|
383
466
|
while Time.now < deadline
|
|
@@ -423,5 +506,20 @@ module Firecrawl
|
|
|
423
506
|
end
|
|
424
507
|
job
|
|
425
508
|
end
|
|
509
|
+
|
|
510
|
+
def paginate_monitor_check(check)
|
|
511
|
+
check.pages ||= []
|
|
512
|
+
current = check
|
|
513
|
+
while current.next_url && !current.next_url.empty?
|
|
514
|
+
raw = @http.get_absolute(current.next_url)
|
|
515
|
+
data = raw["data"] || raw
|
|
516
|
+
data["next"] = raw["next"] if raw["next"]
|
|
517
|
+
next_page = Models::MonitorCheckDetail.new(data)
|
|
518
|
+
check.pages.concat(next_page.pages) unless next_page.pages.empty?
|
|
519
|
+
current = next_page
|
|
520
|
+
end
|
|
521
|
+
check.next_url = nil
|
|
522
|
+
check
|
|
523
|
+
end
|
|
426
524
|
end
|
|
427
525
|
end
|
|
@@ -59,6 +59,16 @@ module Firecrawl
|
|
|
59
59
|
execute_with_retry(uri, request)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
# Sends a PATCH request with JSON body.
|
|
63
|
+
def patch(path, body)
|
|
64
|
+
uri = URI("#{@base_url}#{path}")
|
|
65
|
+
request = Net::HTTP::Patch.new(uri)
|
|
66
|
+
request["Authorization"] = "Bearer #{@api_key}"
|
|
67
|
+
request["Content-Type"] = "application/json"
|
|
68
|
+
request.body = JSON.generate(body)
|
|
69
|
+
execute_with_retry(uri, request)
|
|
70
|
+
end
|
|
71
|
+
|
|
62
72
|
# Sends a POST request with a multipart/form-data body.
|
|
63
73
|
#
|
|
64
74
|
# @param path [String] API path
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Firecrawl
|
|
4
|
+
module Models
|
|
5
|
+
class Monitor
|
|
6
|
+
attr_reader :id, :name, :status, :schedule, :next_run_at, :last_run_at,
|
|
7
|
+
:current_check_id, :targets, :webhook, :notification,
|
|
8
|
+
:retention_days, :estimated_credits_per_month,
|
|
9
|
+
:last_check_summary, :created_at, :updated_at
|
|
10
|
+
|
|
11
|
+
def initialize(data)
|
|
12
|
+
@id = data["id"]
|
|
13
|
+
@name = data["name"]
|
|
14
|
+
@status = data["status"]
|
|
15
|
+
@schedule = data["schedule"]
|
|
16
|
+
@next_run_at = data["nextRunAt"]
|
|
17
|
+
@last_run_at = data["lastRunAt"]
|
|
18
|
+
@current_check_id = data["currentCheckId"]
|
|
19
|
+
@targets = data["targets"] || []
|
|
20
|
+
@webhook = data["webhook"]
|
|
21
|
+
@notification = data["notification"]
|
|
22
|
+
@retention_days = data["retentionDays"]
|
|
23
|
+
@estimated_credits_per_month = data["estimatedCreditsPerMonth"]
|
|
24
|
+
@last_check_summary = data["lastCheckSummary"]
|
|
25
|
+
@created_at = data["createdAt"]
|
|
26
|
+
@updated_at = data["updatedAt"]
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class MonitorCheck
|
|
31
|
+
attr_reader :id, :monitor_id, :status, :trigger, :scheduled_for,
|
|
32
|
+
:started_at, :finished_at, :estimated_credits,
|
|
33
|
+
:reserved_credits, :actual_credits, :billing_status,
|
|
34
|
+
:summary, :target_results, :notification_status, :error,
|
|
35
|
+
:created_at, :updated_at
|
|
36
|
+
|
|
37
|
+
def initialize(data)
|
|
38
|
+
@id = data["id"]
|
|
39
|
+
@monitor_id = data["monitorId"]
|
|
40
|
+
@status = data["status"]
|
|
41
|
+
@trigger = data["trigger"]
|
|
42
|
+
@scheduled_for = data["scheduledFor"]
|
|
43
|
+
@started_at = data["startedAt"]
|
|
44
|
+
@finished_at = data["finishedAt"]
|
|
45
|
+
@estimated_credits = data["estimatedCredits"]
|
|
46
|
+
@reserved_credits = data["reservedCredits"]
|
|
47
|
+
@actual_credits = data["actualCredits"]
|
|
48
|
+
@billing_status = data["billingStatus"]
|
|
49
|
+
@summary = data["summary"] || {}
|
|
50
|
+
@target_results = data["targetResults"]
|
|
51
|
+
@notification_status = data["notificationStatus"]
|
|
52
|
+
@error = data["error"]
|
|
53
|
+
@created_at = data["createdAt"]
|
|
54
|
+
@updated_at = data["updatedAt"]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
class MonitorCheckDetail < MonitorCheck
|
|
59
|
+
attr_accessor :pages, :next_url
|
|
60
|
+
|
|
61
|
+
def initialize(data)
|
|
62
|
+
super
|
|
63
|
+
@pages = data["pages"] || []
|
|
64
|
+
@next_url = data["next"]
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
data/lib/firecrawl/version.rb
CHANGED
data/lib/firecrawl.rb
CHANGED
|
@@ -23,4 +23,5 @@ require_relative "firecrawl/models/agent_response"
|
|
|
23
23
|
require_relative "firecrawl/models/agent_status_response"
|
|
24
24
|
require_relative "firecrawl/models/concurrency_check"
|
|
25
25
|
require_relative "firecrawl/models/credit_usage"
|
|
26
|
+
require_relative "firecrawl/models/monitor"
|
|
26
27
|
require_relative "firecrawl/client"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: firecrawl-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Firecrawl
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A type-safe Ruby client for the Firecrawl v2 API. Supports scraping,
|
|
14
14
|
crawling, batch scraping, URL mapping, web search, and AI agent operations.
|
|
@@ -38,6 +38,7 @@ files:
|
|
|
38
38
|
- lib/firecrawl/models/document.rb
|
|
39
39
|
- lib/firecrawl/models/map_data.rb
|
|
40
40
|
- lib/firecrawl/models/map_options.rb
|
|
41
|
+
- lib/firecrawl/models/monitor.rb
|
|
41
42
|
- lib/firecrawl/models/parse_file.rb
|
|
42
43
|
- lib/firecrawl/models/parse_options.rb
|
|
43
44
|
- lib/firecrawl/models/query_format.rb
|