Overview
Petstore API is a simple, sample API for managing pets.
API information
| Item | Value |
|---|---|
| API name | Petstore API |
| Version | 1.0.0 |
| Description | A sample API for pets |
Base URL
All requests are made relative to:
https://api.petstore.com/v1
Authentication (API key)
This API uses an API key passed via the X-API-Key request header.
- Learn more in Authentication
Versioning
The API is versioned in the URL path:
- Current:
v1(e.g.,https://api.petstore.com/v1/...)
If a new major version is introduced, expect it to appear as a new base path (for example, /v2).
Quickstart
1) Set your API key
Export an environment variable to avoid pasting keys into command history:
export PETSTORE_API_KEY="YOUR_API_KEY"2) Make a request (curl)
Example: list pets (see full details in Pets):
curl -sS \
-H "X-API-Key: ${PETSTORE_API_KEY}" \
"https://api.petstore.com/v1/pets"3) Make a request (JavaScript / Node.js)
const url = "https://api.petstore.com/v1/pets";
async function main() {
const res = await fetch(url, {
headers: {
"X-API-Key": process.env.PETSTORE_API_KEY,
},
});
if (!res.ok) {
throw new Error(`Request failed: ${res.status} ${res.statusText}`);
}
const data = await res.json();
console.log(data);
}
main().catch((err) => {
console.error(err);
process.exit(1);
});Next steps
- Review auth requirements: Authentication
- Explore endpoints:
- Pets (Pet operations)
- Store (Store operations)
- Miscellaneous (Untagged/operational endpoints)
- Understand data models: Schemas
- Troubleshoot failures: Errors