JSPM

  • Created
  • Published
  • Downloads 105
  • Score
    100M100P100Q76532F
  • License Apache-2.0

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

Package Exports

    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

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

    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

    Technical API documentation

    Data Model of the Schema.org Adapter

    Expected Vocabulary Structure

    Conversion Algorithm for Vocabularies

    Code Examples

    Example for Node

    Example for Browser

    All examples

    Changelog

    History.md

    Migration Guide to v6.0.0

    semantify.it

    Made with ❤ in Tirol!