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

unbody

v0.0.4

Published

This is the official Unbody client for typescript/javascript

Downloads

1

Readme

Unbody

This is the official Unbody client for typescript/javascript

Installation

You can install the Unbody client using npm or yarn:

# using npm
npm install unbody

# using yarn
yarn add unbody

Sub-packages

This package contains the following sub-packages:

Usage/Examples

Instantiate

import { Unbody } from 'unbody'

const unbody = new Unbody({
  apiKey: 'your api key',
  projectId: 'your project key',
})

note: using this on client-side of your application can lead to crawling your data!

Transformers

You can use this option to parse JSON strings in the response the way you want

import { Unbody } from 'unbody'

const unbody = new Unbody({
  apiKey: 'your api key',
  projectId: 'your project key',
  GoogleDoc: {
    mentions(data: string): { [p: string]: any } {
      return {} // Any format you want
    },
  },
})

Get methods

You can use this method to get data from any source that you have in Unbody panel

note: examples are for googleDoc but you can replace that with other sources like imageBlock, audioFile etc...

Get without any query

unbody.get.googleDoc
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Where - simple query using object param

unbody.get.googleDoc
  .where({ title: 'My google doc title' })
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Where - advance query using callback param

unbody.get.googleDoc
  .where(({ Like, GreaterThan }) => {
    return {
      title: Like('Document'),
      size: GreaterThan(20),
    }
  })
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Ask - simple usage

unbody.get.googleDoc
  .ask('What is the price of bitcoin?')
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Ask - selecting properties to look for your question response in

unbody.get.googleDoc
  .ask('What is the price of bitcoin?', ['summary'])
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

or you can just pass arguments as an object

unbody.get.googleDoc
  .ask({ question: 'What is the price of bitcoin?', properties: ['summary'] })
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Near text - simple usage

unbody.get.googleDoc
  .nearText(['bitcoin', 'price'])
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Near text - specify the distance from the text

unbody.get.googleDoc
  .nearText(['bitcoin', 'price'], 1.5)
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

or you can just pass arguments as an object

unbody.get.googleDoc
  .nearText({ distance: 1.5, concepts: ['bitcoin', 'price'], ...etc })
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Near vector - simple usage

unbody.get.googleDoc
  .nearVector(1)
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Near vector - specify the distance from the text

unbody.get.googleDoc
  .nearVector(1, 0.5)
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

or you can just pass arguments as an object

unbody.get.googleDoc
  .nearText({ distance: 1.5, vector: [1, 20], ...etc })
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Group - simple usage

unbody.get.googleDoc
  .group(3.5)
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Group - specify the type

unbody.get.googleDoc
  .group(3.5, 'closest')
  .limit(10)
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

or you can just pass arguments as an object

unbody.get.googleDoc
  .group({ force: 3.5, type: 'closest' })
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Group By - simple usage

unbody.get.googleDoc
  .groupBy('title')
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Group By - specify the groups

unbody.get.googleDoc
  .groupBy('title', 3)
  .limit(10)
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

or you can just pass arguments as an object

unbody.get.googleDoc
  .group({ path: 'title', groups: 3, ...etc })
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Sort, Limit and Offset - using for pagination

unbody.get.googleDoc
  .limit(10)
  .offset(1)
  .sort('title', 'asc')
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Select - you can specify which fields to retrieve (by default all fields will be retrieved)

unbody.get.googleDoc
  .select('title', 'blocks.ImageBlock.alt')
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Additional - you can specify which additional fields to retrieve (by default all fields will be retrieved)

unbody.get.googleDoc
  .select('title', 'blocks.ImageBlock.alt')
  .exec()
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Aggregate methods

All the methods in get applies to this, except for additional

Other methods in Get and Aggregate

You can use getGraphQuery and getJsonQuery for debugging purposes