Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@internetarchive/search-service
Advanced tools
A service for searching and retrieving metadata from the Internet Archive.
npm install @internetarchive/search-service
import {
SearchService,
SortParam,
SortDirection
} from '@internetarchive/search-service';
const searchService = SearchService.default;
const dateSort = new SortParam('date', 'desc')
const params = new SearchParams({
query: 'collection:books AND title:(goody)',
sort: [dateSort],
rows: 25,
start: 0,
fields: ['identifier', 'collection', 'title', 'creator']
});
const result = await searchService.performSearch(params);
if (result.success) {
const searchResponse = result.success;
searchResponse.response.numFound // => number
searchResponse.response.docs // => Metadata[] array
searchResponse.response.docs[0].identifier // => 'identifier-foo'
}
const metadataResponse: MetadataResponse = await searchService.fetchMetadata('some-identifier');
metadataResponse.metadata.identifier // => 'some-identifier'
metadataResponse.metadata.collection.value // => 'some-collection'
metadataResponse.metadata.collection.values // => ['some-collection', 'another-collection', 'more-collections']
Internet Archive Metadata is expansive and nearly all metadata fields can be returned as either an array, string, or number.
The Search Service handles all of the possible variations in data formats and converts them to their appropriate types. For instance on date fields, like date
, it takes the string returned and converts it into a native javascript Date
value. Similarly for duration-type fields, like length
, it takes the duration, which can be seconds 324.34
or hh:mm:ss.ms
and converts them to a number
in seconds.
There are parsers for several different field types, like Number
, String
, Date
, and Duration
and others can be added for other field types.
See src/models/metadata-fields/field-types.ts
metadata.collection.value // return just the first item of the `values` array, ie. 'my-collection'
metadata.collection.values // returns all values of the array, ie. ['my-collection', 'other-collection']
metadata.collection.rawValue // return the rawValue. This is useful for inspecting the raw response received.
metadata.date.value // return the date as a javascript `Date` object
metadata.length.value // return the length (duration) of the item as a number of seconds, can be in the format "hh:mm:ss" or decimal seconds
npm install
npm run test
npm run start
npm run format
FAQs
A search service for the Internet Archive
The npm package @internetarchive/search-service receives a total of 84 weekly downloads. As such, @internetarchive/search-service popularity was classified as not popular.
We found that @internetarchive/search-service demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.