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 is Method & Path in an API?

When learning APIs, the first things you need to understand are the HTTP method and the endpoint path. These two define what action you want to perform and on which resource.
In this guide, we’ll use the popular Petstore API (a standard example API) to explain these concepts.

1. HTTP Method#

HTTP methods tell the server what you want to do. The most common methods are:
MethodMeaningTypical Use
GETRetrieve dataGet pet information
POSTCreate dataAdd a new pet
PUTReplace dataUpdate an existing pet
PATCHPartially update dataUpdate specific fields
DELETERemove dataDelete a pet
Example: If you want to see information about a pet, you would use GET. If you want to add a new pet, you would use POST.

2. Endpoint Path#

The endpoint path specifies where the resource lives on the server. Combined with the method, it defines the full action.
Example from Petstore: Get a pet
GET /pets/{id}
GET = retrieve data
/pets/{id} = the path to a specific pet
{id} = path parameter that you replace with the actual pet's ID
Full request URL example:
https://api.petstoreapi.com/v1/pets/pet_1Nv0FGQ9RKHgCVdK
Here, pet_1Nv0FGQ9RKHgCVdK is the pet ID you want to look up.

Principles about Paths#

Here are some basic principles about endpoint paths in REST APIs:
Resource-Based: Paths should represent resources (nouns), not actions (verbs). For example, use /users instead of /getUsers.
Hierarchical Structure: Paths can show relationships. For example, /users/1234/orders means all orders for user 1234.
Use of Path Parameters: Path parameters like {petId} allow you to refer to specific resources.
Plural vs Singular: Use plural nouns for collections (/pets for all pets) and singular for specific items (/pets/12345).
Clarity & Consistency: Keep endpoint paths simple, intuitive, and consistent across the API.
By following these RESTful path conventions, APIs become easier to understand, use, and maintain.

3. How Method & Path Work Together#

Let’s combine method and path in practice:
ActionMethodPathDescription
Get a petGET/pets/{id}Retrieve information about a specific pet
Create a petPOST/petsCreate a new pet with provided data
Update a petPUT/pets/{id}Replace an existing pet record
Delete a petDELETE/pets/{id}Remove a specific pet
List petsGET/petsRetrieve a list of pets
Notice that the same path can be used with different methods to perform different actions. For example:
GET /pets/pet_1Nv0FGQ9RKHgCVdK   β†’ Get pet info
DELETE /pets/pet_1Nv0FGQ9RKHgCVdK β†’ Remove pet

4. Practical Tip for Beginners#

Always check the method before constructing the request β€” a GET will usually not accept a body, while POST and PUT often require one.
Understand path parameters: anything in {} must be replaced with actual values.
Some APIs allow optional query parameters after the path (e.g., /pets?status=AVAILABLE).
Using tools like Apidog makes it easy to visualize the method + path and see the live response.

5. Key Takeaways#

Understanding method & path is the foundation of working with APIs:
1.
The method tells the server what you want to do (GET, POST, PUT, DELETE, PATCH).
2.
The path tells the server which resource you are acting on.
3.
Combining method and path defines a unique action in the API.
4.
Practice with examples like Petstore helps you grasp these concepts quickly.
Once you’re comfortable with method & path, you can move on to Parameters, which is the next piece of the API puzzle.
Modified atΒ 2026-02-12 06:44:53
Previous
API Funtamentals: Overview
Next
Parameters
Built with