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

@dworg/dwjs

v1.0.0

Published

Petstoresdk

Downloads

2

Readme

Petstoresdk Typescript SDK 1.0.0

The Typescript SDK for Petstoresdk.

  • API version: 1.0.0
  • SDK version: 1.0.0

Table of Contents

Installation

npm install dwjs

Authentication

To see whether an endpoint needs a specific type of authentication check the endpoint's documentation.

Access Token

The Petstoresdk API uses access tokens as a form of authentication. You can set the access token when initializing the SDK through the constructor:

const sdk = new Petstoresdk('YOUR_ACCESS_TOKEN')

Or through the setAccessToken method:

const sdk = new Petstoresdk()
sdk.setAccessToken('YOUR_ACCESS_TOKEN')

You can also set it for each service individually:

const sdk = new Petstoresdk()
sdk.pets.setAccessToken('YOUR_ACCESS_TOKEN')

Sample Usage

Here is a simple program demonstrating usage of this SDK. It can also be found in the examples/src/index.ts file in this directory.

When running the sample make sure to use npm install to install all the dependencies.

import { Petstoresdk } from '@dworg/dwjs';


const sdk = new Petstoresdk({ accessToken: process.env.PETSTORESDK_ACCESS_TOKEN });

(async () => {
  try {
    const result = await sdk.pets
      .listPets();
    console.log(result);
  } catch (err) {
    const error = err as Error;
    console.error(error.message);
  }
})();

Petstoresdk Services

A list of all services and services methods.

Pets

| Method | Description | | :-------------------------- | :---------------------- | | createPets | Create a pet | | listPets | List all pets | | showPetById | Info for a specific pet |

All Methods

createPets

Create a pet

  • HTTP Method: POST
  • Endpoint: /pets

Required Parameters

| input | object | Request body. |

Return Type

Returns a dict object.

Example Usage Code Snippet

import { Petstoresdk } from '@dworg/dwjs';


const sdk = new Petstoresdk({ accessToken: process.env.PETSTORESDK_ACCESS_TOKEN });

(async () => {
  const input = {"id":-67521967,"name":"name","tag":"tag"};
  const result = await sdk.pets
    .createPets(input);
  console.log(result);
})();

listPets

List all pets

  • HTTP Method: GET
  • Endpoint: /pets

Optional Parameters

Optional parameters are passed as part of the last parameter to the method. Ex. {optionalParam1 : 'value1', optionalParam2: 'value2'}

| Name | Type | Description | | :---- | :----- | :--------------------------------------------- | | limit | number | How many items to return at one time (max 100) |

Return Type

Pets

Example Usage Code Snippet

import { Petstoresdk } from '@dworg/dwjs';


const sdk = new Petstoresdk({ accessToken: process.env.PETSTORESDK_ACCESS_TOKEN });

(async () => {
  const result = await sdk.pets
    .listPets({ limit: -47508293 });
  console.log(result);
})();

showPetById

Info for a specific pet

  • HTTP Method: GET
  • Endpoint: /pets/{petId}

Required Parameters

| Name | Type | Description | | :---- | :----- | :---------------------------- | | petId | string | The id of the pet to retrieve |

Return Type

Pet

Example Usage Code Snippet

import { Petstoresdk } from '@dworg/dwjs';


const sdk = new Petstoresdk({ accessToken: process.env.PETSTORESDK_ACCESS_TOKEN });

(async () => {
  const result = await sdk.pets
    .showPetById('petId');
  console.log(result);
})();

License

License: MIT. See license in LICENSE.