Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

6 Commits

Repository files navigation

Moon Position Tracker | APIVerve API Tutorial

License: MITBuildPythonAPIVerve | Moon Position

A Python CLI tool to track the moon's position in the sky. Get altitude, azimuth, and distance from any location on Earth.

Screenshot


Get Your Free API Key

This tutorial requires an APIVerve API key. Sign up free - no credit card required.


Features

  • Track moon position from any coordinates
  • Altitude above/below horizon
  • Azimuth with compass direction
  • Distance to the moon
  • Support for custom date/time
  • Pre-configured example locations
  • Interactive CLI interface

Quick Start

  1. Clone this repository

    git clone https://github.com/apiverve/moon-tracker-python-tutorial.git
    cd moon-tracker-python-tutorial
  2. Install dependencies

    pip install -r requirements.txt
  3. Set your API key

    export APIVERVE_API_KEY=your-api-key-here
  4. Run the tracker

    python tracker.py

Project Structure

moon-tracker-python-tutorial/
├── tracker.py # Main Python script
├── requirements.txt # Python dependencies
├── screenshot.jpg # Preview image
├── LICENSE # MIT license
├── .gitignore # Git ignore rules
└── README.md # This file

How It Works

  1. Select a location or enter coordinates
  2. Optionally specify date and time
  3. API calculates moon's position
  4. Display altitude, azimuth, and distance

The API Call

response=requests.get('https://api.apiverve.com/v1/moonposition',
headers={'x-api-key': API_KEY},
params={
'lat': 37.7749,
'lon': -122.4194,
'date': '01-22-2026',
'time': '14:30'
}
)

API Reference

Endpoint:GET https://api.apiverve.com/v1/moonposition

Query Parameters:

ParameterTypeRequiredDescription
latnumberYesLatitude (-90 to 90)
lonnumberYesLongitude (-180 to 180)
datestringNoDate (MM-DD-YYYY format)
timestringNoTime (HH:MM format)

Example Response:

{
"status": "ok",
"error": null,
"data": {
"date": "01-22-2026",
"time": "14:30",
"coordinates": {
"latitude": 37.7749,
"longitude": -122.4194
},
"moon": {
"altitude": -0.407908976399288,
"azimuth": 1.4720499058762104,
"distance": 404332.68340679689
}
}
}

Understanding the Data

FieldDescription
altitudeAngle above/below horizon (radians). Positive = visible
azimuthCompass direction (radians from north)
distanceDistance to moon in kilometers

Converting Radians to Degrees

degrees=radians* (180/3.14159)

Example Locations

LocationLatitudeLongitude
San Francisco37.7749-122.4194
New York40.7128-74.0060
London51.5074-0.1278
Tokyo35.6762139.6503

Customization Ideas

  • Add moon phase data
  • Create visualization graph
  • Add sunrise/sunset comparison
  • Build web interface
  • Track multiple celestial bodies
  • Add notification for moonrise

Related APIs

Explore more APIs at APIVerve:

Free Plan Note

This tutorial works with the free APIVerve plan. Some APIs may have:

  • Locked fields: Premium response fields return null on free plans
  • Ignored parameters: Some optional parameters require a paid plan

The API response includes a premium object when limitations apply. Upgrade anytime to unlock all features.

License

MIT - see LICENSE

Links

About

Moon position tracker that calculates altitude, azimuth, and distance using Python

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages