API Academy
🌐 English
  • 🌐 English
  • 🌐 繁體中文
HomePetstore APIExplore more APIs
HomePetstore APIExplore more APIs
🌐 English
  • 🌐 English
  • 🌐 繁體中文
🌐 English
  • 🌐 English
  • 🌐 繁體中文
  1. API Fundamentals
  • Introduction
  • Table of Contents
  • API Academy
    • Get Started
      • What is an API?
      • How Does an API Work?
      • How to Call an API?
      • How to Read an API Documentation?
      • Chapter Summary
      • Get realtime weather
    • API Fundamentals
      • API Funtamentals: Overview
      • Method & Path
      • Parameters
      • Request Body
      • Responses
      • API Specification & OAS
      • Chapter Summary
    • Working with APIs
      • Working with APIs: Overview
      • Making Requests from Spec
      • Environments and Variables
      • Chaining Multiple Endpoints
      • Handling Authentication
      • Handling API Signatures
      • Introduction to Scripts
      • Chapter Summary
    • Mocking APIs
      • Mocking APIs: Overview
      • Smart Mock
      • Mock Expectations
      • Cloud Mock
      • Mock Scripts
      • Chapter Summary
    • Designing APIs
      • Designing APIs: Overview
      • Introduction to API Design
      • Creating Your First API Project
      • Analyzing Requirements and Planning Your API
      • Designing Data Models
      • Designing Endpoints
      • Using Components and Reusability
      • Setting Up Authentication
      • API Design Guidelines
      • Chapter Summary
    • Developing APIs
      • Developing APIs: Overview
      • Setup: Install Your AI Coding Assistant
      • Quick Start: From Spec to Running API in 30 Minutes
      • Understanding the Generated Code
      • Testing Your API with Apidog
      • Deployment: Put Your API Online
      • Chapter Summary
    • Testing APIs
      • Testing APIs: Overview
      • Getting Started: Your First Test Scenario
      • Integration Testing and Data Passing
      • Dynamic Values
      • Assertions and Validations
      • Flow Control: If, For, ForEach
      • Data-Driven Testing
      • Performance Testing
      • Test Reports and Analysis
      • CI/CD Integration
      • Scheduled Tasks and Automation
      • Advanced Testing Strategies
      • Chapter Summary
    • API Documentations
      • API Documentations: Overview
      • Publishing Your First API Doc
      • Customizing Documentation Appearance
      • Interactive Features for Consumers
      • Advanced Publishing Settings
      • Managing API Versions
      • Chapter Summary
    • Advanced API Technologies
      • API Technologies: Overview
      • GraphQL
      • gRPC
      • WebSocket
      • Socket.IO
      • Server-Sent Events (SSE)
      • SOAP
      • Chapter Summary
    • API Lifecycle
      • API Lifecycle: Overview
      • Stages of the API Lifecycle
      • API Governance
      • API Security Best Practices
      • Monitoring and Analytics
      • API Versioning Strategies
      • The Future of APIs
      • Chapter Summary
    • API Security
      • API Security: Overview
      • API Security Fundamentals
      • Authentication vs Authorization
      • Understanding OAuth 2.0 and OpenID Connect
      • JSON Web Tokens (JWT)
      • OWASP API Security Top 10
      • Encryption and HTTPS
      • Chapter Summary
    • API Tools
      • API Tools: Overview
      • The Evolution of API Tools
      • API Clients
      • Command Line Tools (cURL, HTTPie)
      • API Design and Documentation Tools
      • API Mocking Tools
      • API Testing Tools
      • All-in-One API Platforms
      • Chapter Summary
    • API Gateway
      • API Gateway: Overview
      • What is an API Gateway?
      • Key Features of API Gateways
      • API Gateway vs Load Balancer vs Service Mesh
      • Popular API Gateway Solutions
      • The BFF (Backend for Frontend) Pattern
      • Chapter Summary
  • Modern Pet Store
    • Pet
      • Get Pet
      • Update Pet
      • Delete Pet
      • Create Pet
      • List Pets
      • Upload Pet Image
    • User
      • Update User
      • Get User
      • Delete User
      • Login
      • Logout
      • Create User
    • Store
      • List Inventory
      • Create Order
      • Get Order
      • Delete Order
      • Callback Example
      • Pay for an Order
    • Payments
      • Pay Order
    • Chat
      • Create Chat Completion
    • Webhooks
      • Pet Adopted Event
      • New Pet Available Event
  • Schemas
    • Pet
    • Category
    • User
    • ApiResponse
    • OrderPayment
    • Tag
    • Order
    • Links-Order
    • PetCollection
    • Bank Card
    • Bank Account
    • Links
    • Error
