npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

steltix-search-service

v1.2.14

Published

SearchService

Downloads

42

Readme

Installation

install the package

npm install steltix-search-service --save

Add the references

import { SteltixSearchService, SelectApi } from 'steltix-search-service-dev';
//or
import * as steltixSearchService from 'steltix-search-service-dev';

SteltixSearchService

This service is made for Steltix to access multiple API's and calls from one central location

this I created as an entry point here you can get access all the services (steltix-search.service.ts)

//imports
import { OwlBotService } from './Services/owl-bot.service';
import { DictionaryApiService, SelectApi } from './Services/dictionary-api.service';
import { SweetSearchSevice } from './Services/sweet-search.service';
import { WolframAlphaService } from './Services/wolfram-alpha.service';
import { WordsApiService } from './Services/words-api.service';


export class SteltixSearchService {
    OwlBotService = new OwlBotService();
    SelectApi = new SelectApi();
    WordsApiService = new WordsApiService();
    DictionaryApiService = new DictionaryApiService();
    SweetSearchSevice = new SweetSearchSevice();
    WolframAlphaService = new WolframAlphaService();
}

usage:

import { SteltixSearchService, SelectApi } from 'steltix-search-service-dev';

class test{
   testApp() {
        let sss = new SteltixSearchService();
        //DictionaryApiService
        sss.DictionaryApiService.selectApi(SelectApi.CollegiateDictionary);
        sss.DictionaryApiService.getQueryResults("searchTerm")
        //OwlBotService
        sss.OwlBotService.getQueryResults("searchTerm");
        //WordsApiService
        sss.WordsApiService.getQueryResults("searchTerm");
        //SweetSearchSevice
        sss.SweetSearchSevice.getQueryResults("searchTerm");
        //WolframAlphaService
        sss.WolframAlphaService.getQueryResults("searchTerm");
    }
}

Services

Please note all search terms must be URL encoded

DictionaryApiService

This service has multiple api services and auth keys therefore I have made a class to set it

here is where you would set it "dictionary-api.service.ts"

export class SelectApi {
    static CollegiateDictionary: SelectApiModel = { "token": "Your API KEY", "urlExt": "references/collegiate/json" };
    static CollegiateThesaurus: SelectApiModel = { "token": "Your API KEY", "urlExt": "references/thesaurus/json" };
    static IntermediateThesaurus: SelectApiModel = { "token": "Your API KEY", "urlExt": "references/ithesaurus/json" };
    static SpanishEnglishDictionary: SelectApiModel = { "token": "Your API KEY", "urlExt": "references/spanish/json" };
    static MedicalDictionary: SelectApiModel = { "token": "Your API KEY", "urlExt": "references/medical/json" };
    static ElementaryDictionary: SelectApiModel = { "token": "Your API KEY", "urlExt": "references/sd2/json" };
    static IntermediateDictionary: SelectApiModel = { "token": "Your API KEY", "urlExt": "references/sd3/json" };
    static SchoolDictionary: SelectApiModel = { "token": "Your API KEY", "urlExt": "references/sd4/json" };
    static LearnersDictionary: SelectApiModel = { "token": "Your API KEY", "urlExt": "references/learners/json" };
}

once this is set you can use the service please remember to call "DictionaryApiService.selectApi()"

Usage of service:

class test {
    Das = new DictionaryApiService();
    testDictionaryService() {
        this.Das.selectApi(SelectApi.CollegiateDictionary)
        let result = this.Das.getQueryResults("searchTerm");
        result.then((data) => {
            console.log(data);
        });
    }
}

it will return a promise with the data

OwlBotService

this classes api key has to be set in the service

export class OwlBotService extends BaseSearchService {
    constructor() {
        super();
        //TODO: this must be replaced with your token
        this.apiToken = "Your API KEY";
    }
    getQueryResults(searchQuery: string) {
        return Owlbot(this.apiToken).define('owl');
    }
}

usage:

class test {
    Obs = new OwlBotService();
    testOwlBotService() {
        let result = this.Obs.getQueryResults("searchTerm");
        result.then((data) => {
            console.log(data);
        });
    }
}

WordsApiService

this classes api key has to be set in the service

export class WordsApiService extends BaseSearchService {
    constructor() {
        super();
        this.baseUrl = "https://wordsapiv1.p.mashape.com"
        this.queryString = "words";
        this.apiToken = "your api key";
    }

    getQueryResults(searchQuery: string) {
        return this.unirest.get(`${this.baseUrl}/${this.queryString}/${searchQuery}`)
            .header("X-Mashape-Key", this.apiToken)
            .header("Accept", "application/json");
    }
}

usage:

class test {
    Was = new WordsApiService();
    testDictionaryService() {
        let result = this.Was.getQueryResults("searchTerm");
        result.then((data) => {
            console.log(data);
        });
    }
}

WolframAlphaService

this classes api key has to be set in the service

export class WolframAlphaService extends BaseSearchService {
    constructor() {
        super();
        this.baseUrl = "http://api.wolframalpha.com/v2"
        //TODO: change this token
        this.apiToken = "Your api key";
    }
    getQueryResults(searchQuery: string) {
        return this.unirest.get(`${this.baseUrl}/query?appid=${this.apiToken}&input=${searchQuery}?key=${this.apiToken}&includepodid=Result&output=json&format=plaintext`);;
    }
}

usage:

class test {
    Wras = new WolframAlphaService();
    testDictionaryService() {
        let result = this.Wras.getQueryResults("searchTerm");
        result.then((data) => {
            console.log(data);
        });
    }
}

Please Note: The JSON returned in the body is in string format and as such has to be parsed into an object this unfortunately is unavoidable as this is the result from the api

SweetSearchService

This service requires no api key but the result in the promise is html

class test {
    Sss = new SweetSearchSevice();
    testDictionaryService() {
        let result = this.Sss.getQueryResults("searchTerm");
        result.then((data) => {
            console.log(data);
        });
    }
}