Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/datastreamapp/datastreamjs
- Owner: datastreamapp
- License: mit
- Created: 2022-12-06T21:31:08.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-12T15:20:52.000Z (6 months ago)
- Last Synced: 2024-07-12T17:36:47.304Z (6 months ago)
- Language: JavaScript
- Size: 53.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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')
])
```