Moon Phase API Documentation
Free lunar data API for developers and applications
🚀 Quick Start
GET https://api.phaseofthemoontoday.com/v1/currentGet the current moon phase instantly. No authentication required.
{
"phase": "Waxing Gibbous",
"illumination": 87.3,
"emoji": "🌔",
"days_since_new": 11.2,
"next_full_moon": "2025-01-25T12:34:56Z",
"next_new_moon": "2025-02-09T08:15:30Z"
}📡 Available Endpoints
Current Moon Phase
GET /v1/currentReturns real-time moon phase data including illumination percentage, phase name, and upcoming events.
Historical Moon Phase
GET /v1/date/{YYYY-MM-DD}Get moon phase for any date from 1900 to 2100. Perfect for historical research and birthday calculations.
Location-Based Data
GET /v1/location/{city}Moon phase with local moonrise/moonset times for over 15,000 cities worldwide.
Monthly Calendar
GET /v1/calendar/{YYYY-MM}Complete lunar calendar for any month with all phase transitions and special events.
💻 Code Examples
JavaScript / Node.js
// Fetch current moon phase
fetch('https://api.phaseofthemoontoday.com/v1/current')
.then(response => response.json())
.then(data => {
console.log(`Current phase: ${data.phase}`);
console.log(`Illumination: ${data.illumination}%`);
});
// Get moon phase for specific date
const date = '2025-07-20';
fetch(`https://api.phaseofthemoontoday.com/v1/date/${date}`)
.then(response => response.json())
.then(data => {
console.log(`Phase on ${date}: ${data.phase}`);
});Python
import requests
# Get current moon phase
response = requests.get('https://api.phaseofthemoontoday.com/v1/current')
data = response.json()
print(f"Current phase: {data['phase']}")
print(f"Illumination: {data['illumination']}%")
# Get historical data
date = '2025-07-20'
response = requests.get(f'https://api.phaseofthemoontoday.com/v1/date/{date}')
data = response.json()
print(f"Phase on {date}: {data['phase']}")PHP
<?php // Get current moon phase $url = 'https://api.phaseofthemoontoday.com/v1/current'; $response = file_get_contents($url); $data = json_decode($response, true); echo "Current phase: " . $data['phase'] . "\n"; echo "Illumination: " . $data['illumination'] . "%\n"; // Get moon phase for location $city = 'london'; $url = "https://api.phaseofthemoontoday.com/v1/location/$city"; $response = file_get_contents($url); $data = json_decode($response, true); echo "Phase in $city: " . $data['phase'] . "\n"; ?>
cURL
# Get current moon phase
curl -X GET "https://api.phaseofthemoontoday.com/v1/current" \
-H "Accept: application/json"
# Get historical moon phase
curl -X GET "https://api.phaseofthemoontoday.com/v1/date/2025-07-20" \
-H "Accept: application/json"
# Get monthly calendar
curl -X GET "https://api.phaseofthemoontoday.com/v1/calendar/2025-01" \
-H "Accept: application/json"🎨 Embeddable Widgets
Simple Moon Phase Widget
Add a live moon phase display to any website with one line of code:
<script src="https://cdn.phaseofthemoontoday.com/widget.js" data-style="minimal"></script>WordPress Plugin
Official WordPress plugin available for easy integration:
[moon_phase_today style="detailed" location="auto"]React Component
Ready-to-use React component for modern web applications:
import { MoonPhaseWidget } from '@phaseofthemoontoday/react';
function App() {
return (
<MoonPhaseWidget
apiKey="your-api-key"
theme="dark"
showDetails={true}
/>
);
}⚡ Rate Limits & Pricing
Free Tier
- • 1,000 requests/day
- • Basic endpoints
- • Community support
- • No authentication required
Developer
- • 100,000 requests/day
- • All endpoints
- • Priority support
- • Advanced widgets
Enterprise
- • Unlimited requests
- • Custom endpoints
- • Dedicated support
- • White-label options
🤝 Support & Community
Developer Resources
🎯 Popular Use Cases
Weather Apps
Enhance weather applications with lunar phase data for gardening and outdoor activities.
Mobile Apps
Build astronomy, meditation, or wellness apps with real-time moon phase integration.
Websites
Add live moon phase widgets to blogs, educational sites, and astronomy portals.
Design Tools
Create dynamic calendars, posters, and educational materials with accurate lunar data.
Data Analysis
Research correlations between lunar cycles and various phenomena for scientific studies.
Games
Integrate real moon phases into gaming experiences for immersive fantasy and simulation games.