java json web client

568 views
Skip to first unread message

tec...@t-online.de

unread,
Dec 1, 2013, 1:41:33 PM12/1/13
to astro...@googlegroups.com
Dear Group,

I try to build the java client for astrometry web service.
May be exist the java client?
As JSON Login I have sent following
Variane1 (POST): http://nova.astrometry.net/api/login
JSON:
{"apikey":"**********"}
I have the answer:
{"status": "error", "errormessage": "no json"}
Variante2(POST): http://nova.astronomy.net/api
JSON:
{"login":{"apikey":"************"}}
the answer is
403 Forbidden
Both are NOT correct. Could You give me the right address/host and the right json text?
Many thanks in advance

Valentin

Dustin Lang

unread,
Dec 1, 2013, 2:38:10 PM12/1/13
to astro...@googlegroups.com
Thanks --

Running the python client may help you figure out exactly what the request has to look like:

> python client.py -k $API_KEY_NOVA -u /tmp/1.png
Python: {'apikey': 'XXX'}
Sending json: {"apikey": "XXX"}
Sending to URL: http://nova.astrometry.net/api/login
Sending form data: {'request-json': '{"apikey": "XXX"}'}

(this is the key line: what is actually in the x-www-form-encoded string sent to the server -- just as though there was an HTML form with a field named "request-json":)

Sending data: request-json=%7B%22apikey%22%3A+%22XXX%22%7D

Got json: {"status": "success", "message": "authenticated user: dstn...@gmail.com", "session": "YYY"}
Got result: {'status': 'success', 'message': 'authenticated user: dstn...@gmail.com', 'session': 'YYY'}
Got status: success
Got session: YYY


Hope that helps!

I believe that Karen Collins is also writing a java client (search this group to find her).

--dustin


tec...@t-online.de

unread,
Dec 1, 2013, 5:01:45 PM12/1/13
to astro...@googlegroups.com

I have the right the connection for the login. Now I can use the session.
I need  the json body for right json query with the session (!?) Where was the problem?
I must write the manual in the request body: request-json={"apikey":"********"}. Is it correct in JSON specification?
The login client in java you can find in the attachment. So, I need the json body sample with the session parameter.
PostClient.java

Dustin Lang

unread,
Dec 2, 2013, 8:32:36 AM12/2/13
to astro...@googlegroups.com
Again, if you run the python client.py, you will see this all:


> python client.py -k $API_KEY_NOVA -u /tmp/1.png
Python: {'apikey': 'XXX'}
Sending json: {"apikey": "XXX"}
Sending to URL: http://nova.astrometry.net/api/login
Sending form data: {'request-json': '{"apikey": "XXX"}'}
Sending data: request-json=%7B%22apikey%22%3A+%22XXX%22%7D
Got json: {"status": "success", "message": "authenticated user: dstn...@gmail.com", "session": "YYY"}
Got result: {'status': 'success', 'message': 'authenticated user: dstn...@gmail.com', 'session': 'YYY'}
Got status: success

Got session: YYY

Upload args: {'publicly_visible': 'y', 'allow_modifications': 'd', 'allow_commercial_use': 'd'}
Python: {'publicly_visible': 'y', 'allow_modifications': 'd', 'session': 'YYY', 'allow_commercial_use': 'd'}
Sending json: {"publicly_visible": "y", "allow_modifications": "d", "session": "YYY", "allow_commercial_use": "d"}
Sending to URL: http://nova.astrometry.net/api/upload

Got json: {"status": "success", "subid": 128115, "hash": "094e25d1cf7028e037cacd81a608c6c12c42665e"}
Got result: {'status': 'success', 'subid': 128115, 'hash': '094e25d1cf7028e037cacd81a608c6c12c42665e'}
Got status: success


To upload a file, instead of sending an x-www-form-encoded message, you have to send a multipart/form-data message, exactly like a normal HTML form with a text field and a file upload.

The first part should be "text/plain", with "Content-disposition: form-data; name="request-json" ", and the JSON as the body.

The second part should be "octet-stream", with "Content-disposition: form-data; name="file"; filename="ZZZ" "

cheers,
--dustin

tec...@t-online.de

unread,
Dec 7, 2013, 5:23:51 AM12/7/13
to astro...@googlegroups.com
I have the following implemented: the query of the session (it is ok), and then I send the following (YYY = session):
{'publicly_visible': 'y', 'allow_modifications': 'd', 'session': 'YYY', 'allow_commercial_use': 'd'}

