Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/datastreamapp/datastreamjs

DataSteam API helper in JavaScript
https://github.com/datastreamapp/datastreamjs

Last synced: about 2 months ago
JSON representation

DataSteam API helper in JavaScript

Awesome Lists containing this project

README

        


DataStream Logo


DataStreamJS






DataStream.org API helper. See API documentation for query string values and structure.

## Install

```bash
npm install https://github.com/datastreamapp/datastreamjs
```

## Use

This packages works in the browser and with NodeJS.

### Example

```javascript
import {
setAPIKey,
metadata,
locations,
records,
observations
} from '@datastreamapp/datastreamjs'

setAPIKey('xxxxxxxxxx') // secrets should be injected securely

const observationsStream = await observations({
$select:
'DOI,ActivityType,ActivityMediaName,ActivityStartDate,ActivityStartTime,SampleCollectionEquipmentName,CharacteristicName,MethodSpeciation,ResultSampleFraction,ResultValue,ResultUnit,ResultValueType',
$filter: `DOI eq '10.25976/xxxx-xx00'`,
$top: 10000
})

for await (const observation of observationsStream) {
// use record
}
```

### Example: save to file

```javascript
import { pipeline } from '@datastream/core'
import { csvFormatStream } from '@datastream/csv/format'
import { createWriteStream } from 'node:fs'

import {
setAPIKey,
metadata,
locations,
records,
observations
} from '@datastreamapp/datastreamjs'

setAPIKey('xxxxxxxxxx') // secrets should be injected securely

const recordsStream = await records({
$select:
'DOI,ActivityType,ActivityMediaName,ActivityStartDate,ActivityStartTime,SampleCollectionEquipmentName,CharacteristicName,MethodSpeciation,ResultSampleFraction,ResultValue,ResultUnit,ResultValueType',
$filter: `DOI eq '10.25976/xxxx-xx00'`,
$top: 10000
})

await pipeline([
recordsStream,
csvFormatStream(),
createWriteStream('/path/to/output.csv')
])
```