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

@pinport/client

v1.1.0

Published

SDK for pinport API

Downloads

45

Readme

PinportClient

PinportClient is a TypeScript client for interacting with the Pinport API. It allows for creating and retrieving pins on the Pinport platform.

Installation

To install the PinportClient, use the following command:

npm install @pinport/client

Usage

Importing and Initializing

To use the PinportClient, you need to import it and initialize an instance with your API URL and key:

import { PinportClient } from "@pinport/client";

const pinport = new PinportClient("<api_url>", "<private_key> or <public_key>");

Creating Pins

You can create multiple pins by sending a POST request to the Pinport API. The createPins method takes an array of pin objects to be created.

const pinsToCreate: Pinport.CreatePin[] = [
  {
    meta_id: "meta1",
    position: { x: 1, y: 2, z: 3 },
    offset: { x: 0, y: 0, z: 0 },
    html: "<div>Pin 1</div>",
    opacity: 0.8,
    enableLine: true,
    alert: false,
    icon: "icon1",
  },
  {
    meta_id: "meta2",
    position: { x: 4, y: 5, z: 6 },
    offset: { x: 1, y: 1, z: 1 },
    html: "<div>Pin 2</div>",
    opacity: 0.9,
    enableLine: false,
    alert: true,
    icon: "icon2",
  },
];

pinport
  .createPins(pinsToCreate)
  .then((response) => {
    console.log("Created pins:", response);
  })
  .catch((error: Pinport.ErrorResponse) => {
    console.error("Error creating pins:", error);
  });

Retrieving Pins

You can retrieve all pins by sending a GET request to the Pinport API. The getPins method takes a meta_id for searching pins.

pinport.getPins('meta1').then((response) => {
  console.log("Retrieved pins:", response);
}).catch((error: Pinport.ErrorResponse) => {
  console.error("Error retrieving pins:", error);
});

Updating Pins

You can update existing pins by sending a PUT request to the Pinport API. The updatePins method takes an array of pin objects with updated properties.

const pinsToUpdate: Pinport.UpdatePin[] = [
  {
    id: "pin1",
    position: { x: 2, y: 3, z: 4 },
    offset: { x: 0, y: 0, z: 0 },
    html: "<div>Updated Pin 1</div>",
    opacity: 0.7,
    enableLine: true,
    alert: false,
    icon: "icon1",
  },
  {
    id: "pin2",
    position: { x: 5, y: 6, z: 7 },
    offset: { x: 1, y: 1, z: 1 },
    html: "<div>Updated Pin 2</div>",
    opacity: 0.9,
    enableLine: false,
    alert: true,
    icon: "icon2",
  },
];

pinport
  .updatePins(pinsToUpdate)
  .then((response) => {
    console.log("Updated pins:", response);
  })
  .catch((error: Pinport.ErrorResponse) => {
    console.error("Error updating pins:", error);
  });

Deleting Pins

You can delete pins by sending a DELETE request to the Pinport API. The deletePins method takes an array of pin IDs to be deleted.

const pinIdsToDelete: string[] = ["pin1", "pin2"];

pinport
  .deletePins(pinIdsToDelete)
  .then((response) => {
    console.log("Deleted pins:", response);
  })
  .catch((error: Pinport.ErrorResponse) => {
    console.error("Error deleting pins:", error);
  });

Getting Metadata

You can retrieve metadata by sending a GET request to the Pinport API. The getMetadata method takes a meta_id for retrieving metadata.

pinport.getMetadata('meta1').then((response) => {
  console.log("Retrieved metadata:", response);
}).catch((error: Pinport.ErrorResponse) => {
  console.error("Error retrieving metadata:", error);
});

Extensions

PinportClient supports extensions that can be used to extend its functionality. Extensions are initialized during the PinportClient instance creation.

import { PinportMatterporExtension } from "@pinport/matterport";

const pinport = new PinportClient(
  '<api_url>',
  '<private_key>',
  { extensions: [PinportMatterporExtension] },
);
// now you can access
const pinportMatterport = pinport.extensions.matterport