Paw pair

Find the perfect pet

Use PawFinder to discover adoptable pets using search and filter options like species, breed, age_months, and shelter_id. This tutorial walks through the typical user journey: browsing available pets → applying filters → viewing details → expressing interest.

How the search workflow works

The PawFinder Service API provides an endpoint for searching adoptable pets from shelters in the Dallas-Fort Worth area. Complete all appropriate steps in the Installation Guide before continuing this tutorial.

PawFinder uses json-server with basic search features. The diagram below shows what a production adoption plaform might look like when implementing pet search features:

graph LR
    A["Step 1:<br/>Open App"] -->|Browse All| B["Step 2:<br/>Search/Filter<br/>Species, Age,<br/>Location"]
    B -->|Select Filters| C["Step 3:<br/>View Results<br/>Matching Pets"]
    C -->|Click Pet| D["Step 4:<br/>View Profile<br/>Photos, Bio,<br/>Medical History"]
    D -->|Not Interested| E["Back to Results<br/>Browse More Pets"]
    E -->|New Search| B
    D -->|Interested| F["Step 5:<br/>Express Interest<br/>Contact Shelter"]
    
    style A fill:#9989c4,stroke:#333,stroke-width:2px,color:#fff
    style B fill:#88b2c4,stroke:#333,stroke-width:2px,color:#fff
    style C fill:#88b2c4,stroke:#333,stroke-width:2px,color:#fff
    style D fill:#9989c4,stroke:#333,stroke-width:2px,color:#fff
    style E fill:#88b2c4,stroke:#333,stroke-width:2px,color:#fff
    style F fill:#cc848a,stroke:#333,stroke-width:2px,color:#000

Endpoint structure

# Recommended base_url = http://localhost:3000
GET {base_url}/pets

Query parameters

Filter results using exact matches for the following parameters:

Core filters

Parameters Type Description Examples
species string Pet’s animal type dog, cat
breed string Pet’s breed Maine Coon, Golden Retriever
gender string Pet’s gender male, female
shelter_id integer Shelter’s unique identifier 1, 2, 3, 4

size and status filters

Parameters Type Description Examples
size string Pet’s size category small, medium, large
status string Pet’s availability available, pending, adopted

Pagination

json-server uses underscores for special query parameters _limit, _offset, _sort, and _order, which differs from standard REST conventions.

Parameters Type Description Notes
_limit integer Results per page Default: all results
_offset integer Results to skip Use with _limit
_sort string Field to sort by name, age, intake_date
_order string Sort direction default desc

Start the service

# Option 1: use npm (recommended)
# Run from the pawfinder-service root directory
npm start
# Option 2: call json-server directly
# Run from the pawfinder-service api directory
cd api
json-server -w pawfinder-db-source.json

Call the service

Use cURL commands or the Postman desktop app to make requests. For detailed Postman setup steps, visit the Installation Guide.

The examples below show common search scenarios. The first two include complete responses. See the “Best practices” section below for handling larger result sets with pagination.

Example 1: fetch the profiles of all available dogs

Use cURL

# -X GET is optional, as GET is the default operation
curl -X GET "{base_url}/pets?species=dog&status=available" \
  -H "Content-Type: application/json"

Use Postman desktop app

Set up a GET request to {base_url}/pets?species=dog&status=available

Response 200 OK

[
  {
    "name": "Max",
    "species": "dog",
    "breed": "Golden Retriever Mix",
    "age_months": 36,
    "gender": "male",
    "size": "large",
    "temperament": "energetic, loyal",
    "medical": {
      "spayed_neutered": true,
      "vaccinations": [
        "rabies",
        "dhpp",
        "leptospirosis"
      ]
    },
    "description": "Max is an active dog who needs regular exercise and responds well to commands.",
    "shelter_id": 2,
    "status": "available",
    "intake_date": "2025-07-20",
    "id": 2
  },
  ...
]

Example 2: access the profiles of all available cats at Dallas Animal Services

# -X GET is optional, as GET is the default operation
curl -X GET "{base_url}/pets?species=cat&shelter_id=1&status=available" \
  -H "Content-Type: application/json"

Response 200 OK

[
  {
    "name": "Luna",
    "species": "cat",
    "breed": "Domestic Shorthair",
    "age_months": 18,
    "gender": "female",
    "size": "small",
    "temperament": "playful, affectionate",
    "medical": {
      "spayed_neutered": true,
      "vaccinations": ["fvrcp", "rabies"]
    },
    "description": "Luna is a playful tabby who loves interactive toys and sunny windows.",
    "shelter_id": 1,
    "status": "available",
    "intake_date": "2025-09-01",
    "id": 1
  },
  {
    "name": "Oliver",
    "species": "cat",
    "breed": "Maine Coon",
    "age_months": 24,
    "gender": "male",
    "size": "large",
    "temperament": "gentle, calm",
    "medical": {
      "spayed_neutered": true,
      "vaccinations": ["fvrcp", "rabies"]
    },
    "description": "Oliver is a gentle giant who loves to be brushed and cuddled.",
    "shelter_id": 1,
    "status": "available",
    "intake_date": "2025-08-15",
    "id": 5
  }
]

More Examples:

# Retrieve all the profiles of Maine Coon cats (exact match required)
curl -X GET "{base_url}/pets?species=cat&breed=Maine%20Coon" \
  -H "Content-Type: application/json"
# Work with large sets of pet data
# Fetch the first 2 results sorted by `name` in ascending order
curl -X GET "{base_url}/pets?_limit=2&_start=0&_sort=name&_order=asc" \
  -H "Content-Type: application/json"
# Find dog profiles sorted by how recently they arrived at the shelter
curl -X GET "{base_url}/pets?species=dog&shelter_id=2&_sort=intake_date&_order=desc" \
  -H "Content-Type: application/json"

Common responses

Code Scenario Response
200 Successful with matches [{ "name": "Luna", "species": "cat",...}]
200 Successful without matches []
400 Invalid parameters { "error": "Bad Request", "message": "Invalid query parameter format" ...}

Best practices

Troubleshooting

Next steps