Giter VIP home page Giter VIP logo

framework-api-client's Introduction

Framework API Client

Client for CDLI framework API.

Install

A prerequisite for this client is Node.JS and a package manager like npm, which usually comes with it.

npm install -g https://github.com/cdli-gh/framework-api-client

Or install it locally into an existing project:

npm install https://github.com/cdli-gh/framework-api-client

Alternatively, the command can be run with npx:

npx cdli-api-client --help

Getting started

Right now, the client only supports a basic operation: exporting parts of the database as linked data (or specifically N-Triples). The parts that can be chosen are the types of entities in the catalogue, such as artifacts, materials, proveniences, inscriptions and periods.

Command-Line Interface

cdli [command]

Commands:
  cdli export  Export linked data

Options:
  --version          Show version number                               [boolean]
  --host, -h         Host URL to use for API calls
                         [string] [default: "https://cdli.mpiwg-berlin.mpg.de/"]
  --format, -f       File format
                  [choices: "ndjson", "csv", "tsv", "ntriples", "bibtex", "atf"]
  --output-file, -o  Output file (outputs to stdout by default)
  --help             Show help                                         [boolean]

Export

cli.js export

Export linked data

Options:
  --version          Show version number                               [boolean]
  --host, -h         Host URL to use for API calls
                         [string] [default: "https://cdli.mpiwg-berlin.mpg.de/"]
  --format, -f       File format
                  [choices: "ndjson", "csv", "tsv", "ntriples", "bibtex", "atf"]
  --output-file, -o  Output file (outputs to stdout by default)
  --help             Show help                                         [boolean]
  --entities, -e     Which types of entities to fetch
        [array] [choices: "archives", "artifacts", "artifactsExternalResources",
            "artifactsMaterials", "collections", "dates", "dynasties", "genres",
  "inscriptions", "languages", "materials", "materialAspects", "materialColors",
                 "periods", "proveniences", "publications", "regions", "rulers"]

So to export place-related entities from a locally-running framework instance you could do this:

cdli export \
  --host http://localhost:2354/ \
  --entities archives proveniences regions \
  --output-file places.nt

Programming Interface

const CDLI = require('cdli-api-client')

const client = new CDLI.Client('http://localhost:2354/')

// process logging
client.on('log', msg => process.stderr.write(msg))

client.export(['archives', 'proveniences', 'regions' ], 'places.nt')
    .then(entities => {
        for (const { status, reason } of entities) {
            if (status === 'rejected') {
                console.error(reason)
            }
        }
    })

framework-api-client's People

Contributors

larsgw avatar epageperron avatar dependabot[bot] avatar khoidt 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.