This question runs in a pre-configured Salesforce environment - no personal connection required.

Fetch current weather conditions from the OpenWeatherMap API for given coordinates. Take latitude and longitude as parameters, make an HTTP callout to OpenWeatherMap API, parse the weather description from the JSON response, and return the current weather description as a string.

Use the OpenWeatherMap API endpoint https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API_KEY} to get weather data. Extract the description field from the first weather object in the response. Handle API errors gracefully by returning appropriate error messages.

Examples:

Input: latitude = 40.7128, longitude = -74.0060 Output: "clear sky" Explanation: Current weather description for New York coordinates Input: latitude = 51.5074, longitude = -0.1278 Output: "overcast clouds" Explanation: Current weather description for London coordinates Input: latitude = 999, longitude = 999 Output: "Error: Invalid coordinates" Explanation: Invalid coordinates outside valid range
Apex Code Editor

Welcome to Lightning Challenge!

How It Works

  • • Write your solution in the code editor
  • • This challenge runs without connecting your own org
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 #CodeEveryDay July 2026

Contest runs July 1 - 31. Complete challenges to climb the leaderboard!

Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In