API Academy
🌐 English
  • 🌐 English
  • 🌐 繁體中文
HomePetstore APIExplore more APIs
HomePetstore APIExplore more APIs
🌐 English
  • 🌐 English
  • 🌐 繁體中文
🌐 English
  • 🌐 English
  • 🌐 繁體中文
  1. Get Started
  • 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
        GET
    • 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. Get Started

How to Call an API?

Calling an API means actually making a request and handling the response — not just reading about it. In this article we’ll use a real-life API example for London’s weather using WeatherAPI.com and show how you can try it out using Apidog. We’ll keep it beginner-friendly.

1. What You Need Before Calling an API#

Before you call an API, you typically need:
An endpoint URL (where you send the request)
The correct HTTP method (GET, POST, etc.)
Any parameters required (query strings, path segments)
Possibly headers (authentication, content type)
Sometimes a body (for POST/PUT)
You can send API requests in two main ways: by writing code (using libraries like Python's requests or JavaScript's fetch) or by using API tools like Apidog.
For this guide, we will use Apidog for convenience, as it allows you to send requests and visualize responses easily without setting up a complex development environment.
For our example we’ll use WeatherAPI.com’s current-weather API, which requires you to register, obtain an API key and then send the key as a query parameter.

2. Request (How to Send It)#

What is WeatherAPI.com?#

WeatherAPI.com is a fully managed weather and geolocation API provider offering real-time weather, forecasts, historical weather, air quality data and more.
You need to firstly register in WeatherAPI to get an API key to continue.

Example Request#

Here’s a ready-to-send request (replace YOUR_API_KEY with the actual key you get after signing up):
GET http://api.weatherapi.com/v1/current.json?key=3432a351afd04b30bef75833252711&q=London&aqi=no
Method: GET — retrieving data
URL: Base URL http://api.weatherapi.com/v1/current.json, parameter key = your API key, q = “London”, aqi=no to skip air-quality data
No extra headers or request body needed in this simple case

What is Apidog?#

Apidog is an all-in-one API collaboration platform used for API documentation, API debugging, API mocking, and API automated testing. It offers a visual interface to send HTTP requests and inspect responses easily, making it a powerful alternative to command-line tools or basic HTTP clients.

Apidog Practical Steps#

Here’s how to send this request using Apidog:
1.
Log into Apidog and select New Endpoint.
2.
Set the Method to GET.
3.
Paste this URL into the request URL field. Don't forget to replace the key to your own key.
http://api.weatherapi.com/v1/current.json?key=3432a351afd04b30bef75833252711&q=London&aqi=no
4.
(Optional) Add a descriptive name like “Get realtime weather”.
image.png
5.
Click the Send button. Apidog will fire the request and show you a live response.
By doing this you’ve initiated a real API call for London’s weather data.

3. Response (What You Get Back)#

Apidog Practical Steps#

After sending the request, you'll see the response under the request zone.
image.png
Here’s how to inspect the response in Apidog:
1.
After you’ve sent the request (previous section), look at the response panel in Apidog. You should see status code 200, plus response time and the JSON body.
2.
Expand the JSON body to review fields like daily_units, daily.time, daily.temperature_2m_max, etc.
3.
Save the request in Apidog so you can reuse it.
4.
(Optional) Change the query parameter q to a different city (e.g., q=New York) and resend the request to see how the response changes.

Example Response#

HTTP/1.1 200 OK  
Headers: (ignored for simplicity)
{
    "location": {
        "name": "London",
        "region": "City of London, Greater London",
        "country": "United Kingdom",
        "lat": 51.5171,
        "lon": -0.1062,
        "tz_id": "Europe/London",
        "localtime_epoch": 1764232379,
        "localtime": "2025-11-27 08:32"
    },
    "current": {
        "last_updated_epoch": 1764232200,
        "last_updated": "2025-11-27 08:30",
        "temp_c": 11.2,
        "temp_f": 52.2,
        "is_day": 1,
        "condition": {
            "text": "Overcast",
            "icon": "//cdn.weatherapi.com/weather/64x64/day/122.png",
            "code": 1009
        },
        "wind_mph": 10.1,
        "wind_kph": 16.2,
        "wind_degree": 225,
        "wind_dir": "SW",
        "pressure_mb": 1015.0,
        "pressure_in": 29.97,
        "precip_mm": 0.0,
        "precip_in": 0.0,
        "humidity": 94,
        "cloud": 100,
        "feelslike_c": 9.3,
        "feelslike_f": 48.7,
        "windchill_c": 8.0,
        "windchill_f": 46.3,
        "heatindex_c": 10.2,
        "heatindex_f": 50.3,
        "dewpoint_c": 9.0,
        "dewpoint_f": 48.2,
        "vis_km": 10.0,
        "vis_miles": 6.0,
        "uv": 0.0,
        "gust_mph": 17.1,
        "gust_kph": 27.5,
        "short_rad": 0.68,
        "diff_rad": 0.31,
        "dni": 11.17,
        "gti": 0.0
    }
}
Status code 200 OK: means the request was successful.
The body contains the current weather for London, including temperature (11.2 °C), condition (“Overcast”), wind speed, humidity etc.
Your front-end or client can now use these values to display to the user.
By inspecting the response in Apidog, you’re closing the loop: request → response → usage.
You can also visit this request directly here: Get realtime weather.

4. Key Takeaways#

Calling an API = making a request + handling a response.
You now know how to use a real URL, a method, send your API key, and see a real response for London’s current weather via WeatherAPI.com.
Using a tool like Apidog turns theory into practice.
Next step: try calling APIs with different cities or parameters (e.g., forecast endpoint), or use POST/PUT methods with request body for other APIs.

Calling an API is all about sending the right request and knowing how to read the response that comes back. But how do we know what should we send in the parameters or bodies? How should we compose the request?
In the next article, we’ll break down How to Read an API Documentation so you can understand any API with confidence and call it correctly.
Modified at 2025-12-29 10:42:25
Previous
How Does an API Work?
Next
How to Read an API Documentation?
Built with