{
  "openapi": "3.1.0",
  "info": {
    "title": "Open Books",
    "version": "1.0.0",
    "description": "otl Library original-book supply for AI agents: free discovery, item-level commercial-license screening, x402-paid original PDF/EPUB/text file delivery. Search /v1/search with provider=otl. Metadata: /v1/book/otl/{id}. Original file chunks: /v1/read/otl/{id}; complete original file: /v1/full/otl/{id}?file=pdf|epub. EPUB: /v1/epub/{id}. Only otl books with explicit commercial-use licenses and downloadable ORIGINAL files qualify; non-commercial and unknown rights are excluded."
  },
  "paths": {
    "/v1/search": {
      "get": {
        "summary": "Search otl Library books.",
        "x-payment-info": {
          "price": {
            "amount": "2000",
            "asset": "USDC",
            "network": "base"
          }
        },
        "operationId": "search_books",
        "description": "Search otl Library books. Paid via x402: 0.002 USDC.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "provider",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "otl"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "example": {
                  "provider": "otl",
                  "results": []
                }
              }
            }
          },
          "402": {
            "description": "x402 payment required. Decode the PAYMENT-REQUIRED header (base64 JSON), sign an EIP-3009 USDC authorization and retry with the PAYMENT-SIGNATURE header."
          }
        }
      }
    },
    "/v1/book/otl/{id}": {
      "get": {
        "summary": "otl Library metadata, original file formats and item-level commercial-use license.",
        "x-payment-info": {
          "price": {
            "amount": "1000",
            "asset": "USDC",
            "network": "base"
          }
        },
        "operationId": "get_book_metadata",
        "description": "otl Library metadata, original file formats and item-level commercial-use license. Paid via x402: 0.001 USDC.",
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "example": {
                  "rights_verified": false
                }
              }
            }
          },
          "402": {
            "description": "x402 payment required. Decode the PAYMENT-REQUIRED header (base64 JSON), sign an EIP-3009 USDC authorization and retry with the PAYMENT-SIGNATURE header."
          }
        }
      }
    },
    "/v1/read/otl/{id}": {
      "get": {
        "summary": "Original PDF/EPUB/text file chunk; bytes unchanged.",
        "x-payment-info": {
          "price": {
            "amount": "5000",
            "asset": "USDC",
            "network": "base"
          }
        },
        "operationId": "read_book_chunk",
        "description": "Original PDF/EPUB/text file chunk; bytes unchanged. Paid via x402: 0.005 USDC.",
        "parameters": [
          {
            "name": "chunk",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "example": {
                  "content_type": "application/octet-stream",
                  "raw_bytes": "original file bytes"
                }
              }
            }
          },
          "402": {
            "description": "x402 payment required. Decode the PAYMENT-REQUIRED header (base64 JSON), sign an EIP-3009 USDC authorization and retry with the PAYMENT-SIGNATURE header."
          }
        }
      }
    },
    "/v1/bulk": {
      "post": {
        "summary": "Bulk reading",
        "x-payment-info": {
          "price": {
            "amount": "4000",
            "asset": "USDC",
            "network": "base"
          }
        }
      }
    },
    "/v1/enrich": {
      "post": {
        "summary": "AI enrichment",
        "x-payment-info": {
          "price": {
            "amount": "20000",
            "asset": "USDC",
            "network": "base"
          }
        }
      }
    },
    "/v1/full/otl/{id}": {
      "get": {
        "summary": "Complete original PDF/EPUB/text file; bytes unchanged.",
        "x-payment-info": {
          "price": {
            "amount": "dynamic",
            "asset": "USDC",
            "network": "base"
          }
        },
        "operationId": "read_full_book",
        "description": "Complete original PDF/EPUB/text file; bytes unchanged. Paid via x402: chunks x 0.005 USDC.",
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "example": {
                  "content_type": "application/octet-stream",
                  "stream": "original file bytes"
                }
              }
            }
          },
          "402": {
            "description": "x402 payment required. Decode the PAYMENT-REQUIRED header (base64 JSON), sign an EIP-3009 USDC authorization and retry with the PAYMENT-SIGNATURE header."
          }
        }
      },
      "post": {
        "summary": "Full book text (POST-compatible)",
        "x-payment-info": {
          "price": {
            "amount": "dynamic",
            "asset": "USDC",
            "network": "base"
          }
        }
      }
    },
    "/v1/corpus/quote": {
      "get": {
        "summary": "Free corpus quote"
      },
      "post": {
        "summary": "Free corpus quote (JSON items or ids)"
      }
    },
    "/v1/corpus/bundle": {
      "post": {
        "summary": "Paid corpus bundle (dynamic x402 amount)"
      }
    },
    "/v1/session": {
      "post": {
        "summary": "Time-based pass",
        "x-payment-info": {
          "price": {
            "amount": "dynamic",
            "asset": "USDC",
            "network": "base"
          }
        }
      }
    },
    "/v1/epub/{id}": {
      "get": {
        "operationId": "download_epub",
        "summary": "Original EPUB under verified commercial-use license; preserve attribution and license terms.",
        "description": "Original EPUB under verified commercial-use license; preserve attribution and license terms. Paid via x402: chunks x 0.005 USDC.",
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "example": {
                  "content_type": "application/epub+zip"
                }
              }
            }
          },
          "402": {
            "description": "x402 payment required. Decode the PAYMENT-REQUIRED header (base64 JSON), sign an EIP-3009 USDC authorization and retry with the PAYMENT-SIGNATURE header."
          }
        }
      }
    },
    "/v1/corpus/discover": {
      "get": {
        "operationId": "discover_corpus",
        "summary": "Free otl discovery; paid delivery requires a commercially licensed downloadable original file.",
        "description": "Free otl discovery; paid delivery requires a commercially licensed downloadable original file. Free.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "provider",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "otl"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 6
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "example": {
                  "books": [],
                  "catalog_only": []
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent/guide": {
      "get": {
        "operationId": "get_agent_guide",
        "summary": "Free machine-readable x402 onboarding guide.",
        "description": "Free machine-readable x402 onboarding guide. Free.",
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "example": {
                  "workflow": []
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent/kit": {
      "get": {
        "operationId": "purchase_agent_kit",
        "summary": "x402 paid agent integration kits: starter 0.002, builder 0.01, pro 0.05 USDC.",
        "description": "x402 paid agent integration kits: starter 0.002, builder 0.01, pro 0.05 USDC. Paid via x402: 0.002-0.05 by tier USDC.",
        "parameters": [
          {
            "name": "tier",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "starter",
                "builder",
                "pro"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "example": {
                  "product": "agent_integration_kit"
                }
              }
            }
          },
          "402": {
            "description": "x402 payment required. Decode the PAYMENT-REQUIRED header (base64 JSON), sign an EIP-3009 USDC authorization and retry with the PAYMENT-SIGNATURE header."
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "https://open-books.alfrexo95.workers.dev"
    }
  ]
}