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 🙏

© 2026 – Pkg Stats / Ryan Hefner

qryma-javascript

v0.1.2

Published

Qryma Search API JavaScript SDK

Downloads

286

Readme

Qryma JavaScript SDK

A JavaScript SDK for the Qryma Search API, providing a simple and intuitive interface for accessing Qryma's powerful search capabilities.

Table of Contents

Installation

You can install the Qryma JavaScript SDK using npm:

npm install qryma-javascript

Or using yarn:

yarn add qryma-javascript

Quick Start

// To install: npm i qryma-javascript
const { qryma } = require('qryma-javascript');

const client = qryma({ apiKey: "ak-********************" });

client.search("artificial intelligence", {
    lang: "en"
})
.then(console.log);

Usage Examples

Basic Search

const { qryma } = require('qryma-javascript');

const client = qryma({ apiKey: "ak-********************" });

// Simple search with just query
client.search("python programming")
    .then(response => {
        // Access the organic results
        const results = response.organic || [];
        results.forEach(result => {
            console.log(result.title);
            console.log(result.link);
            console.log(result.snippet);
            console.log();
        });
    })
    .catch(error => {
        console.error(error);
    });

Using Async/Await

const { qryma } = require('qryma-javascript');

const client = qryma({ apiKey: "ak-********************" });

async function search() {
    try {
        const response = await client.search("python programming");

        // Access the organic results
        const results = response.organic || [];
        results.forEach(result => {
            console.log(result.title);
            console.log(result.link);
            console.log(result.snippet);
            console.log();
        });
    } catch (error) {
        console.error(error);
    }
}

search();

Search with All Parameters

const { qryma } = require('qryma-javascript');

const client = qryma({ apiKey: "ak-********************" });

// Search with all available parameters
client.search("machine learning tutorials", {
    lang: "en",
    safe: false,
    mode: "snippet",
    maxResults: 5
})
.then(response => {
    const results = response.organic || [];
    console.log(`Found ${results.length} results`);
});

Custom Base URL and Timeout

const { qryma } = require('qryma-javascript');

const client = qryma({
    apiKey: "ak-********************",
    baseUrl: "https://custom.qryma.com",
    timeout: 60
});

client.search("custom search").then(console.log);

API Response Format

The search() method returns the raw API response in the following format:

{
  "organic": [
    {
      "title": "Result Title",
      "date": "",
      "link": "https://example.com",
      "position": 1,
      "site_name": "Example.com",
      "snippet": "Description text...",
      "text": "Full text..."
    }
  ]
}

Field descriptions:

  • title: Search result title
  • date: Publication date (if available)
  • link: URL of the search result
  • position: Position in the results list
  • site_name: Name of the website
  • snippet: Brief description or excerpt from the page
  • text: Full text of the page

API Reference

qryma(config)

Factory function to create a Qryma client instance.

Parameters:

  • config.apiKey: Your Qryma API key (required)
  • config.baseUrl: Base URL for the API (optional, default: https://search.qryma.com)
  • config.timeout: Request timeout in seconds (optional, default: 30)

Returns:

  • QrymaClient instance

QrymaClient.search(query, options?)

Perform a search with the given query and return the raw API response.

Parameters:

  • query: Search query string (required)
  • options: Search options (optional)
    • lang: Language code for search results (e.g., 'am' for Amharic, 'en' for English) (optional)
    • maxResults: Maximum number of results to return (optional, default: 5, range: 1-10)
    • safe: Safe search mode: true or false (optional, default: false)
    • mode: Result detail mode: 'snippet' for brief descriptions or 'fulltext' for detailed content (optional, default: 'snippet')

Returns:

  • Promise<QrymaResponse>: Promise resolving to raw API response object containing the search results

Alternative: Using QrymaClient class directly

If you prefer, you can still use the class directly:

const { QrymaClient } = require('qryma-javascript');

const client = new QrymaClient("ak-********************");
client.search("artificial intelligence", { lang: "en" })
    .then(console.log);

Configuration

Environment Variables

You can configure the API key using environment variables:

export QRYMA_API_KEY="your-api-key"

Then in your code:

const { qryma } = require('qryma-javascript');

const client = qryma({ apiKey: process.env.QRYMA_API_KEY });

Error Handling

The SDK returns rejected promises for API errors:

const { qryma } = require('qryma-javascript');

const client = qryma({ apiKey: "ak-********************" });

client.search("test query")
    .then(response => {
        const results = response.organic || [];
        // Process results...
    })
    .catch(error => {
        if (error.message.includes("timed out")) {
            console.error("Network timeout error");
        } else if (error.message.includes("API request failed")) {
            console.error("API error");
        } else {
            console.error("General error:", error.message);
        }
    });

Common error conditions:

  • Invalid API key
  • Rate limiting
  • Network timeouts
  • Invalid parameters

Testing

The SDK includes a simple test file. To run the test:

  1. First, replace the placeholder API key in tests/test-search.js with your actual API key
  2. Then run the test:
npm run test

Contributing

Contributions are welcome! Please see our contributing guide for more information.

License

MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions, please:

  1. Check the documentation
  2. Open an issue on GitHub
  3. Contact support at [email protected]

Changelog

0.1.0

  • Basic search functionality
  • Simple factory function qryma() for easy initialization
  • Advanced search with SearchOptions
  • Result extraction methods
  • API status check
  • Error handling
  • Comprehensive data models