DataStream.org API helper. See API documentation for query string values and structure.
npm install https://github.com/datastreamapp/datastreamjs
This packages works in the browser and with NodeJS.
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
}
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')
])