<p>Astropy is one option:</p>

<pre><code>from astropy.time import Time
from astropy.coordinates import solar_system_ephemeris, EarthLocation
from astropy.coordinates import get_body, get_moon
from astropy.coordinates import SkyCoord, EarthLocation, AltAz
from astropy import units as u
import time;

t = Time("2019-08-11 11:00", scale="utc")
loc = EarthLocation(lat=38.2464000*u.deg, lon=274.236400*u.deg, height=0*u.m)

with solar_system_ephemeris.set('jpl'):
  moon = get_body('moon', t, loc)

altazframe = AltAz(obstime=t, location=loc, pressure=0)
moonaz=moon.transform_to(altazframe)

print(moonaz.alt.degree,moonaz.az.degree)
</code></pre>

<p>If you want a library you can ship with a product, you'll want something much smaller.  I am actually working on <a href="https://github.com/gmiller123456/vsop87-multilang" rel="nofollow noreferrer">a library converted to many different languages to do just that</a>. 
 Only the JavaScript version has a working Alt Az example, but it should be easy to convert to other languages (and will be eventually).</p>

CC BY-SA 4.0
2019-08-13T03:20:26.763Z
2019-08-16T03:49:09.133Z
2019-08-16T03:49:09.133Z
Greg Miller
<p>I'm looking for a simple API that will allow me to get positions of planets and the moon for a given date, location and time.<br>
Does anyone know an API like that?<br>
Any suggestions or alternatives would be appreciated.</p>

CC BY-SA 4.0
2019-08-12T14:04:57.970Z
I think it is not really an API, it is more like a database (although it can have an API). Celestia, Google Sky Map, both have this DB. Celestia is opensource, and its database is free.
peterh
CC BY-SA 4.0
2019-08-12T16:15:59.333Z
JPL HORIZONS will do this and is callable from Python [docs](https://astroquery.readthedocs.io/en/latest/jplhorizons/jplhorizons.html). It may not meet the definition of "simple" and it may not integrate with your other code however.
astrosnapper
CC BY-SA 4.0
2019-08-13T00:37:46.407Z
There may be an answer at [Where can I find/visualize planets/stars/moons/etc positions?](https://astronomy.stackexchange.com/q/13488/7982) or not, I don't really know what does or doesn't count as an API for you in your case, or if you really need a proper API or something else will do. If you can use Python then [Skyfield](https://rhodesmill.org/skyfield/) works quite nicely. If you like compiled code, then Spice...
uhoh
CC BY-SA 4.0
2019-08-13T00:41:15.040Z
Also see [Python API for JPL Horizons?](https://space.stackexchange.com/q/15462/12102) where an answer mentions astroquery (as does astrosnapper's comment above).
uhoh
CC BY-SA 4.0
2019-08-13T06:05:01.227Z
Thanks guys for your suggestions. I'll definitely check out the python libraries.
Deathbat219
<planet><the-moon><solar-system><positional-astronomy>
Planets positions (azimuth, altitude) API
Deathbat219
# Planets positions (azimuth, altitude) API

(Asked by: username_0 on 2019-08-12)

I'm looking for a simple API that will allow me to get positions of planets and the moon for a given date, location and time.  
Does anyone know an API like that?  
Any suggestions or alternatives would be appreciated.

**Tags:** planet, the-moon, solar-system, positional-astronomy
> **Comments:**
> **username_1**: I think it is not really an API, it is more like a database (although it can have an API). Celestia, Google Sky Map, both have this DB. Celestia is opensource, and its database is free.  
> **username_2**: JPL HORIZONS will do this and is callable from Python [docs](https://astroquery.readthedocs.io/en/latest/jplhorizons/jplhorizons.html). It may not meet the definition of "simple" and it may not integrate with your other code however.  
> **username_3**: There may be an answer at [Where can I find/visualize planets/stars/moons/etc positions?](https://astronomy.stackexchange.com/q/13488/7982) or not, I don't really know what does or doesn't count as an API for you in your case, or if you really need a proper API or something else will do. If you can use Python then [Skyfield](https://rhodesmill.org/skyfield/) works quite nicely. If you like compiled code, then Spice...  
> **username_3**: Also see [Python API for JPL Horizons?](https://space.stackexchange.com/q/15462/12102) where an answer mentions astroquery (as does astrosnapper's comment above).  
> **username_0**: Thanks guys for your suggestions. I'll definitely check out the python libraries.  

---

## 1 answers

### Answer by username_4 on 2019-08-13. Score: 5 | Accepted answer

Astropy is one option:
from astropy.time import Time
from astropy.coordinates import solar_system_ephemeris, EarthLocation
from astropy.coordinates import get_body, get_moon
from astropy.coordinates import SkyCoord, EarthLocation, AltAz
from astropy import units as u
import time;

t = Time("2019-08-11 11:00", scale="utc")
loc = EarthLocation(lat=38.2464000*u.deg, lon=274.236400*u.deg, height=0*u.m)

with solar_system_ephemeris.set('jpl'):
  moon = get_body('moon', t, loc)

altazframe = AltAz(obstime=t, location=loc, pressure=0)
moonaz=moon.transform_to(altazframe)

print(moonaz.alt.degree,moonaz.az.degree)

If you want a library you can ship with a product, you'll want something much smaller.  I am actually working on a library converted to many different languages to do just that. 
 Only the JavaScript version has a working Alt Az example, but it should be easy to convert to other languages (and will be eventually).


---

