Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lynnaloo/adopt-a-pet

:cat2: :dog2: Adopt-a-Pet API Client for Node.js
https://github.com/lynnaloo/adopt-a-pet

adopt-a-pet adoption animal api api-client hacktoberfest hacktoberfest2020 nodejs npm pets rescue

Last synced: 24 days ago
JSON representation

:cat2: :dog2: Adopt-a-Pet API Client for Node.js

Awesome Lists containing this project

README

        

# Adopt-a-Pet

[![Greenkeeper badge](https://badges.greenkeeper.io/lynnaloo/adopt-a-pet.svg)](https://greenkeeper.io/)
[![Build Status](https://dev.azure.com/lynnaloo/adopt-a-pet/_apis/build/status/lynnaloo.adopt-a-pet?branchName=master)](https://dev.azure.com/lynnaloo/adopt-a-pet/_build/latest?definitionId=2&branchName=master)

Adopt-a-Pet API Client for Node

## Installation

* Install [Node LTS](https://nodejs.org/)

```
npm i adopt-a-pet
```

## Setup

* [Get API keys](http://www.adoptapet.com/shelter/portable_pet_list_api) for your shelter
* Set API key and ShelterId to environment variables: (optional)

```
export ADOPT_API_KEY=xxx
export SHELTER_ID=90641
```

## Usage:

```javascript
const AdoptPet = require('adopt-a-pet')

// Instantiate the adopt-a-pet API Client
// Parameters are not required if environment variables are set
const adoptPet = new AdoptPet(shelterId, apiKey)

//
// Get all pets for current shelter
//
adoptPet.getPets()
.then((pets) => {
// returns an array of pet objects
return pets;
});

//
// Get a random pet from the list of current shelter pets
//
adoptPet.getRandomPet()
.then((pet) => {
// return the random pet object
return pet;
})

//
// Get pet details using a petId and boolean to limit details
//
adoptPet.getPetDetails(petId, true)
.then((pet) => {
// returns detailed pet object
return pet;
});
```