# hyperfetch

> Fetch JSON-LD from any URI if possible

Latest version **0.2.2** (published 2019-05-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install hyperfetch
pnpm add hyperfetch
yarn add hyperfetch
bun add hyperfetch
```

## 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.2.2 |
| Published | 2019-05-28 |
| First published | 2019-04-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Angelo Veltens |
| Maintainers | aveltens |
| Keywords | json-ld, rdf, linked, data, solid |

## Links

- npm: https://www.npmjs.com/package/hyperfetch
- Repository: https://gitlab.com/angelo-v/hyperfetch
- Homepage: https://gitlab.com/angelo-v/hyperfetch#readme
- Issues: https://gitlab.com/angelo-v/hyperfetch/issues
- npm.io page: https://npm.io/package/hyperfetch

## Dependencies (5)

- [rdfxml2jsonld](https://npm.io/package/rdfxml2jsonld.md) ^0.2.0
- [@rdfjs/fetch-lite](https://npm.io/package/@rdfjs/fetch-lite.md) ^2.0.0
- [@rdfjs/formats-common](https://npm.io/package/@rdfjs/formats-common.md) ^2.0.0
- [rdfxml-streaming-parser](https://npm.io/package/rdfxml-streaming-parser.md) ^1.2.3
- [@rdfjs/serializer-jsonld](https://npm.io/package/@rdfjs/serializer-jsonld.md) ^1.2.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.2.2 (latest) — 2019-05-28
- 0.2.1 — 2019-05-08
- 0.2.0 — 2019-05-04
- 0.0.1-alpha.3 — 2019-04-24
- 0.0.1-alpha.2 — 2019-04-24
- 0.0.1-alpha.1 — 2019-04-24

## README

# Hyperfetch

Hyperfetch tries to fetch JSON-LD from any URI.

## Quickstart

```javascript
import hyperfetch from 'hyperfetch'

hyperfetch('https://api.example/resource').then(jsonld => {
  console.log(jsonld)
});

```

## Supported Content-Types

A resource representation may be delivered as one of the following Content-Types:

 - application/ld+json
 - application/rdf+xml
 - application/trig
 - application/n-quads
 - application/n-triples
 - text/n3
 - text/turtle

**For any supported Content-Type, hyperfetch will return a JSON-LD object!**

Unsupported Content-Types cause an error.

## Passing custom options

You may pass an options object as second argument, to set for example HTTP headers or use a specific implementation of `fetch`.

```javascript
hyperfetch('https://api.example/resource', {
  // custom options
})
```

For details see [documentation of the underlying library @rdfjs/fetch-lite](https://github.com/rdfjs/fetch-lite#options)

## Storing data to hyperfact

The data retrieved by hyperfetch can directly be merged to a [hyperfact](https://www.npmjs.com/package/hyperfact) store:

```javascript

import hyperfetch from 'hyperfetch';
import createStore from 'hyperfact';

export const facts = createStore();

hyperfetch("https://api.example/resource")
  .then(resource => facts.merge(resource))
```

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