Introduction
Welcome to the Ethiopian Time API! This API provides the current Ethiopian time, formatted for easy integration into applications, websites, and systems that require Ethiopian time information.
The Ethiopian time system is distinct, starting the day at sunrise (approximately 6:00 AM Gregorian time), and this API allows accurate conversion and display of Ethiopian time.
Base URL
https://api.ethioall.com/time/api
API Response Format
{
"hour": 3,
"minute": 45,
"period": "Morning",
"time": "3:45 Morning",
"time_gregorian": "9:45 AM"
}
Fields in the Response:
- hour: The current hour in Ethiopian time (1-12).
- minute: The current minute.
- period: Either "Morning" or "Evening" to denote AM or PM in Ethiopian time.
- time: The Ethiopian time in a human-readable format.
- time_gregorian: The equivalent Gregorian time in 12-hour format.
How to Use the Ethiopian Time API
You can access the API by making a GET request to the following endpoint:
https://api.ethioall.com/time/api
This will return the current Ethiopian time and its Gregorian equivalent in JSON format.
Example Request with cURL
curl -X GET https://api.ethioall.com/time/api
Examples in Different Programming Languages
PHP Example
// Initialize a cURL session
$ch = curl_init();
// Set the URL to send the request to
curl_setopt($ch, CURLOPT_URL, "https://api.ethioall.com/time/api");
// Return the response as a string instead of outputting it directly
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the cURL request
$response = curl_exec($ch);
// Check if the response is valid
if ($response !== false) {
// Decode the JSON response into an associative array
$data = json_decode($response, true);
// Display the Ethiopian time
echo "Ethiopian Time: {$data['time']}\n";
}
// Close the cURL session
curl_close($ch);
?>
Python Example
import requests
# Define the API URL
url = "https://api.ethioall.com/time/api"
# Send a GET request to the API
response = requests.get(url)
# Check if the request was successful
if response.status_code == 200:
# Parse the JSON response
data = response.json()
# Print the Ethiopian time
print(f"Ethiopian Time: {data['time']}")
JavaScript (Node.js) Example
const axios = require('axios');
// Send a GET request to the API
axios.get('https://api.ethioall.com/time/api')
.then((response) => {
// Log the entire response data
console.log(response.data);
})
.catch((error) => {
// Log any errors encountered during the request
console.error("Error fetching time:", error);
});
Ruby Example
require 'net/http'
require 'json'
# Parse the API URL
url = URI.parse("https://api.ethioall.com/time/api")
# Send a GET request and store the response
response = Net::HTTP.get(url)
# Parse the JSON response
data = JSON.parse(response)
# Output the Ethiopian time
puts data
Error Handling
The API responds with an HTTP status code. Common error codes:
- 400 Bad Request: The request was not formatted properly.
- 404 Not Found: The requested resource could not be found.
- 500 Internal Server Error: An error occurred on the server.
Use Cases
- Display the current Ethiopian time on websites.
- Integrate Ethiopian time into mobile applications.
- Develop tools for Ethiopian time conversion and comparison.
- Provide educational platforms with Ethiopian time details.