Skip to content

petfinder-com/petfinder-js-sdk

Repository files navigation

Petfinder JS SDK

CircleCI npm version Coverage Status

A JS wrapper for the Petfinder API, written in JavaScript/TypeScript.

Features

  • TypeScript definition
  • Promises (via Axios)
  • Well tested

Install

Using npm:

npm install --save @petfinder/petfinder-js

In browser:

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/@petfinder/petfinder-js/dist/petfinder.min.js"></script>

Usage (Browser)

var pf = new petfinder.Client({apiKey: "my-api-key", secret: "my-api-secret"});

pf.animal.search()
    .then(function (response) {
        // Do something with `response.data.animals`
    })
    .catch(function (error) {
        // Handle the error
    });

Usage (Node/CommonJS)

var petfinder = require("@petfinder/petfinder-js");
var client = new petfinder.Client({apiKey: "my-api-key", secret: "my-api-secret"});

client.animal.search()
    .then(function (response) {
        // Do something with `response.data.animals`
    })
    .catch(function (error) {
        // Handle the error
    });

Usage (TypeScript/ES6 Module)

import { Client } from "@petfinder/petfinder-js";

const client = new Client({apiKey: "my-api-key", secret: "my-api-secret"});

client.animal.search()
    .then(function (response) {
        // Do something with `response.data.animals`
    })
    .catch(function (error) {
        // Handle the error
    });

Documentation

See docs directory for more detailed documentation.