schema-org-adapter
TypeScript icon, indicating that this package has built-in type declarations

6.2.2 • Public • Published

Schema.org Adapter

Fast, simple & flexible API for the Schema.org Vocabulary (and vocabulary extensions!) for Node and Browsers

Built with TypeScript Issues open
Code style in ESLint Functions test coverage
NPM Version License: CC BY-SA 4.0

Version 6 out now! Check the Migration Guide when upgrading!

Features

Empowers the semantic web: Schema.org has become the standard vocabulary for the semantic web. The Schema.org Adapter (SDO-Adapter) gives developers a clear API to access the schema.org vocabulary in a simple way.

Clear data model: The data model of the rdf-based, machine-readable version of Schema.org is slightly adapted (see algorithm documentation for details) to create the clear and pragmatic data model for the Schema.org Adapter.

Supports schema.org versions and external vocabularies: The Schema.org Adapter is lightweight because it does NOT include the vocabulary data, instead it allows the user to input his needed local/remote vocabularies (JSON-LD or URL to JSON-LD). This gives users the possibility to specify the version of Schema.org (including http/https variations) they need, also to use external vocabularies.

Built-in reasoning: The simple-to-use API of this library offers functions and parameters that enable built-in reasoning on the used vocabulary-terms (e.g. resolution of properties, subclasses, ranges, etc.)

Install and load

Independent of the installation and loading method it is expected that a variable named SOA provides this library.

NPM

npm install schema-org-adapter

Node.js

Require/import the package:

const { SOA } = require('schema-org-adapter');
// or
import { SOA } from 'schema-org-adapter';

Browser

Script-include the bundled package in /dist:

<script src="/dist/schema-org-adapter.min.js"></script>
<!--Global variable 'SOA' is available-->

CDN

For the browser you can also directly load the library via CDN:

<script src="https://cdn.jsdelivr.net/gh/semantifyit/schema-org-adapter/dist/schema-org-adapter.min.js"></script>
<!--Global variable 'SOA' is available-->

Usage

// 1. Create an SDO-Adapter instance with the latest schema.org vocabulary version
const mySdoAdapter = await SOA.create({
  schemaVersion: "latest"
});

// 2. Use the SDO-Adapter!

// get all properties that are usable by the class schema:Hotel
const hotelInstance = mySdoAdapter.getClass('schema:Hotel');
const hotelProperties = hotelInstance.getProperties();
// ["schema:audience", "schema:checkinTime", "schema:availableLanguage", ...]

// get all data-types and classes that are valid ranges for the property schema:address
const addressInstance = mySdoAdapter.getProperty("schema:address");
const addressRanges = addressInstance.getRanges();
// ["schema:PostalAddress", "schema:Text"]

Documentation

Code Examples

Changelog

Made with ❤ in Tirol!

Dependents (2)

Package Sidebar

Install

npm i schema-org-adapter

Weekly Downloads

295

Version

6.2.2

License

Apache-2.0

Unpacked Size

1.01 MB

Total Files

274

Last publish

Collaborators

  • semantifyit
  • omarjah
  • yarnseemannsgarn