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

objective-sdk

v1.0.11

Published

This is the official Typescript library for the Objective APIs. It provides convenient methods for using Objective's APIs.

Downloads

1,091

Readme

Objective TypeScript SDK

The Objective TypeScript SDK provides a powerful and easy-to-use interface for interacting with the Objective API, allowing you to manage object stores and indexes efficiently. This document outlines the installation process, initialization of the Objective class, and details the available methods for working with object stores and indexes.

To get an API Key, visit our website.

To view our official API documentation, visit our docs.

Installation

To install the SDK, run the following command in your project directory:

npm install objective-sdk

or if you use yarn:

yarn add objective-sdk

or if you use pnpm:

pnpm install objective-sdk

Initialization

To start using the SDK, you need to initialize the Objective class. This requires an API key which can be provided directly or through environment variables.

import { ObjectiveClient } from "objective-sdk"

const objective = new ObjectiveClient({
  apiKey: "Your API Key Here",
  baseURL: "https://api.objective.inc/v1", // Optional
  timeout: 600000, // Optional, in milliseconds
  maxRetries: 2, // Optional
  defaultHeaders: { "Custom-Header": "Value" }, // Optional
})

Object Store Methods

The SDK provides methods to interact with object stores, allowing you to create, find, get, delete, upsert, and partially update objects.

Create an Object

objective.objectStore.create(object)

Find Multiple Objects

objective.objectStore.getObjects({
  limit: 20, // Amount of results to return - optional. Default is 10.
  cursor: "1234", // A base64 encoded, URL-safe string to navigate to the next or previous page. - optional
  include_metadata: true, // - Includes metadata, such as the count of total objects in the object store. - optional. Default is false.
  include_object: true, // Include the object in the response. - optional. Default is false.
})

Get a Single Object

objective.objectStore.getObject(objectId)

Delete a Single Object

objective.objectStore.delete(objectId)

Upsert an Existing Object

objective.objectStore.upsert(objectId, object)

Partially Update an Object

objective.objectStore.updatePartial(objectId, object)

Index Methods

The SDK also provides methods to manage indexes, including creating indexes, finding multiple indexes, and retrieving or deleting a single index.

Create an Index

objective.indexes.create({
  configuration: {
    index_type: {
      name: "multimodal",
    },
    fields: {
      searchable: {
        allow: ["title", "description"],
        deny: ["image_url"],
      },
      crawlable: {
        allow: ["image_url"],
      },
      filterable: {
        allow: ["price"],
      },
      types: {
        price: "float",
      },
    },
  },
})

Find Multiple Indexes

objective.indexes.getIndexes({
  limit: 20, // Amount of indexes to return - optional. Default is 10.
  cursor: "1234", // A base64 encoded, URL-safe string to navigate to the next or previous page. - optional
})

Retrieve the Status for a Single Index

objective.indexes.index.status(indexId)

Delete an Index

objective.indexes.index.delete(indexId)

Search an Index

objective.indexes.index.search(indexId, {
  query: "Shirts", // Required
  limit: 10, // Optional. Default is 10.
  filter_query: "", // Optional.
  ranking_expr: "", // Optional.
  offset: 10, // Optional. Default is 0.
  object_fields: "name,description", // Optional
})

Conclusion

The Objective TypeScript SDK simplifies the process of interacting with the Objective API, providing a comprehensive set of methods for managing object stores and indexes. By following the installation and initialization steps outlined above, you can quickly integrate Objective's capabilities into your TypeScript applications.