Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mariolazzari/rijks

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mariolazzari/rijks

Rijksmuseum REST APIs client TypeScript based

  • 0.0.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by25%
Maintainers
1
Weekly downloads
 
Created
Source

Rijks


This package is a wrapper around the public REST APIs of Rijksmuseum (Amsterdam).

Prerequisites

In order to use this package, you need an api key: You can read more on how to obtain the API key on this page.

This package requires NodeJS (version 18 or later) and a node package manager (Npm, Yarn, Pnpm or Bun).

To make sure you have them available on your machine, try running the following command.

$ npm -v && node -v
v10.1.0
v18.18.0

Gettting started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.


Installation

BEFORE YOU INSTALL: please read the prerequisites.

Start with cloning this repo on your local machine:

$ git clone https://github.com/mariolazzari/rijks.git
$ cd rijks

To install and set up the library, run:

npm install @mariolazzari/rijks

Usage

Import package

import Rijks from "@mariolazzari/rijks"

Watch mode

npm test

Unit testing

npm test

Bulding new version

npm build

This task will create a distribution version of the project inside your local dist/ folder

Rijks class

Rijks **class++ content handles all the requests and the responses to the thrre main Rijks museum REST APIs.

Constructor

In order to initialize Rijks client:

const rijks = new Rijks(API_KEY, culture?)

Constructor parameters

ParameterTypeRequiredDefault
apiKeystringYes
cultureCultureNoen

Result

This interface handles all REST APIs responses.

interface Result<T> {
  success: boolean;
  status: number;
  data?: T;
  error?: string;
}

Types

In order to implement all features, the following common types have been implemended:

Culture type

Culture type contains all supported cultures.

type Culture = "en | nl"
Sort type

Sort type contains all supported sorting criterias.

type Sort = | "relevance" 
  | "objectYype" 
  | "chronologic" 
  | "achronologic" 
  | "artist" 
  | "artistDesc"
CountFacets

This type has the following definition:

type CountFacets = {
  hasimage: number;
  ondisplay: number;
};
ArtObject

This interface has the following structure:

interface ArtObject {
  links: Link;
  id: string;
  objectNumber: string;
  title: string;
  hasImage: boolean;
  principalOrFirstMaker: string;
  longTitle: string;
  showImage: boolean;
  permitDownload: boolean;
  webImage?: Image;
  headerImage?: Image;
  productionPlaces: string[];
};

Methods

Rijks client includes the following three methonds:

getCollection

Description

This asynchronous method handles GET /api/[culture]/collection REST API.

Prototype

async getCollection(params: CollectionRequest): Promise<Result<CollectionResponse>> 

Sample code

const params: CollectionRequest = {searchTerm: "Vermeer"}
const collection: CollectionResponse = await rijks.getCollection(params)
CollectionRequest

This interface contains all the possible parameters handled by getCollection method.

ParameterTypeRequiredDefault
searchTermstringYes
pagenumberYes1
perPagenumberYes10
formatFormatjson
cultureCultureen
involvedMakerstring
typestring
materialstring
techniquestring
periodstring
hexstring
imageOnlystringtrue
topPiecesstringtrue
sortSort
CollectionResponse

This interface contains all the values returned by getCollection method

ParameterTypeRequiredDefault
elapsedMillisecondsnumberYes0
countnumberYes0
countFacetsCountFacets
artObjectsArtObjects[][]

getCollectionDetails

Description

This method handles GET /api/[culture]/collection/[object-number] REST API.

Prototype

async getCollectionDetails(params:CollectionDetailsRequst) : Promise<Result<CollectionDetailsResponse>>

Authors

  • Mario Lazzari - Initial work

Keywords

FAQs

Package last updated on 16 Oct 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc