New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

nypl-data-api-client

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nypl-data-api-client

Simple client for interacting with NYPL's internal data api

latest
Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

NYPL Data API Client

Helper lib for interacting with the (internal) NYPL Data API

Installation

Install it via npm for use inside your project:

npm i nypl-data-api-client --save

Usage

const NyplClient = require('nypl-data-api-client')
var client = new NyplClient({ base_url: 'http://example.com/api/v0.1/' })

Client options include:

  • base_url: Base URL for the api (e.g. 'http://example.com/api/v0.1/'). (Alternatively use NYPL_API_BASE_URL)
  • oauth_key: OAUTH key (Alternatively use NYPL_OAUTH_KEY)
  • oauth_secret: OAUTH secret (Alternatively use NYPL_OAUTH_SECRET)
  • oauth_url: OAUTH URL. (Alternatively use NYPL_OAUTH_URL)
  • log_level: Set log level (i.e. info, error, warn, debug). Default env.LOG_LEVEL or 'error'

Note that you must specify URL base for the api via base_url config (as above) or via NYPL_API_BASE_URL env variable. The value should include everything from the protocol to the version number in the path (as above). .

client.get (path, opts)

Returns a Promise that resolves content at path (e.g. 'current-schemas/Item')

Params:

  • path: String path to retrieve
  • opts: Optional options hash that may include:
    • cache: Boolean, default true. Controls whether or not response is cached (using default configuration of node-cache

For example, to get the "Item" stream schema:

client.get('current-schemas/Item').then((schema) => {
  // Now we can build an avro encoder by parsing the escaped "schema" prop:
  var avroType = require('avsc').parse(JSON.parse(schema.schema))
})

client.post (path, data)

Returns a Promise that resolves after submitting data to path

Params:

  • path: String path to retrieve
  • data: Object/data you want to POST to the endpoint

For example, to post a new "TestSchema" schema:

client.post('schemas/TestSchema', '{ "name": "TestSchema", "type": "record", "fields": [ ... ] }')
  .then((resp) => {
    if (JSON.parse(resp).data.stream !== 'TestSchema') throw Error('Error creating schema...')
  })

Testing

npm test

FAQs

Package last updated on 17 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts