{
  "openapi": "3.1.0",
  "info": {
    "title": "Delta Registry — Aozora Bunko New Public-Domain Text Delta Feed",
    "description": "Watches Aozora Bunko's own official catalog export for newly digitized or revised confirmed-public-domain Japanese texts and emits NEW_TEXT/REVISED_TEXT/STATUS_CHANGE events with full decoded text where available. Pay-per-event: billed only for what's new or changed.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/K0XRDbUteacQL3jeF/run-sync-get-dataset-items": {
      "post": {
        "operationId": "runAozoraBunkoPublicDomainTextFeed",
        "summary": "Watches Aozora Bunko's own official catalog export for newly digitized or revised confirmed-public-domain Japanese texts and emits NEW_TEXT/REVISED_TEXT/STATUS_CHANGE events with full decoded text where available. Pay-per-event: billed only for what's new or changed.",
        "x-sync-pattern-reason": "Real observed max runtime 10.7s fits safely under GPT Actions' 45s cap — run-sync-get-dataset-items is safe to expose directly.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "onlyNew": {
                    "type": "boolean",
                    "description": "When true (default), only NEW_TEXT, REVISED_TEXT and STATUS_CHANGE rows are pushed, each as a charged PPE event. Set to false for a free baseline run: every catalog row that passes the public-domain filter is pushed once as an uncharged SNAPSHOT_NO_DIFF record.",
                    "default": true
                  },
                  "resetState": {
                    "type": "boolean",
                    "description": "When true, clears this feed's stored seen-work state before this run, so the next run re-baselines from scratch (every catalog row becomes a fresh, uncharged SNAPSHOT_NO_DIFF again, subject to onlyNew). Use for testing or recovering a corrupted state store, not routine operation.",
                    "default": false
                  },
                  "onlyConfirmedPublicDomain": {
                    "type": "boolean",
                    "description": "When true (default), keeps only catalog rows where Aozora's own work-copyright flag reads なし (no copyright - confirmed public domain). When false, also includes rows flagged あり (the author/estate granted free-use permission, but the work is NOT public domain).",
                    "default": true
                  },
                  "includeFullText": {
                    "type": "boolean",
                    "description": "When true (default), NEW_TEXT/REVISED_TEXT events download the linked text ZIP, decode it from Shift_JIS, strip Aozora's ruby/annotation markup and legend preamble, and embed both plain_text and raw_text_with_markup - delivered as the higher-priced 'result' event. When false, or when a text file fails to download/decode, the same events are delivered as metadata-only 'result-summary' records instead.",
                    "default": false
                  },
                  "authorIdAllowlist": {
                    "type": "array",
                    "description": "Aozora 人物ID values (e.g. \"001257\") to restrict this feed to. Leave empty to monitor the entire catalog.",
                    "default": []
                  },
                  "maxItemsPerRun": {
                    "type": "integer",
                    "description": "Caps the number of charged (result/result-summary) events this run will push, independent of your Apify spending limit. 0 means no Actor-side cap.",
                    "default": 20,
                    "minimum": 0
                  },
                  "requestDelayMs": {
                    "type": "integer",
                    "description": "Aozora Bunko is a small, volunteer-run, non-commercial mirror with no published rate limit - this default trades a slower walk for not needing to trust an unconfirmed number, and for being a polite citizen of a small server, not only a cost control.",
                    "default": 500,
                    "minimum": 0
                  },
                  "maxRetries": {
                    "type": "integer",
                    "description": "Retry attempts (exponential backoff with jitter) for a 429/5xx response or a network-level failure before a single catalog or text-ZIP fetch is given up on as failed.",
                    "default": 5,
                    "minimum": 0
                  },
                  "requestTimeoutSecs": {
                    "type": "integer",
                    "description": "Aborts a single request to Aozora Bunko (catalog export or per-work text ZIP) that takes longer than this, so one slow response never stalls the whole run.",
                    "default": 30,
                    "minimum": 5
                  },
                  "deltaStateName": {
                    "type": "string",
                    "description": "Names the Key-Value Store this feed's seen-work state is kept in. Run multiple independent schedules - e.g. filtered to different author allowlists - without them draining each other's baseline by giving each a distinct name here.",
                    "default": "default"
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Array of normalized records from the actor run.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "actorSpecification": 1,
                    "fields": {
                      "$schema": "http://json-schema.org/draft-07/schema#",
                      "title": "Aozora Bunko New Public-Domain Text Delta Feed record",
                      "type": "object",
                      "properties": {
                        "record_id": {
                          "type": "string",
                          "description": "作品ID (work_id) - Aozora's own stable identity key."
                        },
                        "event_id": {
                          "type": "string"
                        },
                        "event_type": {
                          "type": "string",
                          "enum": [
                            "BASELINE_SNAPSHOT",
                            "NEW_TEXT",
                            "REVISED_TEXT",
                            "STATUS_CHANGE",
                            "SNAPSHOT_NO_DIFF"
                          ]
                        },
                        "scraped_at": {
                          "type": "string"
                        },
                        "is_new": {
                          "type": "boolean"
                        },
                        "source_url": {
                          "type": "string"
                        },
                        "work_id": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "author_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "author_name": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "copyright_status": {
                          "type": "string",
                          "enum": [
                            "confirmed_public_domain",
                            "author_permitted_free_use"
                          ]
                        },
                        "first_published_date": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "source_last_updated": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "text_file_url": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "xhtml_file_url": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "character_count": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "content_hash": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "plain_text": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Decoded, ruby/annotation-stripped, legend-preamble-stripped plain text. Null unless includeFullText=true and the text was successfully decoded."
                        },
                        "raw_text_with_markup": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "The decoded text with Aozora's own ruby/annotation markup intact, legend preamble still stripped."
                        },
                        "changed_fields": {
                          "type": [
                            "array",
                            "null"
                          ]
                        },
                        "status_fingerprint": {
                          "type": "string"
                        },
                        "content_fingerprint": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "record_id",
                        "event_id",
                        "event_type",
                        "scraped_at",
                        "is_new",
                        "source_url",
                        "work_id",
                        "title",
                        "copyright_status",
                        "status_fingerprint",
                        "content_fingerprint"
                      ]
                    },
                    "views": {
                      "overview": {
                        "title": "Overview",
                        "description": "One row per delta event, most recent first.",
                        "transformation": {
                          "fields": [
                            "work_id",
                            "title",
                            "author_name",
                            "event_type",
                            "copyright_status",
                            "character_count",
                            "source_url"
                          ]
                        },
                        "display": {
                          "component": "table",
                          "properties": {
                            "work_id": {
                              "label": "Work ID",
                              "format": "text"
                            },
                            "title": {
                              "label": "Title",
                              "format": "text"
                            },
                            "author_name": {
                              "label": "Author",
                              "format": "text"
                            },
                            "event_type": {
                              "label": "Event",
                              "format": "text"
                            },
                            "copyright_status": {
                              "label": "Copyright",
                              "format": "text"
                            },
                            "character_count": {
                              "label": "Characters",
                              "format": "number"
                            },
                            "source_url": {
                              "label": "Source",
                              "format": "link"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-openai-isConsequential": false
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApifyBearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "security": [
    {
      "ApifyBearerAuth": []
    }
  ]
}