Giter VIP home page Giter VIP logo

lod-opendata's Introduction

lod-opendata

A NPM package for get data of Lëtzebuerger Online Dictionnaire (LOD) from data.public.lu.

Author : Roberto Entringer
License: MIT
Repo on Github : https://github.com/robertoentringer/lod-opendata
Npm package : https://www.npmjs.com/package/lod-opendata

Installation

$ npm install lod-opendata

Usage

const opendata = require('lod-opendata')

// Example with async / Await

const asyncAwait = async () => {
  //Get all fields. Use defaults
  try {
    const result = await opendata()
    console.log(result)
  } catch (error) {
    console.log(error.message)
  }
}
asyncAwait()

// Example with then / catch

const thenCatch = () => {
  //Get all fields. Use defaults
  opendata()
    .then((obj) => console.log(obj))
    .catch((err) => console.log(err.message))

  //Get all fields from the main `resources` field'
  opendata('resources')
    .then((obj) => console.log(obj))
    .catch((err) => console.log(err.message))

  //Get the `url` field from `resources` field'
  opendata('resources/{url}')
    .then(({ resources: [{ url }] }) => console.log(url))
    .catch((err) => console.log(err.message))

  //Get multiple main fields: `page`, `title`, `slug`
  opendata('page,title,slug')
    .then(({ page, title, slug }) => console.log(page, title, slug))
    .catch((err) => console.log(err.message))

  //Get multiple subfields: `id`, `published`, `latest` from main field `resources`
  opendata('resources/{id,published,latest}')
    .then(({ resources: [{ id, published, latest }] }) => console.log(id, published, latest))
    .catch((err) => console.log(err.message))

  //Get all fields pass a custom api `url`. Useful if the API URL changes.
  const url = 'http://data.public.lu/api/1/datasets/letzebuerger-online-dictionnaire-raw-data'
  opendata('', url)
    .then((obj) => console.log(obj))
    .catch((err) => console.log(err.message))
}
thenCatch()

See all fields available :
https://data.public.lu/api/1/datasets/letzebuerger-online-dictionnaire/

API Documentation - Portail Open Data :
https://data.public.lu/en/docapi/

lod-opendata's People

Contributors

dependabot[bot] avatar robertoentringer avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.