# @ubw/mediatum-rest-client

> Convenience wrapper around the RESTful mediaTUM API

Latest version **0.4.1** (published 2018-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ubw/mediatum-rest-client
pnpm add @ubw/mediatum-rest-client
yarn add @ubw/mediatum-rest-client
bun add @ubw/mediatum-rest-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2018-09-09 |
| First published | 2018-07-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 113 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Michael Mayer |
| Maintainers | schnittstabil |
| Keywords | mediaTUM, api, fetch, get, publications |

## Links

- npm: https://www.npmjs.com/package/@ubw/mediatum-rest-client
- Repository: https://gitlab.com/ubw/mediatum-rest-client
- Homepage: https://gitlab.com/ubw/mediatum-rest-client#README
- Issues: https://gitlab.com/ubw/mediatum-rest-client/issues
- npm.io page: https://npm.io/package/@ubw/mediatum-rest-client

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.4.1 (latest) — 2018-09-09
- 0.4.0 — 2018-09-09
- 0.3.1 — 2018-07-25
- 0.3.0 — 2018-07-23
- 0.2.0 — 2018-07-22
- 0.1.1 — 2018-07-11

## README

# mediatum-rest-client

> Convenience wrapper around the RESTful [mediaTUM](https://github.com/mediatum/mediatum) API


## Install

```
$ npm install @ubw/mediatum-rest-client
```


## Usage

```js
const ubwMediatumRestClient = require('@ubw/mediatum-rest-client');

ubwMediatumRestClient.getAllChildren(1433089, {limit: 1}).then(console.log);
// =>
/*
{
	data: [
		{
			type: '1433089',
			id: 1335274,
			attributes: {
				'author.firstname': 'Thomas',
				type: 'Dissertation',
				// ...
			},
			links: {
				self: {
					href: 'https://mediatum.ub.tum.de/?id=...'
				}
			}
		}
	],
	meta: {
		username: 'guest',
		status: 'ok',
		method: 'GET',
		nodelist_limit: '1',
		nodelist_start: 0,
		// ...
	}
}
 */
```


## API


### .getAllChildren(id, [options])

Returns a `Promise`.


#### id

Type: `Number`

The [`id` of the mediaTUM node](https://mediatum.ub.tum.de/services/export/) to query.


#### options

Type: `Object`

See [mediaTUM query parameters](https://mediatum.ub.tum.de/services/export) for additional options.


##### format

Type: `String`<br>
Default: `'json'`


##### acceptcached

Type: `Number`<br>
Default: `180`


##### mask

Type: `String`<br>
Default: `'none'`


##### attrspec

Type: `String`<br>
Default: `'all'`


##### baseUrl

Type: `String`<br>
Default: `'https://mediatum.ub.tum.de'`


##### queryUrl

Type: `Function`<br>
Default: `` (baseUrl, id, endpoint) => `${baseUrl}/services/export/node/${id}/${endpoint}` ``


##### selfHref

Type: `Function`<br>
Default: `` (node, baseUrl) => `${baseUrl}/?id=${node.id}` ``


##### schema

Type: `Object`<br>
Default: `undefined`

Expected `attributes` schema.

```js
const schema = {
	author: String,      // convert attribute to string
	title: undefined,    // include attribute, but do not mind the type
	isAwesome: Boolean,  // convert attribute to boolean
	year: 'year',        // convert attribute to integer
	pages: 'int',        // convert attribute to integer
	created: Date,       // convert attribute to date
};

getAllChildren(42, {schema})
// => nodes in nodelist will only have attributes mentioned above
/*
{
	data: [
		{
			type: '21',
			id: 42,
			attributes: {
				author: 'Douglas Adams',
				title: 'The Hitchhiker’s Guide to the Galaxy',
				isAwesome: true,
				year: 1979,
				pages: 158,
				created: Date(...)
			},
			links: {
				self: {
					href: 'https://mediatum.ub.tum.de/?id=42'
				}
			}
		}
	],
	meta: {
		// ...
	}
}
 */
```


## Related

* [mediaTUM - Medienserver](https://mediatum.github.io)
* [mediaTUM Core](https://github.com/mediatum/mediatum)
* [@ubw/mediatum-query-builder](https://gitlab.com/ubw/mediatum-query-builder) – Convenience query builder for the RESTful mediaTUM API


## License

MIT © [Michael Mayer](http://schnittstabil.de)

---
_Source: https://npm.io/package/@ubw/mediatum-rest-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
