Book Actions Schema Framework

Use conditional-logic schema generation to keep Book Actions markup aligned with real page state and avoid stale or invalid static templates.

When To Use It

Google Search CentralBook Actions documentation

Use for book catalogs submitted to Google as a Book actions data feed. The framework below builds one feed entity per work, with one edition per format.

Key Implementation Documentation Highlights

  • Limited and feed-based: Book actions are open to book providers with a wide selection of available books who register interest, and the data is delivered through a data feed, not page markup. Feed files must be under 1 GB uncompressed with a .json extension; Google fetches the feed about once a day.
  • Required on the work (Book): @id (a globally unique, stable URL-format ID), name, author (with name), url (the canonical page for the book) and workExample (one Book per edition).
  • Required on each edition: @id, bookFormat (AudiobookFormat, EBook, Hardcover or Paperback), inLanguage (ISO 639-1 two-letter code), isbn (ISBN-13 only, convert ISBN-10) and potentialAction with target.urlTemplate and target.actionPlatform (DesktopWebPlatform, AndroidPlatform, IOSPlatform).
  • ReadAction requires expectsAcceptanceOf: an Offer with category (nologinrequired, free, subscription, purchase or rental) and eligibleRegion (ISO 3166-1 alpha-2 country). price and priceCurrency are required for purchase and rental. BorrowAction requires lender, a LibrarySystem referenced by @id.
  • Recommended properties: work and author sameAs; edition author, bookEdition, datePublished (YYYY-MM-DD or YYYY), identifier (OCLC_NUMBER, LCCN, JP_E-CODE), name, sameAs, url; offer availabilityStarts and availabilityEnds.
  • Every @id, url and urlTemplate must be unique and a production, canonical URL; action links must land on a page that directly supports purchase or borrowing. Remove stale entities whose availabilityEnds has passed.

Template Approach

const pageData = {
  title: "The Salt Road",
  authorName: "Elena Marsh",
  url: "https://www.example.com/books/the-salt-road",
  isbn: "9780306406157"
};

const staticTemplate = {
  "@context": "https://schema.org",
  "@type": "Book",
  "@id": `${pageData.url}#work`,
  "name": pageData.title,
  "author": { "@type": "Person", "name": pageData.authorName },
  "url": pageData.url,
  "workExample": {
    "@type": "Book",
    "@id": `${pageData.url}/ebook#edition`,
    "bookFormat": "https://schema.org/EBook",
    "inLanguage": "en",
    "isbn": pageData.isbn,
    "potentialAction": {
      "@type": "ReadAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://www.example.com/checkout/the-salt-road-ebook",
        "actionPlatform": ["https://schema.org/DesktopWebPlatform"]
      },
      "expectsAcceptanceOf": {
        "@type": "Offer",
        "category": "purchase",
        "price": 14.99,
        "priceCurrency": "USD",
        "eligibleRegion": { "@type": "Country", "name": "US" }
      }
    }
  }
};

Conditional-logic Framework

const ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}))?(Z|[+-]\d{2}:\d{2})?)?$/;