I have tried with "request-json" too ( with the same result :(  ).
As a
result I get: HTTP 500
I have been informed already several times, the Python client to use.
Just with my development I would like to avoid it: that's the goal.
There are many people
who do not have Python for various reasons.

Could You help me to formulate the upload query correctly? The session I have.


regards

Valentin

Dustin Lang

unread,
Dec 8, 2013, 11:07:02 AM12/8/13
to astro...@googlegroups.com
I was not suggesting that you USE the python client; I understand you want to write in Java.  I'm just saying, the python client WORKS and you can SEE what it does.

If you want to upload a FILE, you need to create a MULTIPART/FORM-DATA request, as I describe above.

If you want to send a URL, you must add the "url" key.

The API accepts form encoded data; you ALWAYS need to include   request-json=JSON_TEXT

It may be helpful to read the error message the web server gives you along with the error 500.

--dstn

tec...@t-online.de

unread,
Dec 10, 2013, 12:55:54 PM12/10/13
to astro...@googlegroups.com
Ok. I have upload. Could You help me to get the result?


On Sunday, December 1, 2013 7:41:33 PM UTC+1, tec...@t-online.de wrote:

tec...@t-online.de

unread,
Dec 10, 2013, 1:00:26 PM12/10/13
to astro...@googlegroups.com

Ok. I have upload. Could You help me to get the result?

{"status": "success", "subid": 135968, "hash": "93a145e00b530b34e6a618587e96557919606c0d"}

P.S. Not always the same: for example
reqEntity.addPart("request-json", new StringBody(jsonObject.toJSONString(), "application/json", Charset.defaultCharset()));
it is not here jsonObject.toJSONString() as in login case.

Dustin Lang

unread,
Dec 10, 2013, 5:23:00 PM12/10/13
to astro...@googlegroups.com
First, use that submission ID to get the submission status:

/api/submissions/SUBID/

In that JSON object, look in the "jobs" list.  It lists "job ids" for the submission.  Get status for those jobs:

/api/jobs/JOBID/
/api/jobs/JOBID/calibration/

cheers,
--dustin

tec...@t-online.de

unread,
Dec 11, 2013, 4:23:04 AM12/11/13
to astro...@googlegroups.com
I have it (after getting "calibration"):
     Parity      1.0
     Orientation 89.04237151778
     Pixscale    9.863707137088177
     Radius       5.6902562958290455
     RA(deg)     46.96815245427165
     DEC(deg)   41.39727391431627
The first question: have You any requirements for java clients? I can do , for example, the syntax of client to client.py identical.
The second question: Where can I find the list of ra,dec and pixel position all identified stars on the full image?
The next: whai kind of data can I load more?

regards

Valentin

Dustin Lang

unread,
Dec 11, 2013, 1:08:39 PM12/11/13
to astro...@googlegroups.com
The URLs of the web site are:
  http://trac.astrometry.net/browser/trunk/src/astrometry/net/urls.py

You can get the wcs file at

/wcs_file/JOBID

For the RA,Decs of catalog objects in the field,

/rdls_file/JOBID

And the sources detected in your image,

/axy_file/JOBID

For named objects,

/api/jobs/JOBID/annotations/

I would be happy to point to your java client in our documentation.

cheers,
--dustin

valentin_com

unread,
Dec 12, 2013, 8:36:38 AM12/12/13
to astro...@googlegroups.com
Many thanks.
I have these fits files decoded.
It does not solve my main problem. RDLs has RA, DEC, but it has not X, Y (pix) position on the full image. AXY has all X, Y position, but it has not RA, DEC for each. I need both type of  values ​​together. I have in the annotation list of deep sky objects with RA, DEC. But I need the stars with X, Y, R, DEC. How can I get it?

valentin_com

unread,
Dec 12, 2013, 9:52:57 AM12/12/13
to astro...@googlegroups.com
How can I get followings: *.corr files, user_id, user_image_id?

Dustin Lang

unread,
Dec 12, 2013, 3:45:00 PM12/12/13
to astro...@googlegroups.com
The user_images list is in the submission status,

/api/submissions/SUBID/

The corr.fits files are currently not available in the web version.

You can do the x,y -- ra,dec conversion using the wcs.fits file (eg, using the Astrometry.net wcs-xy2rd and wcs-rd2xy programs).

--dustin

valentin_com

unread,
Dec 13, 2013, 9:23:34 AM12/13/13
to astro...@googlegroups.com
Hallo Dustin,

I send the first version JANClient: Java Astrometry Net Client. Threre is the very small INSTALL.txt. If by the start the JANClient has trouble, when JANClient prints the small using instruction. I will be happy for the comments and wishes. The sources are included.
When necessary, I can also send a NetBeans project.

Best regards

Valentin Steinhauer

tec.de(at)t-online.de

JANClient.zip
INSTALL.txt

valentin_com

unread,
Dec 13, 2013, 9:58:08 AM12/13/13
to astro...@googlegroups.com
I forgot to delete my APIKEY in Packet (in config.properties). Can you do it, please?

valentin_com

unread,
Dec 13, 2013, 11:51:28 AM12/13/13
to astro...@googlegroups.com
I have corrected the problem with apikey in the first packages.
JANClient.zip
INSTALL.txt

valentin_com

unread,
Dec 14, 2013, 11:25:13 AM12/14/13
to astro...@googlegroups.com
Has the WCS generated file an error?
NAXIS = 0
Have it to be 2?

Jean-Paul Godard

unread,
Dec 15, 2013, 4:46:49 AM12/15/13
to astro...@googlegroups.com
Hi Valentin

I do test "Janclient" on a seven box. A little problem with image in fits format albeight solution is ok:

C:\...\Astrometry\Testjanc\JANClient>java -jar JANClient.jar buba.fit

Java Astrometry.net Client is running ...Unexpected character (<) at position 0.
..
Image buba.fit
Calibration of the image:
     Parity      1.0
     Orientation -89.58446923900631
     Pixscale    2.8010110976469638
     Radius      0.6754339989720155
     RA(deg)     350.2033612674675
     DEC(deg)    61.13089630510049

Thanks for the tool. Its Nice.
suggestions:
1 - collect all downloaded files in a directory (/download) to facilitate deletion.
2 - allow a parameter in the command line (/sync) to synchronize the current ascom scope on RA/DEC


Dustin Lang

unread,
Dec 16, 2013, 11:09:40 AM12/16/13
to astro...@googlegroups.com
It's just a WCS header -- no image pixels -- so it must have NAXIS=0.

cheers,
--dustin

valentin_com

unread,
Dec 17, 2013, 1:19:18 PM12/17/13
to astro...@googlegroups.com
Hallo Dustin,

I have analysed the source from SkyView and the xy2rd transformer Pixel2rd (?) in the SkyView.
If NAXIS = 0 , then it will be cam never to TAN and SIP, as it given in WCS. Is it the error fro SkyView or
from wcs_xy2rd ?

regards

Valentin

P.S. the small insignificant warning from JANCleant is not error, it is a warning, if the connection was still not occurred.
Then the astrometry.net server reply with the HTML. And first character is "<" not allowed.

valentin_com

unread,
Dec 17, 2013, 1:23:34 PM12/17/13
to astro...@googlegroups.com

Hi,
Could you please explain what does it mean. the ASCOM RA/DEC synchronization?
Many thanks

Valentin

valentin_com

unread,
Dec 19, 2013, 4:59:06 AM12/19/13
to astro...@googlegroups.com
Hi Jean,

I send the new version with the out directory parameter.

regards


Valentin

On Sunday, December 15, 2013 10:46:49 AM UTC+1, Jean-Paul Godard wrote:
INSTALL.txt
JANClient.zip

Jean-Paul Godard

unread,
Dec 21, 2013, 7:45:12 AM12/21/13
to astro...@googlegroups.com
Hi valentin,

When you have a "ascom" compatible scope (see http://ascom-standards.org ),  you may take pictures to automatically synchronize the scope (typically 3 points are required. usually we use bright stars).
When you get the coordinates of the field (center of picture) , you put these coordinates in the ascom telescope interface and send the "synchronize request" if required by user.

selecting the scope (in VB) looks like:

Dim chsr As New ASCOM.Utilities.Chooser
chsr.DeviceType = "Telescope"
' Retrieve the ProgID of the previously chosen
Dim scopeProgID As String = My.Settings.scopeProgID

' device, or set it to ""

scopeProgID = chsr.Choose(scopeProgID)

if scopeProgID = "" Then Return

' Maybe save the new telescope choice ProgID here...

My.Settings.scopeProgID = scopeProgID

My.Settings.Save()

' Create the Telescope and connect it.

Try

scope = CreateObject(scopeProgID)

Catch ex As Exception

MsgBox("Problems to connect " & scopeProgID & " " & ex.ToString())

Return
End Try


And synchronizing looks like:

If rep = MsgBoxResult.Yes Then

scope.SyncToCoordinates(db1, db2)

Msgbox1("sync to " & vbCrLf & "Ra = " & db1.ToString & vbCrLf & "Dec= " & db2.ToString)

End If

valentin_com

unread,
Dec 22, 2013, 10:08:45 AM12/22/13
to astro...@googlegroups.com
Hallo Jean,

this is the version with an ASCOM synchronization.
I have NOT the possibilty to test full. If anybody will do it, many thanks.

regards & merry christmas

Valentin
JANClient.zip
INSTALL.txt

Jean-Paul Godard

unread,
Dec 24, 2013, 11:37:57 AM12/24/13
to astro...@googlegroups.com
Hi Valentin,

Thanks for your time... this is my Xmas gift.
I'll test this as soon as the stars come back;..

Season' greetings
JPG


valentin_com

unread,
Dec 28, 2013, 7:47:36 AM12/28/13
to astro...@googlegroups.com

Hallo astrometry.net,

It was made small change: Read the NEW IMAGE file and the conversion DEG to HMS.

regards

valentin

JANClient.zip
INSTALL.txt
Reply all
Reply to author
Forward
0 new messages