Skip to content

apiverve/moon-tracker-python-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Moon Position Tracker | APIVerve API Tutorial

License: MIT Build Python APIVerve | 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:

Parameter Type Required Description
lat number Yes Latitude (-90 to 90)
lon number Yes Longitude (-180 to 180)
date string No Date (MM-DD-YYYY format)
time string No Time (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

Field Description
altitude Angle above/below horizon (radians). Positive = visible
azimuth Compass direction (radians from north)
distance Distance to moon in kilometers

Converting Radians to Degrees

degrees = radians * (180 / 3.14159)

Example Locations

Location Latitude Longitude
San Francisco 37.7749 -122.4194
New York 40.7128 -74.0060
London 51.5074 -0.1278
Tokyo 35.6762 139.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

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages