npm package: @flowereatfish/tvgh-library-collection-api
Description: Unofficial Taipei Veterans General Hospital Medical Library Collection API
Author: Eating-Fish Flower
Latest version: 1.1.0
Deprecated: Go to https://www.npmjs.com/package/tvgh-library-collection-crawler because the package name has been changed

# Unofficial Taipei Veterans General Hospital Medical Library Collection API

[![NPM version](https://img.shields.io/npm/v/@flowereatfish/tvgh-library-collection-api.svg)](https://www.npmjs.com/package/@flowereatfish/tvgh-library-collection-api)
[![Travis-CI status](https://travis-ci.com/FlowerEatFish/tvgh-library-collection-api.svg?branch=master)](https://travis-ci.com/FlowerEatFish/tvgh-library-collection-api/builds)
[![AppVeyor status](https://ci.appveyor.com/api/projects/status/aeiv3t9fajpgiabc/branch/master?svg=true)](https://ci.appveyor.com/project/FlowerEatFish/tvgh-library-collection-api/history)
[![Codecov status](https://codecov.io/gh/FlowerEatFish/tvgh-library-collection-api/branch/master/graph/badge.svg)](https://codecov.io/gh/FlowerEatFish/tvgh-library-collection-api/commits)
[![Dependencies status](https://david-dm.org/FlowerEatFish/tvgh-library-collection-api/status.svg)](https://david-dm.org/FlowerEatFish/tvgh-library-collection-api)
[![Code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io/)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

非官方臺北榮民總醫院醫學圖書館 API

- [Unofficial Taipei Veterans General Hospital Medical Library Collection API](#Unofficial-Taipei-Veterans-General-Hospital-Medical-Library-Collection-API)
  - [Requirements](#Requirements)
  - [Installations](#Installations)
  - [Usage](#Usage)
    - [Node.js version 8 or higher (with full Async/Await support)](#Nodejs-version-8-or-higher-with-full-AsyncAwait-support)
    - [Others](#Others)
  - [Demo](#Demo)
    - [Commands](#Commands)
    - [Results](#Results)
  - [API documentation](#API-documentation)
    - [Input parameters](#Input-parameters)
    - [Output results](#Output-results)

## Requirements

- This construct uses [Axios.js](https://github.com/axios/axios), so you need to care the Cross-Origin Requests (CORS).

## Installations

- NPM

```shell
npm install @flowereatfish/tvgh-library-collection-api --save
```

- Yarn

```shell
yarn add @flowereatfish/tvgh-library-collection-api
```

## Usage

### Node.js version 8 or higher (with full Async/Await support)

```javascript
const tvghLibraryCollectionApi = require('@flowereatfish/tvgh-library-collection-api');

const run = async () => {
  const results = await tvghLibraryCollectionApi('橡皮擦計畫');
  console.log(results);
};

run();
```

### Others

```javascript
const tvghLibraryCollectionApi = require('@flowereatfish/tvgh-library-collection-api');

tvghLibraryCollectionApi('橡皮擦計畫')
  .then(results => console.log(results));
```

## Demo

### Commands

```shell
# To download the files and install packages.
$ git clone https://github.com/FlowerEatFish/tvgh-library-collection-api.git
$ cd tvgh-library-collection-api
$ yarn install # npm install

# To run a demo.
$ yarn start # npm start
```

### Results

```shell
>>> You search data using keyword "愛因斯坦的時空".

{
  title: '愛因斯坦的時空',
  author: '李家維',
  isbn: null,
  issn: null,
  edition: null,
  pub_year: '2017[民106]',
  pub_place: '臺北市 :',
  pub_info: '臺北市 : 遠流, 2017[民106]',
  shape: '159面 : 彩圖 ; 28公分',
  collection: [
    {
      library: '北榮',
      data_type: '*圖書',
      special_number: '',
      barcode: '00000253432',
      call_number: '331/8466/2017',
      is_flow: true,
      status: '正在查詢...'
    }
  ],
  url: 'http://tghtpe.ent.sirsidynix.net/client/zh_TW/vgh/search/results?qu=%E6%84%9B%E5%9B%A0%E6%96%AF%E5%9D%A6%E7%9A%84%E6%99%82%E7%A9%BA&rw=0&lm=VGHTPE'
}
```

```shell
>>> You search data using keyword "Alzheimer disease".

[ {...}, {...}, ... ] # Array.prototype.length <= 12
```

```shell
>>> You search data using keyword "no-result-as-example".

null
```

## API documentation

### Input parameters

```javascript
import tvghLibraryCollectionApi from '@flowereatfish/tvgh-library-collection-api';

const result = tvghLibraryCollectionApi(
  keyword, // string. Necessary.
           // If you set it as null, it will get an error.
  page, // number. Positive integer. Default: 1.
        // Every page only shows maximum 12 results.
  libraryNumbering, // number. Integer and the range from 0 to 7 are valid. Default: 0.
                    // Each number represents a different library, as follows:
                    // 0: VGHTPE 臺北總院
                    // 1: GANDAU 關渡分院
                    // 2: FLVH   鳳林分院
                    // 3: SAVH   蘇澳分院
                    // 4: TYVH   桃園分院
                    // 5: VHCT   新竹分院
                    // 6: VHTT   臺東分院
                    // 7: VHYL   玉里分院
                    // 8: YSVH   員山分院
)
```

### Output results

```javascript
// If you get one result, it will return an "object".
result = {
  title: string | null,
  author: string | null,
  isbn: string | null,
  issn: string | null,
  edition: string | null,
  pub_year: string | null,
  pub_place: string | null,
  pub_info: string | null,
  shape: string | null,
  collection: object[]
    [
      {
        library: string | null,
        data_type: string | null,
        special_number: string | null,
        barcode: string | null,
        call_number: string | null,
        is_flow: boolean,
        status: '正在查詢...' | null // You always get this result because the text is pre-rendering.
      },
      { ... }, { ... }, ...
    ],
  url: string | null,
};

// If you get two or more results, it will return an "array".
result = [
  {
    ... // This result is the same as above.
  },
  { ... }, { ... }, ...
];

// If you have not got any result, it will return a "null".
result = null;
```