function isAbsoluteUrl(value) {
  return typeof value === "string" && /^https?:\/\/[^\s/?#]+\.[^\s/?#]+(?:[/?#]\S*)?$/i.test(value);
}

// Returns the ISO 8601 string unchanged (timezone offset kept), or null if unparseable.
function toIsoDateTime(value) {
  if (typeof value !== "string") return null;
  const text = value.trim();
  const m = text.match(ISO_DATE_TIME);
  if (!m) return null;
  const [, y, mo, d, h = "00", mi = "00", s = "00"] = m;
  const date = new Date(Date.UTC(+y, +mo - 1, +d));
  if (date.getUTCMonth() !== +mo - 1 || date.getUTCDate() !== +d) return null;
  if (+h > 23 || +mi > 59 || +s > 59) return null;
  return text;
}

function toIsoDate(value) {
  const iso = toIsoDateTime(value);
  return iso ? iso.slice(0, 10) : null;
}

// Drops null, undefined, "", [] and {} recursively.
function compact(value) {
  if (Array.isArray(value)) {
    const items = value.map(compact).filter((v) => v !== undefined);
    return items.length ? items : undefined;
  }
  if (value && typeof value === "object") {
    const out = {};
    for (const [key, v] of Object.entries(value)) {
      const c = compact(v);
      if (c !== undefined) out[key] = c;
    }
    return Object.keys(out).length ? out : undefined;
  }
  return value === null || value === undefined || value === "" ? undefined : value;
}

function passesPageGates(source) {
  if (source.indexable === false) return false;
  if (source.canonicalUrl && source.url && source.canonicalUrl !== source.url) return false;
  return source.contentVisible !== false;
}

function toNumber(value) {
  if (value === null || value === undefined || value === "" || typeof value === "boolean") return null;
  const num = Number(value);
  return Number.isFinite(num) ? num : null;
}

const isCurrencyCode = (value) => typeof value === "string" && /^[A-Z]{3}$/.test(value);

const BOOK_FORMATS = ["AudiobookFormat", "EBook", "Hardcover", "Paperback"];
const PLATFORMS = ["DesktopWebPlatform", "AndroidPlatform", "IOSPlatform"];
const OFFER_CATEGORIES = ["nologinrequired", "free", "subscription", "purchase", "rental"];

// Google Search accepts ISBN-13 only: ISBN-10 is converted, checksums are verified.
function toIsbn13(value) {
  const raw = String(value ?? "").replace(/[\s-]/g, "").toUpperCase();
  let digits = raw;
  if (/^\d{9}[\dX]$/.test(raw)) {
    const sum10 = [...raw].reduce((s, c, i) => s + (c === "X" ? 10 : Number(c)) * (10 - i), 0);
    if (sum10 % 11 !== 0) return null;
    digits = `978${raw.slice(0, 9)}`;
  } else if (/^97[89]\d{10}$/.test(raw)) {
    digits = raw.slice(0, 12);
  } else {
    return null;
  }
  const sum = [...digits].reduce((s, c, i) => s + Number(c) * (i % 2 ? 3 : 1), 0);
  const isbn = `${digits}${(10 - (sum % 10)) % 10}`;
  return raw.length === 13 && isbn !== raw ? null : isbn;
}

// ReadAction needs an Offer (category + eligibleRegion); purchase and rental need a price.
function buildOffer(offer, now) {
  const ends = toIsoDateTime(offer.availabilityEnds);
  if (ends && new Date(ends) < now) return null;                 // stale: drop it from the feed
  const price = toNumber(offer.price);
  const needsPrice = offer.category === "purchase" || offer.category === "rental";
  const regions = (offer.regions ?? []).filter((r) => /^[A-Z]{2}$/.test(r));
  if (!OFFER_CATEGORIES.includes(offer.category) || regions.length === 0) return null;
  if (needsPrice && (price === null || price < 0 || !isCurrencyCode(offer.currency))) return null;
  return {
    "@type": "Offer",
    category: offer.category,
    price: needsPrice ? price : null,
    priceCurrency: needsPrice ? offer.currency : null,
    availabilityStarts: toIsoDateTime(offer.availabilityStarts),
    availabilityEnds: ends,
    eligibleRegion: regions.map((name) => ({ "@type": "Country", name }))
  };
}

function buildAction(action, now) {
  const platforms = (action.platforms ?? []).filter((p) => PLATFORMS.includes(p));
  if (!isAbsoluteUrl(action.url) || platforms.length === 0) return null;
  const target = {
    "@type": "EntryPoint",
    urlTemplate: action.url,
    actionPlatform: platforms.map((p) => `https://schema.org/${p}`)
  };
  if (action.type === "BorrowAction") {
    if (!isAbsoluteUrl(action.libraryId)) return null;            // lender @id, described in the library feed
    return { "@type": "BorrowAction", target, lender: { "@type": "LibrarySystem", "@id": action.libraryId } };
  }
  const offers = (action.offers ?? []).map((o) => buildOffer(o, now)).filter(Boolean);
  return offers.length ? { "@type": "ReadAction", target, expectsAcceptanceOf: offers } : null;
}

function buildEdition(edition, now) {
  const isbn = toIsbn13(edition.isbn);
  const actions = (edition.actions ?? []).map((a) => buildAction(a, now)).filter(Boolean);
  if (!isAbsoluteUrl(edition.id) || !BOOK_FORMATS.includes(edition.format) || !/^[a-z]{2}$/.test(edition.language ?? "") || !isbn || actions.length === 0) return null;
  const published = String(edition.datePublished ?? "");
  return {
    "@type": "Book",
    "@id": edition.id,
    url: isAbsoluteUrl(edition.url) ? edition.url : null,
    bookFormat: `https://schema.org/${edition.format}`,
    inLanguage: edition.language,
    isbn,
    bookEdition: edition.bookEdition,
    datePublished: /^\d{4}(-\d{2}-\d{2})?$/.test(published) && (published.length === 4 || toIsoDate(published)) ? published : null,
    identifier: (edition.identifiers ?? [])
      .filter((i) => ["OCLC_NUMBER", "LCCN", "JP_E-CODE"].includes(i.type) && i.value)
      .map((i) => ({ "@type": "PropertyValue", propertyID: i.type, value: String(i.value).replace(/^\D+/, "") })),
    sameAs: isAbsoluteUrl(edition.sameAs) ? edition.sameAs : null,
    potentialAction: actions
  };
}

// Builds one Book (work) entity for the dataFeedElement array of a Book actions feed.
function buildBookFeedEntity(source, now = new Date()) {
  if (!passesPageGates(source)) return null;

  // Required: work @id, name, author, canonical url and at least one valid edition.
  const authors = (source.authors ?? []).filter((a) => a.name);
  const seen = new Set([source.id, source.url]);
  const editions = (source.editions ?? []).map((e) => buildEdition(e, now)).filter((e) => {
    if (!e) return false;
    const keys = [e["@id"], e.url, ...e.potentialAction.map((a) => a.target.urlTemplate)].filter(Boolean);
    if (keys.some((k) => seen.has(k))) return false;                 // @id, url and urlTemplate must be unique
    keys.forEach((k) => seen.add(k));
    return true;
  });
  if (!isAbsoluteUrl(source.id) || !source.name || authors.length === 0 || !isAbsoluteUrl(source.url) || editions.length === 0) return null;

  return compact({
    "@context": "https://schema.org",
    "@type": "Book",
    "@id": source.id,
    name: source.name,
    url: source.url,
    author: authors.map((a) => ({ "@type": a.type === "Organization" ? "Organization" : "Person", name: a.name, sameAs: isAbsoluteUrl(a.sameAs) ? a.sameAs : null })),
    sameAs: isAbsoluteUrl(source.sameAs) ? source.sameAs : null,
    workExample: editions
  });
}

// Usage:
// const source = {
//   url: "https://www.example.com/books/the-salt-road",
//   canonicalUrl: "https://www.example.com/books/the-salt-road",
//   indexable: true,
//   contentVisible: true,
//   id: "https://www.example.com/books/the-salt-road#work",
//   name: "The Salt Road",
//   authors: [{ name: "Elena Marsh", sameAs: "https://en.wikipedia.org/wiki/Elena_Marsh" }],
//   sameAs: "https://www.wikidata.org/wiki/Q00000000",
//   editions: [{
//     id: "https://www.example.com/books/the-salt-road/ebook#edition",
//     url: "https://www.example.com/books/the-salt-road/ebook",
//     format: "EBook",
//     language: "en",
//     isbn: "978-0-306-40615-7",
//     bookEdition: "2nd Edition",
//     datePublished: "2026-02-10",
//     identifiers: [{ type: "OCLC_NUMBER", value: "ocm1234567" }],
//     sameAs: "https://www.example.com/catalog/9780306406157",
//     actions: [{
//       type: "ReadAction",
//       url: "https://www.example.com/checkout/the-salt-road-ebook",
//       platforms: ["DesktopWebPlatform", "AndroidPlatform", "IOSPlatform"],
//       offers: [{ category: "purchase", price: 14.99, currency: "USD", regions: ["US", "CA"], availabilityStarts: "2026-02-10T00:00:00-05:00", availabilityEnds: "2027-12-31T23:59:59-05:00" }]
//     }]
//   }]
// };
// const jsonLd = buildBookFeedEntity(source);

The Output As An Entity Graph

The conditional-logic output above, parsed in your browser and drawn as the graph a crawler builds from it. Every nested object is a node and the property that holds it is the edge. Tap a node to inspect its properties, or drag to rearrange.

Why Conditional Logic Is Better Than Static Templates

  • Prevents emitting empty, null, or stale fields that frequently trigger rich result warnings.
  • Supports multiple page states (for example: no rating yet, no image yet, no offers yet) without duplicate templates.
  • Lets engineering teams centralize schema policy checks and validation in reusable code paths.
  • Makes large-scale schema maintenance safer when content models evolve over time.

Property Reference

What Google's Book actions documentation requires and recommends, property by property. These are the same rules the SchemaCDN validator checks. Each name links to its schema.org definition.

Availability: Limited to book providers with a wide selection of available books (register interest).

Book actions properties in Google's documentation
PropertyGoogleExpectsNotes
@idRequiredURLA globally unique, stable URL-format ID for the book, unique to your organization.
authorRequiredPerson or Organization, can repeatThe author(s) of the book.
author.nameRequiredText
author.sameAsRecommendedURLA reference page that identifies the person or organization.
nameRequiredTextThe title of the book.
urlRequiredURLThe page on your site where the book is described (canonical).
workExampleRequiredBook, can repeatThe edition(s) of the work.
workExample.@idRequiredURLA globally unique, stable URL-format ID for the edition, unique to your organization.
workExample.bookFormatRequiredEnumOne of: AudiobookFormat, EBook, Hardcover, Paperback.
workExample.inLanguageRequiredTextAn ISO 639-1 alpha-2 language code.
workExample.isbnRequiredTextThe ISBN-13 of the edition. Convert ISBN-10 to ISBN-13.
workExample.potentialActionRequiredReadAction or BorrowAction, can repeatReadAction or BorrowAction for users to purchase, download or borrow the book.
workExample.authorRecommendedPerson or Organization, can repeatOnly when the edition author differs from the work author.
workExample.bookEditionRecommendedTextFor example 2nd Edition.
workExample.datePublishedRecommendedDateIn YYYY-MM-DD or YYYY format.
workExample.identifierRecommendedPropertyValue, can repeatExternal IDs that unambiguously identify this edition.
workExample.nameRecommendedTextOnly when the edition title differs from the work title.
workExample.sameAsRecommendedURLA reference page that unambiguously indicates the edition.
workExample.urlRecommendedURLThe page on your site where the edition is described.
sameAsRecommendedURLA reference page identifying the work (Wikipedia, Wikidata, VIAF, Library of Congress).

Explore Other Schema Framework Pages

Breadcrumb Use on pages that belong to a clear hierarchy and display navigational trail links users can follow. BreadcrumbList Open Carousel Use when a page lists multiple related entities in a scannable sequence that can be surfaced as cards. ItemList Open Course Use for educational offerings where curriculum details, provider identity, and delivery context are explicit. Course Open Dataset Use for dataset landing pages so datasets are discoverable in Google Dataset Search with license, creator and download details. Dataset Open Discussion Forum Use for forum and community threads where a primary post and subsequent replies are publicly visible. DiscussionForumPosting Open Limited Education Q&A Use for educational question-answer pages where a single canonical answer and supporting context are visible. Quiz Open Employer Aggregate Rating Use on pages that publish employer rating aggregates from a clear and policy-compliant review source. EmployerAggregateRating Open Retired Estimated Salary Use for compensation insight pages that present transparent salary ranges for specific occupations and locations. Occupation Open Event Use for upcoming events with a real-world or virtual occurrence, schedule, and location context. Event Open Retired Fact Check Use for fact-checking pages that evaluate a specific claim with a transparent rating methodology. ClaimReview Open Retired Home Activities Use for virtual classes and activities where participation details and timing are clearly listed. Event Open Retired How-To Use for instructional content that teaches a process through ordered steps and actionable detail. HowTo Open Image Metadata Use on image pages and image hosts that expose ownership and licensing information to search engines. ImageObject Open Job Posting Use for active job listings that include role details, hiring entity, and location/salary context. JobPosting Open Retired Learning Video Use for educational videos where the learning objective and pedagogical structure are explicit. LearningResource Open Local Business Use for physical businesses serving local customers with publicly verifiable contact and location details. LocalBusiness Open Loyalty Program Use to publish a loyalty program and its tiers once at the organization level, so member prices and member shipping can reference them. MemberProgram Open Math Solvers Use for pages that solve mathematical expressions and present step-by-step computational guidance. MathSolver Open Merchant Listing Use on pages where a product can be bought, with price, availability, shipping and return details. Product Open Limited Movie Use for movie detail pages with canonical film information and transparent metadata attribution. Movie Open Organization Use for official organization pages to clarify brand identity and authoritative entity signals. Organization Open Retired Practice Problems Use for educational practice content that presents solvable problems and answer validation structure. Quiz Open Product Snippet Use for product pages where pricing, availability, and product identity are visible to users. Product Open Product Variants Use when one product comes in variants such as size or color, grouped with ProductGroup. ProductGroup Open Profile Page Use for creator or contributor profile pages where identity attributes and ownership are explicit. ProfilePage Open Q&A Use for pages where users submit questions and community or editorial answers are displayed. QAPage Open Recipe Use for recipe pages with complete ingredients, instructions, and preparation details. Recipe Open Return Policy Use to publish a merchant return policy once at the organization level, with offer-level overrides. MerchantReturnPolicy Open Review Snippet Use when a page publishes genuine reviews tied to a clearly identified product, service, or entity. Review Open Shipping Policy Use to publish shipping rates, delivery times and destinations once at the organization level. ShippingService Open Site Name Use on the home page so Google shows the preferred site name in search results. WebSite Open Retired Sitelinks Search Box Use on sites with a functioning internal search endpoint that can accept URL query parameters. WebSite Open Software App (Beta) Use for software product pages that describe platform support and application category clearly. SoftwareApplication Open Limited Speakable Use for news-style pages where specific text segments are appropriate for text-to-speech playback. SpeakableSpecification Open Subscription and Paywalled Content Use for pages with restricted sections so Google can distinguish free previews from protected content. CreativeWork Open Limited Vacation Rental Use for rental property detail pages where booking-relevant amenities and location signals are explicit. VacationRental Open Retired Vehicle Listing Use for inventory pages selling vehicles with standardized listing fields and offer information. Car Open Video Use for pages where a primary video is embedded and key media metadata is visible on-page. VideoObject Open Article Use for editorial pages where the visible content is a complete article with a clear byline and publication timestamps. Article Open

Implement Book Actions Schema Frameworks Correctly

Get implementation support for conditional schema architecture, validation, and deployment governance.