Country Information and Conversion API

免费增值
通过 Klorax | 已更新 il y a un mois | Location
人气

7.4 / 10

延迟

678ms

服务等级

100%

Health Check

N/A

README

Country Information and Conversion API

The Country Information and Conversion API provides comprehensive country-related data and conversion capabilities, allowing developers to access detailed information about countries worldwide and seamlessly convert between country names and country codes.

Endpoints

Get Country Code by Name

Retrieve the country code based on the country name.

  • URL: /api/country/code/:name
  • Method: GET
  • Parameters:
    • :name - The name of the country.

Example Request:

GET /api/country/code/United States

Example Response:

{
  "code": "US",
  "name": "United States",
  "capital": "Washington, D.C.",
  "population": 331002651,
  "language": "English",
  "currency": "USD",
  "timezone": "UTC-04:00, UTC-05:00"
}

Get Country Name by Code

Retrieve the country name based on the country code.

  • URL: /api/country/name/:code
  • Method: GET
  • Parameters:
    • :code - The country code.

Example Request:

GET /api/country/name/US

Example Response:

{
  "code": "US",
  "name": "United States",
  "capital": "Washington, D.C.",
  "population": 331002651,
  "language": "English",
  "currency": "USD",
  "timezone": "UTC-04:00, UTC-05:00"
}

Additional Country Information

In addition to the country code and name, both endpoints provide the following additional information about each country:

  • capital: The capital city of the country.
  • population: The population count of the country.
  • language: The official language(s) spoken in the country.
  • currency: The currency used in the country.
  • timezone: The time zone(s) observed in the country.

Please note that the additional country information is included in the example responses for both endpoints.

Error Handling

The API returns appropriate HTTP status codes and error responses to indicate various scenarios:

  • 200 OK: Successful request and response.
  • 400 Bad Request: Invalid request parameters or missing required parameters.
  • 404 Not Found: Country not found or invalid country name/code.
  • 500 Internal Server Error: An unexpected error occurred.

Please make sure to handle these status codes appropriately in your application.

关注者:1
API 创建者:
K
Klorax
Morax
登录并给 API 打分
打分:5 - 投票:1