Package Exports
- schema-org-adapter
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (schema-org-adapter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Schema.org Adapter
Fast, simple & flexible API for the Schema.org Vocabulary (and vocabulary extensions!) for Node and Browsers
const SDOAdapter = require('schema-org-adapter')
const mySDOAdapter = new SDOAdapter()
const urlLatestSDO = await mySDOAdapter.constructSDOVocabularyURL('latest', 'all-layers')
// resolves to "https://raw.githubusercontent.com/schemaorg/schemaorg/master/data/releases/6.0/all-layers.jsonld" if 6.0 is the latest version
await mySDOAdapter.addVocabularies([urlLatestSDO])
let Hotel = mySDOAdapter.getClass('schema:Hotel')
Hotel.getProperties() // 117 -> ["schema:audience", "schema:checkinTime", "schema:availableLanguage", ...]
Hotel.getSuperClasses(false) //only direct superclasses: 1 -> ["schema:LodgingBusiness"]
Hotel.getSuperClasses() //5 -> ["schema:LodgingBusiness", "schema:LocalBusiness", "schema:Place", "schema:Organization", "schema:Thing"]
let address = mySDOAdapter.getProperty("schema:address")
address.getRanges() // 2 -> ["schema:PostalAddress", "schema:Text"]
address.getDomains(false) // only direct domains: 5 -> ["schema:Place", "schema:GeoCoordinates", "schema:GeoShape", "schema:Person", "schema:Organization"]
address.getDomains() // 229 -> ["schema:Place", "schema:Accommodation", "schema:TouristAttraction", ...]Installation
NPM
Install the npm package:
npm install schema-org-adapter
Require the package:
const SDOAdapter = require('schema-org-adapter')Browser
Script-include the bundled package in /dist or load via a cdn:
<script src="https://cdn.jsdelivr.net/gh/semantifyit/schema-org-adapter/dist/schema-org-adapter.min.js"></script>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 = require('schema-org-adapter')
const mySdoAdapter = new SDOAdapter()
//get list of classes that are NOT superseded
let listOfClasses = mySdoAdapter.getAllClasses({
"isSuperseded": false
})