crw-server 0.13.4

Firecrawl-compatible API server for the CRW web scraper
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
{
  "openapi": "3.1.0",
  "info": {
    "title": "CRW REST API",
    "version": "0.10.0",
    "description": "Firecrawl-compatible web scraping, crawling, mapping, search, and extraction API. Hosted at https://api.fastcrw.com; self-host with `docker run -p 3000:3000 ghcr.io/us/crw:latest`.",
    "license": {
      "name": "AGPL-3.0",
      "url": "https://opensource.org/licenses/AGPL-3.0"
    },
    "contact": {
      "url": "https://github.com/us/crw"
    }
  },
  "servers": [
    {
      "url": "https://api.fastcrw.com",
      "description": "Hosted (requires Bearer token)"
    },
    {
      "url": "http://localhost:3000",
      "description": "Self-hosted (no auth by default)"
    }
  ],
  "security": [
    { "bearerAuth": [] },
    {}
  ],
  "tags": [
    { "name": "search", "description": "Web search via SearXNG (self-hosted) or managed (hosted)" },
    { "name": "scrape",  "description": "Single-URL content extraction" },
    { "name": "crawl",   "description": "Async multi-page crawl jobs" },
    { "name": "map",     "description": "URL discovery without full scraping" },
    { "name": "extract", "description": "Structured JSON extraction via scrape + jsonOptions" },
    { "name": "change-tracking", "description": "Stateless diff of a scrape against a caller-supplied previous snapshot (monitor primitive)" }
  ],
  "paths": {
    "/v1/search": {
      "post": {
        "tags": ["search"],
        "summary": "Search the web and optionally scrape results",
        "operationId": "search",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/SearchRequest" },
              "examples": {
                "minimal": {
                  "summary": "Top 3 results, no scraping",
                  "value": { "query": "renewable energy trends 2024", "limit": 3 }
                },
                "with_scrape": {
                  "summary": "Scrape each result as markdown",
                  "value": {
                    "query": "rust async runtime",
                    "limit": 5,
                    "scrapeOptions": { "formats": ["markdown"], "onlyMainContent": true }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Search results",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SearchResponse" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "429": { "$ref": "#/components/responses/RateLimited" },
          "503": { "$ref": "#/components/responses/SearchDisabled" }
        }
      }
    },
    "/v1/scrape": {
      "post": {
        "tags": ["scrape"],
        "summary": "Scrape one URL",
        "operationId": "scrape",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ScrapeRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scrape result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ScrapeResponse" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/v1/map": {
      "post": {
        "tags": ["map"],
        "summary": "Discover URLs on a site",
        "operationId": "map",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/MapRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "List of URLs",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/MapResponse" }
              }
            }
          }
        }
      }
    },
    "/v1/crawl": {
      "post": {
        "tags": ["crawl"],
        "summary": "Start an async crawl job",
        "operationId": "crawlStart",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CrawlRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Crawl job accepted; poll with /v1/crawl/{id}",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CrawlAccepted" }
              }
            }
          }
        }
      }
    },
    "/v1/crawl/{id}": {
      "get": {
        "tags": ["crawl"],
        "summary": "Get crawl job status and results",
        "operationId": "crawlStatus",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "Crawl job id returned by POST /v1/crawl"
          }
        ],
        "responses": {
          "200": {
            "description": "Job status + collected pages",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CrawlStatus" }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/v1/change-tracking/diff": {
      "post": {
        "tags": ["change-tracking"],
        "summary": "Diff current scrape content against a previous snapshot",
        "description": "Stateless: opencore stores nothing — the caller supplies the `previous` snapshot. Accepts a single body or a `batch` array (presence of `batch` selects batch mode). The crawl-path workhorse for monitors.",
        "operationId": "changeTrackingDiff",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChangeTrackingDiffRequest" },
              "examples": {
                "single_gitdiff": {
                  "summary": "Single page, markdown git-diff",
                  "value": {
                    "modes": ["gitDiff"],
                    "previous": { "markdown": "Starter $19", "contentHash": "abc" },
                    "current": { "markdown": "Starter $24" }
                  }
                },
                "batch_json": {
                  "summary": "Batch, json per-field mode",
                  "value": {
                    "modes": ["json"],
                    "batch": [
                      { "url": "https://example.com/pricing", "previous": { "json": { "price": "$19" }, "contentHash": "abc" }, "current": { "json": { "price": "$24" } } }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Diff result (object for single, array for batch) wrapped in the standard envelope",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success", "data"],
                  "properties": {
                    "success": { "type": "boolean" },
                    "data": {
                      "oneOf": [
                        { "$ref": "#/components/schemas/ChangeTrackingResult" },
                        { "type": "array", "items": { "$ref": "#/components/schemas/ChangeTrackingResult" } }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/v1/extract": {
      "post": {
        "tags": ["extract"],
        "summary": "Structured JSON extraction (alias for scrape + formats:[json])",
        "operationId": "extract",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ExtractRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Extracted JSON",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ExtractResponse" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "Hosted only. Get a key at https://fastcrw.com/register."
      }
    },
    "schemas": {
      "SearchRequest": {
        "type": "object",
        "required": ["query"],
        "properties": {
          "query": { "type": "string", "minLength": 1, "maxLength": 2000 },
          "limit": { "type": "integer", "minimum": 1, "maximum": 20, "default": 5 },
          "lang":  { "type": "string", "example": "en" },
          "tbs":   { "type": "string", "enum": ["qdr:h", "qdr:d", "qdr:w", "qdr:m", "qdr:y"] },
          "sources":    { "type": "array", "items": { "type": "string", "enum": ["web", "news", "images"] } },
          "categories": { "type": "array", "items": { "type": "string" } },
          "scrapeOptions": { "$ref": "#/components/schemas/ScrapeOptions" }
        }
      },
      "SearchResult": {
        "type": "object",
        "required": ["url", "title"],
        "properties": {
          "url":         { "type": "string", "format": "uri" },
          "title":       { "type": "string" },
          "snippet":     { "type": "string", "description": "Result blurb (LLM-ready summary line)" },
          "description": { "type": "string", "description": "Alias of snippet (same value, kept for Firecrawl response-shape parity)" },
          "position":    { "type": "integer" },
          "score":       { "type": "number" },
          "category":    { "type": "string", "description": "SearXNG result category (e.g. 'general')" },
          "markdown":    { "type": "string", "description": "Present when scrapeOptions.formats includes 'markdown'" }
        }
      },
      "SearchResponse": {
        "type": "object",
        "required": ["success", "data"],
        "properties": {
          "success": { "type": "boolean" },
          "data":    { "type": "array", "items": { "$ref": "#/components/schemas/SearchResult" } }
        }
      },
      "ScrapeOptions": {
        "type": "object",
        "properties": {
          "formats":         { "type": "array", "items": { "type": "string", "enum": ["markdown", "html", "rawHtml", "links"] }, "default": ["markdown"] },
          "onlyMainContent": { "type": "boolean", "default": true }
        }
      },
      "ScrapeRequest": {
        "type": "object",
        "required": ["url"],
        "properties": {
          "url":             { "type": "string", "format": "uri" },
          "formats":         { "type": "array", "items": { "type": "string", "enum": ["markdown", "html", "rawHtml", "plainText", "links", "json", "summary", "changeTracking"] }, "default": ["markdown"] },
          "onlyMainContent": { "type": "boolean", "default": true },
          "jsonOptions":     { "$ref": "#/components/schemas/JsonOptions" },
          "changeTracking":  { "$ref": "#/components/schemas/ChangeTrackingOptions", "description": "Activated when formats includes 'changeTracking'. The format entry is the plain string; options ride on this sibling field." },
          "goal":            { "type": "string", "maxLength": 2048, "description": "Plain-language monitor goal for the meaningful-change judge" },
          "judgeEnabled":    { "type": "boolean", "description": "Run the LLM meaningful-change judge on a changed page (requires goal)" }
        }
      },
      "ScrapeResponse": {
        "type": "object",
        "required": ["success", "data"],
        "properties": {
          "success": { "type": "boolean" },
          "warning": { "type": "string", "description": "Top-level advisory (e.g. fallback render notice)" },
          "data": {
            "type": "object",
            "properties": {
              "markdown": { "type": "string" },
              "html":     { "type": "string" },
              "rawHtml":  { "type": "string" },
              "links":    { "type": "array", "items": { "type": "string", "format": "uri" } },
              "json":     { "type": "object", "additionalProperties": true },
              "metadata": { "$ref": "#/components/schemas/PageMetadata" },
              "warning":  { "type": "string" },
              "warnings": { "type": "array", "items": { "type": "string" } },
              "renderDecision": { "type": "string", "description": "Which renderer ran (e.g. 'http', 'browser')" },
              "creditCost":     { "type": "number" }
            }
          }
        }
      },
      "JsonOptions": {
        "type": "object",
        "properties": {
          "schema":       { "type": "object", "description": "JSON schema for the extracted shape", "additionalProperties": true },
          "prompt":       { "type": "string" },
          "systemPrompt": { "type": "string" }
        }
      },
      "MapRequest": {
        "type": "object",
        "required": ["url"],
        "properties": {
          "url":   { "type": "string", "format": "uri" },
          "limit": { "type": "integer", "minimum": 1, "maximum": 5000, "default": 100 },
          "search":{ "type": "string", "description": "Optional substring filter applied to discovered URLs" }
        }
      },
      "MapResponse": {
        "type": "object",
        "required": ["success", "data"],
        "properties": {
          "success": { "type": "boolean" },
          "data": {
            "type": "object",
            "required": ["links"],
            "properties": {
              "links": { "type": "array", "items": { "type": "string", "format": "uri" } },
              "droppedActionCount":    { "type": "integer" },
              "strippedTrackingCount": { "type": "integer" }
            }
          }
        }
      },
      "CrawlRequest": {
        "type": "object",
        "required": ["url"],
        "properties": {
          "url":      { "type": "string", "format": "uri" },
          "maxPages": { "type": "integer", "minimum": 1, "default": 100 },
          "maxDepth": { "type": "integer", "minimum": 0, "default": 2 },
          "scrapeOptions": { "$ref": "#/components/schemas/ScrapeOptions" }
        }
      },
      "CrawlAccepted": {
        "type": "object",
        "required": ["success", "id"],
        "properties": {
          "success": { "type": "boolean" },
          "id":      { "type": "string" },
          "url":     { "type": "string", "format": "uri", "description": "URL to poll with GET /v1/crawl/{id}" }
        }
      },
      "CrawlStatus": {
        "type": "object",
        "required": ["status"],
        "properties": {
          "status":    { "type": "string", "enum": ["scraping", "completed", "failed"] },
          "completed": { "type": "integer" },
          "total":     { "type": "integer" },
          "data":      { "type": "array", "items": { "$ref": "#/components/schemas/ScrapeResponse" } }
        }
      },
      "ExtractRequest": {
        "type": "object",
        "required": ["url"],
        "properties": {
          "url":    { "type": "string", "format": "uri" },
          "schema": { "type": "object", "additionalProperties": true },
          "prompt": { "type": "string" },
          "llmApiKey":   { "type": "string", "description": "BYOK: LLM provider API key (required unless server has one configured)" },
          "llmProvider": { "type": "string", "description": "LLM provider name (e.g. openai, anthropic)" },
          "llmModel":    { "type": "string", "description": "Model identifier passed to the provider" }
        }
      },
      "ExtractResponse": {
        "type": "object",
        "required": ["success", "data"],
        "properties": {
          "success": { "type": "boolean" },
          "data":    { "type": "object", "additionalProperties": true }
        }
      },
      "PageMetadata": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "title":       { "type": "string" },
          "description": { "type": "string" },
          "sourceURL":   { "type": "string", "format": "uri" },
          "statusCode":  { "type": "integer" }
        }
      },
      "ChangeTrackingOptions": {
        "type": "object",
        "properties": {
          "modes":   { "type": "array", "items": { "type": "string", "enum": ["gitDiff", "json"] }, "description": "Diff surfaces. gitDiff = markdown unified diff + AST; json = per-field diff; both = mixed." },
          "schema":  { "type": "object", "additionalProperties": true, "description": "JSON schema of tracked fields (json/mixed mode)" },
          "prompt":  { "type": "string" },
          "previous": { "$ref": "#/components/schemas/ChangeTrackingSnapshot" },
          "tag":     { "type": "string", "description": "Opaque caller tag echoed on the result" },
          "contentType": { "type": "string", "description": "MIME type; non-text content is hashed, not diffed" }
        }
      },
      "ChangeTrackingSnapshot": {
        "type": "object",
        "properties": {
          "markdown":    { "type": "string", "description": "Present for gitDiff/mixed mode" },
          "json":        { "type": "object", "additionalProperties": true, "description": "Present for json/mixed mode" },
          "contentHash": { "type": "string", "description": "Mode-aware hash; persist + supply on the next check" },
          "capturedAt":  { "type": "string", "description": "Caller-stamped capture time, echoed untouched" }
        }
      },
      "ChangeDiff": {
        "type": "object",
        "properties": {
          "text": { "type": "string", "description": "Unified markdown diff (gitDiff/mixed)" },
          "json": { "type": "object", "additionalProperties": true, "description": "Parse-diff AST (gitDiff-only) OR per-field path map {previous,current} (json/mixed)" }
        }
      },
      "ChangeJudgment": {
        "type": "object",
        "required": ["meaningful", "confidence", "reason"],
        "properties": {
          "meaningful": { "type": "boolean" },
          "confidence": { "type": "string", "enum": ["low", "medium", "high"] },
          "reason":     { "type": "string" },
          "meaningfulChanges": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type":   { "type": "string", "enum": ["added", "removed", "changed"] },
                "before": { "type": "string" },
                "after":  { "type": "string" },
                "reason": { "type": "string" }
              }
            }
          }
        }
      },
      "ChangeTrackingResult": {
        "type": "object",
        "required": ["status", "contentHash"],
        "properties": {
          "status":           { "type": "string", "enum": ["same", "changed"], "description": "Per-page status. Set-level new/removed are computed by the caller's reconciler." },
          "firstObservation": { "type": "boolean", "description": "True when no previous was supplied — caller maps to 'new'" },
          "contentHash":      { "type": "string" },
          "snapshot":         { "$ref": "#/components/schemas/ChangeTrackingSnapshot" },
          "diff":             { "$ref": "#/components/schemas/ChangeDiff" },
          "judgment":         { "$ref": "#/components/schemas/ChangeJudgment" },
          "tag":              { "type": "string" },
          "truncated":        { "type": "boolean" }
        }
      },
      "ChangeTrackingDiffItem": {
        "type": "object",
        "required": ["current"],
        "properties": {
          "url":      { "type": "string", "format": "uri" },
          "current":  { "type": "object", "properties": { "markdown": { "type": "string" }, "json": { "type": "object", "additionalProperties": true } } },
          "previous": { "$ref": "#/components/schemas/ChangeTrackingSnapshot" },
          "modes":    { "type": "array", "items": { "type": "string", "enum": ["gitDiff", "json"] } },
          "schema":   { "type": "object", "additionalProperties": true },
          "prompt":   { "type": "string" },
          "contentType": { "type": "string" },
          "tag":      { "type": "string" }
        }
      },
      "ChangeTrackingDiffRequest": {
        "type": "object",
        "description": "Single body (provide 'current') OR batch (provide 'batch'). Top-level modes/schema/prompt/contentType act as shared defaults in batch mode.",
        "properties": {
          "batch":    { "type": "array", "items": { "$ref": "#/components/schemas/ChangeTrackingDiffItem" } },
          "current":  { "type": "object", "properties": { "markdown": { "type": "string" }, "json": { "type": "object", "additionalProperties": true } } },
          "previous": { "$ref": "#/components/schemas/ChangeTrackingSnapshot" },
          "modes":    { "type": "array", "items": { "type": "string", "enum": ["gitDiff", "json"] } },
          "schema":   { "type": "object", "additionalProperties": true },
          "prompt":   { "type": "string" },
          "contentType": { "type": "string" }
        }
      },
      "Error": {
        "type": "object",
        "required": ["success", "error"],
        "properties": {
          "success": { "type": "boolean", "const": false },
          "error":   { "type": "string", "description": "Machine-readable error code (see docs/error-codes.md)" },
          "message": { "type": "string" }
        }
      }
    },
    "responses": {
      "BadRequest":      { "description": "Invalid request body", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "Unauthorized":    { "description": "Missing or invalid bearer token (hosted only)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "NotFound":        { "description": "Resource not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "RateLimited":     { "description": "Rate limit exceeded", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "SearchDisabled":  { "description": "Search is disabled in self-hosted config (error: search_disabled)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
    }
  }
}