HomePetstore APIExplore more APIs
HomePetstore APIExplore more APIs
🌐 English
  • 🌐 English
  • 🌐 繁體中文
🌐 English
  • 🌐 English
  • 🌐 繁體中文
  1. API Fundamentals

What are Parameters in an API?

After learning about method & path, the next step in reading and using APIs is understanding parameters. Parameters allow you to customize requests, filter results, and provide input to the API.
We’ll continue using the Petstore API to illustrate different types of parameters.

1. What Are Parameters?#

Parameters are pieces of information sent to the API to tell it what exactly you want. They can appear in different places in the request:
TypeWhere it AppearsExample Purpose
Path ParametersPart of the URL path, often in {}/pets/{id} specifies which pet to fetch
Query ParametersAfter ? in the URL/pets?status=AVAILABLE filters pets by status
Header ParametersIn HTTP headersAuthorization: Bearer <token> for authentication
Body ParametersIn request body (for POST/PUT/PATCH)JSON object with pet details

2. Path Parameters#

Path parameters are required values embedded in the URL path. They identify a specific resource.
Example: Get a pet
GET /pets/{id}
{id} is the path parameter. Replace it with a real pet ID:
GET https://api.petstoreapi.com/v1/pets/pet_1Nv0FGQ9RKHgCVdK
This request fetches the pet with ID pet_1Nv0FGQ9RKHgCVdK.

3. Query Parameters#

Query parameters are optional (sometimes required) values added after ? in the URL. Multiple query parameters are separated by &.
Example: List pets
GET /pets?status=AVAILABLE
status=AVAILABLE is the query parameter.
You could add multiple parameters:
/pets?status=AVAILABLE&species=DOG
Query parameters are often used for:
Filtering results (status, category)
Pagination (limit, offset)
Sorting (sort=asc)

4. Header Parameters#

Header parameters are sent inside the HTTP headers instead of the URL. They often carry:
Authentication tokens (Authorization)
Content type (Content-Type: application/json)
Custom metadata (X-Request-ID)
Example:
GET /pets/pet_1Nv0FGQ9RKHgCVdK
Headers:
  Authorization: Bearer <your-token>
  Accept: application/json
Most headers are automatically handled by tools or frameworks, so you usually don’t need to set them manually; however, authentication-related headers (like Authorization) often need to be added yourself.

5. Body Parameters#

Body parameters are used for methods that create or update data (POST, PUT, PATCH). They are usually in JSON format, but could also be form data or XML.
Example: Create a pet
POST /pets
Body (JSON):
{
  "name": "Fluffy",
  "species": "DOG",
  "breed": "Golden Retriever",
  "ageMonths": 24,
  "status": "AVAILABLE"
}
The body contains structured data for the new resource.
The API spec defines which fields are required and their types.
The body is usually the most complex part of a request, since it often requires a specific and sometimes nested structure. You need to carefully follow the API documentation to construct it correctly.
Fortunately, tools like Apidog can help you easily build a properly formatted body that meets the API’s requirements.

6. Practical Tips#

1.
Always check which parameters are required in the spec. Missing required parameters usually trigger a 400 Bad Request.
2.
Optional parameters can enhance your request (filter, sort, paginate).
3.
Use URL encoding for query parameters that contain spaces or special characters.
4.
Tools like Apidog or Postman make it easier to add parameters in the right place and see the request URL generated.
5.
Remember: path parameters are required, query parameters are usually optional, and body parameters depend on the HTTP method.

7. Key Takeaways#

Parameters define what data you are asking for or what data you are sending.
Path parameters identify specific resources.
Query parameters filter, sort, and paginate results.
Header parameters pass metadata or authentication.
Body parameters carry structured data for POST/PUT/PATCH requests.
Reading the API spec carefully ensures you pass parameters correctly and get the expected response.

Now that you have a solid understanding of the different types of parameters and how to use them, you’re ready to take the next step. In the following section, we’ll dive deeper into the Request Body—exploring how to structure data for complex API operations and best practices for building valid and effective request payloads.
Modified at 2025-12-25 09:30:48
Previous
Method & Path
Next
Request Body
Built with