API Academy
๐ŸŒ English
  • ๐ŸŒ English
  • ๐ŸŒ ็น้ซ”ไธญๆ–‡
HomePetstore APIExplore more APIs
HomePetstore APIExplore more APIs
๐ŸŒ English
  • ๐ŸŒ English
  • ๐ŸŒ ็น้ซ”ไธญๆ–‡
๐ŸŒ English
  • ๐ŸŒ English
  • ๐ŸŒ ็น้ซ”ไธญๆ–‡
  1. Working with APIs
  • 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. Working with APIs

Making Requests from Spec

In the previous chapters, we've explored the theoretical foundations of APIs and learned about their individual componentsโ€”methods, paths, parameters, request bodies, and responses. Now, as someone new to the API world, it's time to see how these pieces come together to build real functionality.
This chapter focuses on Working with APIsโ€”the practical process of using APIs to solve real problems and accomplish tasks. We'll start with the most fundamental skill: how to make requests from an API specification in Apidog.
Instead of manually constructing requests from scratch, working from a spec ensures you're using the API correctly and helps you avoid common mistakes. If you haven't imported an API spec into Apidog yet, you can learn how to do so in the previous article: What is an API Specification?.

1. Making a GET Request from Spec#

Let's start with a simple example: retrieving a pet by its ID using the Pet Store API. This demonstrates how to work with a GET request that includes a path parameter.

Step 1: Open the Endpoint#

1.
In your Apidog project, navigate to the imported Pet Store API spec.
2.
Find the "Get a pet" endpoint (or GET /pets/{id}).
3.
Click on it to open the endpoint details.

Step 2: Switch to the Run Tab#

Once the endpoint is open, you'll see multiple tabs at the top:
Edit โ€” for viewing or modifying the endpoint specification
Run โ€” for sending requests
Preview โ€” for viewing the spec in different formats
Click on the "Run" tab to switch to the request interface.
image.png

Step 3: Fill in the Path Parameter#

In the Run tab, you'll see the request is automatically generated based on the spec. For the GET /pets/{id} endpoint:
The method is already set to GET
The path shows /pets/{id} with the path parameter {id} highlighted
If the spec includes an example value (like '1'), it may already be filled in
Enter a pet ID in the path parameter field. For example, type pet_1Nv0FGQ9RKHgCVdK to retrieve the pet with that ID.
image.png

Step 4: Send the Request#

1.
Make sure you've selected the correct environment in the top-right corner (if your project uses environments).
2.
Click the "Send" button.
3.
The response will appear in the lower panel, showing the status code, response time, and the JSON body with the pet's information.

2. Making a POST Request from Spec#

Now let's try a more complex example: creating a new pet using a POST request with a request body. This shows how to work with endpoints that require data to be sent.

Step 1: Open the Endpoint#

1.
Navigate to the "Create a pet" endpoint (or POST /pets) in your Apidog project.
2.
Click on it to open the endpoint.

Step 2: Switch to the Run Tab#

Click the "Run" tab to access the request interface.

Step 3: Review the Auto-Generated Request Body#

When you switch to the Run tab, Apidog automatically generates a request body based on the spec's schema. If the spec includes an example, it will be pre-filled. Otherwise, you'll see a structure matching the schema.
image.png

Step 4: Fill in the Request Body#

The request body for creating a pet typically includes fields like:
name โ€” the pet's name (e.g., "Luna")
species โ€” the pet's species (e.g., "DOG", "CAT")
breed โ€” the pet's breed (e.g., "Golden Retriever")
ageMonths โ€” the pet's age in months
status โ€” the pet's status (e.g., "AVAILABLE", "PENDING", "ADOPTED")
You can:
Edit the auto-generated values directly in the JSON editor
Click "Auto-generate" to create new sample data based on the schema
Manually type your own values
Example request body:
{
  "name": "Luna",
  "species": "DOG",
  "breed": "Golden Retriever",
  "ageMonths": 24,
  "size": "LARGE",
  "color": "Golden",
  "gender": "FEMALE",
  "goodWithKids": true,
  "goodWithPets": true,
  "adoptionFee": 150.00,
  "description": "Friendly golden retriever looking for an active family",
  "status": "AVAILABLE"
}

Step 5: Send the Request#

1.
Verify your request body is correctly formatted.
2.
Click "Send" to create the pet.
3.
Check the responseโ€”you should receive a 201 Created status with the created pet's information, or see any error messages if something went wrong.

3. Save as Endpoint Case (Optional)#

After sending a successful request, you can save it as an endpoint case for future use:
1.
Click the "Save as case" button (located next to the "Send" button).
2.
In the dialog that appears:
Enter a name for the case (e.g., "Get pet by ID - Luna")
Optionally, check "Save response" to also save the response data
3.
Click "Save".
The saved case will appear under the endpoint in your project tree, making it easy to reuse this specific request configuration later.
image.png

4. Key Takeaways#

Working with APIs is about using API components to solve real problems and build functionality.
Working from specs ensures accuracy and saves time by auto-generating requests.
To make requests in Apidog:
1.
Import the API spec (if not already done)
2.
Open the endpoint you want to use
3.
Switch to the "Run" tab
4.
Fill in any required parameters or request body
5.
Click "Send" to execute the request
6.
Optionally, click "Save as case" to save the request for future use
GET requests typically use path or query parameters.
POST requests usually require a request body with structured data.
Endpoint cases allow you to save specific request configurations for reuse.
Apidog automatically generates requests based on the spec, making it easy to test APIs correctly.

Now that you know how to make basic requests from specs, you're ready to explore more advanced techniques for building real-world solutions. In the next article, we'll learn about Environments and Variablesโ€”how to manage different environments and use variables to make your requests more flexible and reusable.
Modified atย 2025-12-29 10:42:25
Previous
Working with APIs: Overview
Next
Environments and Variables
Built with