Public ethiopian date api

ethioall

Public ethiopian date api

Ethiopian Date API Documentation

Welcome to the Ethiopian Date API! This API allows you to easily retrieve the current Ethiopian date, including the day, month, year, and the numeric date, both in Amharic and English. You can use this API to integrate Ethiopian date functionality into your applications, websites, and more.

The Ethiopian calendar is distinct from the Gregorian calendar, and this API allows you to convert between the two, showing the Ethiopian date along with the day of the week in both Amharic and English.

Base URL:

https://date.ethioall.com/api/date

This is the endpoint where you can make GET requests to retrieve the Ethiopian date.

API Response Format

The API will return a JSON response with the following fields:

{
  "day": "ሰኞ",
  "month": "መስከረም",
  "date": 21,
  "year": 2017,
  "numeric_date": "21-1-2017",
  "day_english": "Monday",
  "month_english": "Meskerem",
  "month_number": 1
}

Fields in the Response:

  • day: The day of the week in Amharic (e.g., “ሰኞ” for Monday).
  • month: The month name in Amharic (e.g., “መስከረም” for Meskerem).
  • date: The day of the month in the Ethiopian calendar.
  • year: The current Ethiopian year.
  • numeric_date: The Ethiopian date in the format day-month-year (e.g., “21-1-2017”).
  • day_english: The day of the week in English (e.g., “Monday”).
  • month_english: The month name in English (e.g., “Meskerem”).
  • month_number: The month number in the Ethiopian calendar (e.g., 1 for Meskerem).

How to Use the Ethiopian Date API

You can access the API by making a GET request to the following endpoint:

https://date.ethioall.com/api/date

This will return the current Ethiopian date and additional information in JSON format.


Examples in Different Programming Languages

Below are code examples demonstrating how to make a request to the Ethiopian Date API and handle the response in various programming languages.

1. PHP Example

<?php
// Initialize cURL session
$ch = curl_init();

// Set the API URL
curl_setopt($ch, CURLOPT_URL, "https://date.ethioall.com/api/date");

// Set cURL options to return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL request and store the response
$response = curl_exec($ch);

// Check if there was an error with the cURL request
if ($response === false) {
    echo "cURL Error: " . curl_error($ch);
} else {
    // Decode the JSON response
    $data = json_decode($response, true);
    
    // Print the Ethiopian Date
    echo "Ethiopian Date: " . $data['date'] . " " . $data['month'] . " " . $data['year'] . "\n";
    echo "Day (Amharic): " . $data['day'] . "\n";
    echo "Day (English): " . $data['day_english'] . "\n";
    echo "Month (English): " . $data['month_english'] . "\n";
}

// Close the cURL session
curl_close($ch);
?>

2. Python Example

import requests

# Set the API URL
url = "https://date.ethioall.com/api/date"

# Send a GET request to the API
response = requests.get(url)

# If the request was successful (status code 200)
if response.status_code == 200:
    # Parse the JSON response
    data = response.json()

    # Print the Ethiopian Date
    print(f"Ethiopian Date: {data['date']} {data['month']} {data['year']}")
    print(f"Day (Amharic): {data['day']}")
    print(f"Day (English): {data['day_english']}")
    print(f"Month (English): {data['month_english']}")
else:
    print(f"Error: {response.status_code}")

3. JavaScript (Node.js) Example

const axios = require('axios');

// Set the API URL
const url = 'https://date.ethioall.com/api/date';

// Send a GET request to the API
axios.get(url)
  .then((response) => {
    const data = response.data;

    // Print the Ethiopian Date
    console.log(`Ethiopian Date: ${data.date} ${data.month} ${data.year}`);
    console.log(`Day (Amharic): ${data.day}`);
    console.log(`Day (English): ${data.day_english}`);
    console.log(`Month (English): ${data.month_english}`);
  })
  .catch((error) => {
    console.error('Error:', error);
  });

4. Ruby Example

require 'net/http'
require 'json'
require 'uri'

# Set the API URL
url = URI.parse("https://date.ethioall.com/api/date")

# Send a GET request to the API
response = Net::HTTP.get(url)

# Parse the JSON response
data = JSON.parse(response)

# Print the Ethiopian Date
puts "Ethiopian Date: #{data['date']} #{data['month']} #{data['year']}"
puts "Day (Amharic): #{data['day']}"
puts "Day (English): #{data['day_english']}"
puts "Month (English): #{data['month_english']}"

Error Handling

The API responds with an HTTP status code. If the status code is not 200 (OK), you should check for errors. Below are some 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.

Check the status_code in the response for any errors.

Use Cases

  • Integrate into Websites: Display the current Ethiopian date on your website.
  • Mobile Applications: Use the API to show Ethiopian dates in mobile apps.
  • Cultural and Religious Applications: Develop applications that show important Ethiopian dates and holidays.
  • Educational Platforms: Provide Ethiopian date details for academic purposes.

Conclusion

The Ethiopian Date API is a simple and effective way to retrieve the current Ethiopian date and additional information such as the day of the week, month name, and numeric date. Whether you’re building a website, mobile app, or anything else that requires Ethiopian date functionality, this API provides an easy-to-integrate solution.

Feel free to use the API and share it with others. If you need any additional help or have questions, don’t hesitate to reach out to us!

This documentation should now be more structured, detailed, and user-friendly for developers looking to integrate the Ethiopian Date API into their applications.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top