schema-org-adapter
v6.2.2
Published
Fast, simple & flexible API for the Schema.org Vocabulary (and vocabulary extensions!) for Node and Browsers
Downloads
917
Readme
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"]