
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
maniiifest
Advanced tools
Typesafe IIIF presentation v3 manifest and collection parsing without external dependencies
A TypeScript library for working with IIIF Presentation API 3.0 manifests, collections, and W3C web annotations.
A typechecker/validator built using maniiifest is available online here.
npm install maniiifest
import { Maniiifest } from 'maniiifest';
const response = await fetch('https://iiif.wellcomecollection.org/presentation/b19974760');
const data = await response.json();
const parser = new Maniiifest(data);
// Get top-level properties
console.log(parser.getCollectionId());
console.log(parser.getCollectionLabel());
// Iterate over nested items
for (const manifest of parser.iterateCollectionManifest()) {
console.log(manifest);
}
The Maniiifest constructor parses IIIF Manifests and Collections:
const parser = new Maniiifest(data);
For W3C annotation types, use the dedicated static methods or classes:
import { Maniiifest, ManiiifestAnnotation, ManiiifestAnnotationPage, ManiiifestAnnotationCollection } from 'maniiifest';
// Via static factory methods
const annotation = Maniiifest.parseAnnotation(data);
const page = Maniiifest.parseAnnotationPage(data);
const annoCollection = Maniiifest.parseAnnotationCollection(data);
// Or via direct constructors
const annotation2 = new ManiiifestAnnotation(data);
const page2 = new ManiiifestAnnotationPage(data);
const annoCollection2 = new ManiiifestAnnotationCollection(data);
Every method is either a getter that returns a single value (or null) or an iterator (generator) that you loop over with for...of.
The naming convention tells you what it does:
| Pattern | Returns | Example |
|---|---|---|
get<Resource><Property>() | value or null | getManifestLabel() |
iterate<Resource><Item>() | generator | iterateManifestCanvas() |
const parser = new Maniiifest(manifest);
parser.getManifestId();
parser.getManifestLabel();
parser.getManifestSummary();
parser.getManifestRights();
parser.getManifestRequiredStatement();
for (const canvas of parser.iterateManifestCanvas()) { /* ... */ }
for (const meta of parser.iterateManifestMetadata()) { /* ... */ }
for (const anno of parser.iterateManifestCanvasAnnotation()) { /* ... */ }
for (const range of parser.iterateManifestRange()) { /* ... */ }
Canvas and range properties are accessible through the manifest:
// Canvas-level iteration
for (const label of parser.iterateManifestCanvasLabel()) { /* ... */ }
for (const thumb of parser.iterateManifestCanvasThumbnail()) { /* ... */ }
for (const meta of parser.iterateManifestCanvasMetadata()) { /* ... */ }
for (const rendering of parser.iterateManifestCanvasRendering()) { /* ... */ }
for (const seeAlso of parser.iterateManifestCanvasSeeAlso()) { /* ... */ }
for (const service of parser.iterateManifestCanvasService()) { /* ... */ }
// Range-level iteration (structures / table of contents)
for (const label of parser.iterateManifestRangeLabel()) { /* ... */ }
for (const item of parser.iterateManifestRangeItem()) { /* ... */ }
for (const rendering of parser.iterateManifestRangeRendering()) { /* ... */ }
for (const anno of parser.iterateManifestRangeAnnotation()) { /* ... */ }
const parser = new Maniiifest(collection);
parser.getCollectionId();
parser.getCollectionLabel();
parser.getCollectionSummary();
parser.getCollectionRights();
parser.getCollectionNavDate();
parser.getCollectionNavPlace();
for (const manifest of parser.iterateCollectionManifest()) { /* ... */ }
for (const nested of parser.iterateCollectionCollection()) { /* ... */ }
for (const meta of parser.iterateCollectionMetadata()) { /* ... */ }
for (const rendering of parser.iterateCollectionRendering()) { /* ... */ }
for (const seeAlso of parser.iterateCollectionSeeAlso()) { /* ... */ }
for (const behavior of parser.iterateCollectionBehavior()) { /* ... */ }
for (const partOf of parser.iterateCollectionPartOf()) { /* ... */ }
const parser = Maniiifest.parseAnnotation(annotation);
parser.getAnnotationId();
parser.getAnnotationBody();
parser.getAnnotationTarget();
parser.getAnnotationMotivation();
parser.getAnnotationCreator();
parser.getAnnotationCreated();
parser.getAnnotationModified();
for (const body of parser.iterateAnnotationTextualBody()) { /* ... */ }
for (const body of parser.iterateAnnotationResourceBody()) { /* ... */ }
for (const target of parser.iterateAnnotationTarget()) { /* ... */ }
for (const feature of parser.iterateAnnotationFeature()) { /* ... */ }
for (const coords of parser.iterateAnnotationGeometryPointCoordinates()) { /* ... */ }
const parser = Maniiifest.parseAnnotationPage(page);
parser.getAnnotationPageId();
parser.getAnnotationPagePartOf();
parser.getAnnotationPageLabel();
parser.getAnnotationPageNext();
parser.getAnnotationPageStartIndex();
for (const anno of parser.iterateAnnotationPageAnnotation()) { /* ... */ }
for (const body of parser.iterateAnnotationPageAnnotationTextualBody()) { /* ... */ }
for (const ref of parser.iterateAnnotationPageAnnotationCanvasRef()) { /* ... */ }
const parser = Maniiifest.parseAnnotationCollection(collection);
parser.getAnnotationCollectionId();
parser.getAnnotationCollectionLabel();
parser.getAnnotationCollectionTotal();
parser.getAnnotationCollectionFirst();
parser.getAnnotationCollectionLast();
for (const anno of parser.iterateAnnotationCollectionAnnotation()) { /* ... */ }
Full API docs: jptmoore.github.io/maniiifest
The library exports TypeScript types that match real IIIF JSON structure:
import { Maniiifest } from 'maniiifest';
import type { Manifest, Canvas, Annotation, Label, Metadata, Service } from 'maniiifest';
const response = await fetch('https://example.org/iiif/manifest.json');
const manifest: Manifest = await response.json();
console.log(manifest.id);
console.log(manifest.label);
for (const item of manifest.metadata ?? []) {
const meta: Metadata = item;
console.log(meta.label, '->', meta.value);
}
A full list of exported types is in the generated src/iiif-types.ts file.
More examples can be found here.
npm run build: Compile TypeScript to dist/.npm run test: Run the tests using Jest.npm start: Run the example script.npm run compilespec: Recompile specification.ts from the ATD spec and regenerate iiif-types.ts. Requires atdts. Only needed when specification.atd changes.npm run generate-docs: Generate documentation using TypeDoc.This project is licensed under the MIT License.
FAQs
Typesafe IIIF presentation v3 manifest and collection parsing without external dependencies
The npm package maniiifest receives a total of 143 weekly downloads. As such, maniiifest popularity was classified as not popular.
We found that maniiifest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.