@@ -349,7 +349,88 @@ try {
349349 System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
350350}
351351```
352+ ### Astronomy API
353+ ``` java
354+ // Query astronomy information for location (city, country, etc.)
355+ AstronomyParams astronomyParams =
356+ AstronomyParams . builder()
357+ .withLocation(" Amsterdam, Netherlands" )
358+ .build();
359+
360+ try {
361+ Astronomy astronomy = ipGeolocationAPI. getAstronomy(astronomyParams);
362+
363+ System . out. println(" City: " + astronomy. getLocation(). getCity());
364+ System . out. println(" Country: " + astronomy. getLocation(). getCountryName());
365+ System . out. println(" Locality: " + astronomy. getLocation(). getLocality());
366+
367+ System . out. println(" Sun Distance: " + astronomy. getSunDistance());
368+ System . out. println(" Sun Altitude: " + astronomy. getSunAltitude());
369+ System . out. println(" Day length: " + astronomy. getDayLength());
370+ } catch (IPGeolocationError e) {
371+ // on unsuccessful lookup or invalid input IPGeolocationError is thrown
372+ System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
373+ }
374+ ```
375+ ``` java
376+ // Query astronomy information for given geo coordinates (latitude/longitude)
377+ AstronomyParams astronomyParams =
378+ AstronomyParams . builder()
379+ .withCoordinates(BigDecimal . valueOf(51.507277 ), BigDecimal . valueOf(- 0.1290644 ))
380+ .withDate(" 2024-02-29" )
381+ .build();
382+
383+ try {
384+ Astronomy astronomy = ipGeolocationAPI. getAstronomy(astronomyParams);
385+
386+ System . out. println(" Lat/Lon: " + astronomy. getLocation(). getLatitude() + " /" + astronomy. getLocation(). getLongitude());
387+
388+ System . out. println(" Date: " + astronomy. getDate());
389+ System . out. println(" Moonset: " + astronomy. getMoonset());
390+ System . out. println(" Sun Azimuth: " + astronomy. getSunAzimuth());
391+ } catch (IPGeolocationError e) {
392+ // on unsuccessful lookup or invalid input IPGeolocationError is thrown
393+ System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
394+ }
395+ ```
396+ ``` java
397+ // Query astronomy information for machine IP
398+ try {
399+ Astronomy astronomy = ipGeolocationAPI. getAstronomy();
352400
401+ System . out. println(" Zipcode: " + astronomy. getLocation(). getCity());
402+ System . out. println(" State code: " + astronomy. getLocation(). getStateCode());
403+ System . out. println(" City: " + astronomy. getLocation(). getCity());
404+
405+ System . out. println(" Sunrise: " + astronomy. getSunrise());
406+ System . out. println(" Sunset: " + astronomy. getSunset());
407+ System . out. println(" Moonrise: " + astronomy. getMoonrise());
408+ } catch (IPGeolocationError e) {
409+ // on unsuccessful lookup or invalid input IPGeolocationError is thrown
410+ System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
411+ }
412+ ```
413+ ``` java
414+ // Query astronomy information for specific IP in Chinese Language
415+ AstronomyParams astronomyParams = AstronomyParams . builder()
416+ .withIPAddress(" 1.1.1.1" )
417+ .withLang(" cn" )
418+ .build();
419+
420+ try {
421+ Astronomy astronomy = ipGeolocationAPI. getAstronomy(astronomyParams);
422+
423+ System . out. println(" Zipcode: " + astronomy. getLocation(). getCity());
424+ System . out. println(" Country Name: " + astronomy. getLocation(). getCountryName());
425+
426+ System . out. println(" Sun distance: " + astronomy. getSunDistance());
427+ System . out. println(" Moonrise: " + astronomy. getMoonrise());
428+ System . out. println(" Moon Parallactic Angle: " + astronomy. getMoonParallacticAngle());
429+ } catch (IPGeolocationError e) {
430+ // on unsuccessful lookup or invalid input IPGeolocationError is thrown
431+ System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
432+ }
433+ ```
353434
354435** IPGeolocation provides geolocation information in the following languages:
355436
0 commit comments