Schema.org Adapter
Fast, simple & flexible API for the Schema.org Vocabulary (and vocabulary extensions!) for Node and Browsers
const SDOAdapter = const mySDOAdapter = const urlLatestSDO = await mySDOAdapter // resolves to "https://raw.githubusercontent.com/schemaorg/schemaorg/master/data/releases/6.0/all-layers.jsonld" if 6.0 is the latest versionawait mySDOAdapter let Hotel = mySDOAdapterHotel // 117 -> ["schema:audience", "schema:checkinTime", "schema:availableLanguage", ...]Hotel //only direct superclasses: 1 -> ["schema:LodgingBusiness"]Hotel //5 -> ["schema:LodgingBusiness", "schema:LocalBusiness", "schema:Place", "schema:Organization", "schema:Thing"] let address = mySDOAdapteraddress // 2 -> ["schema:PostalAddress", "schema:Text"]address // only direct domains: 5 -> ["schema:Place", "schema:GeoCoordinates", "schema:GeoShape", "schema:Person", "schema:Organization"]address // 229 -> ["schema:Place", "schema:Accommodation", "schema:TouristAttraction", ...]Installation
NPM
Install the npm package:
npm install schema-org-adapter
Require the package:
const SDOAdapter = Browser
Script-include the bundled package in /dist or load via a cdn:
Features
⌘ Empowers the semantic web: Schema.org has become the standard vocabulary for the semantic web. This Schema.org 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 documentation for details) to create the clear and pragmatic data model of this Schema.org Adapter.
↹ Supports 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 the user the possibility to specify the version/part of Schema.org he/she needs, and also to use external vocabularies.
♻ Built-in reasoning: The API of Schema.org Adapter offers functions and parameters to enable built-in reasoning on the used vocabulary-terms (e.g. resolution of properties, sub-classes, ranges, etc.)
API
JSDoc
Api documentation generated by JSDoc hosted at GitHub.
Examples
Check the examples for Node and Browser on GitHub.
Use of filters
It is possible to filter the results of some functions by passing a filter object - The filter options can be:
- "isSuperseded": boolean (e.g.
false-> only vocabulary elements that are not superseded will be returned) - "termType": string/Array (e.g.
['Property', 'Class']-> only vocabulary elements that are properties or classes will be returned) - "fromVocabulary": string/Array (e.g.
['http://schema.org/']-> only vocabulary elements that come from a specific vocabulary will be returned (this may be interesting if you use additional external vocabularies))
const SDOAdapter = const mySdoAdapter = //get list of classes that are NOT supersededlet listOfClasses = mySdoAdapter