To go with the new VSP, I've designed a new REST API for developers who want to integrate their programs with VSP. The endpoint for the api is http://www.aavso.org/apps/vsp/api/chart/
If you have a chart ID, you can simply add the chart id to the url like so:
http://www.aavso.org/apps/vsp/api/chart/X15094C/
If you want to plot a new chart you can specify the fields as GET params:
http://www.aavso.org/apps/vsp/api/chart/?star=SS+Cyg&fov=60&maglimit=14…
If you open an API url in your browser, you'll get a nice formatted HTML display of the data; try it out by clicking the above links. For your progams, you can get output in JSON or XML by adding format=json or format=xml to your GET parameters.
You can find full documentation for the API here: https://www.aavso.org/api-vsp
If you're interested, please try it out and let me know what you think! I'll be writing up some more detailed documentation over the next few days, but if you have any questions feel free to ask.
Seriously, this is great. Thanks!
Hi,
One suggestion, if possible: how about adding the coordinates (RA, DEC) of the variable star in the output? It could even be just as simple as creating another entry in the table (at the begining, ot at the end).
Currently I'm working on an app that needs this as well, and having it in the VSP output will spare me from making an HTTP request to VSX.
Regards,
Alex
TA currently fetches photometry by chartid with:
http://www.aavso.org/cgi-bin/vsp.pl?chartid=13591Dqq&delimited=yes
How would it get that same data via the new API?
Thanks,
George
Hi George,
I may have missed it somewhere else, but Photomcap is not compatible with the new VSP.
Michael
I'll answer my own question. After Googleing photomcap I found this link to version 18. Seems to work.
https://drive.google.com/folderview?id=0B8twDwcGOO6cQVF4WlM5QXhZaU0&usp…
I'll second this. Having the photometry data in a simple to interpret file of delmited lines like before would be much easier to handle for on-the-fly handling in a program.
Brian
Alex, that's a good idea. I'll plan on adding more data, such as ra/dec, to the results.
George, I explain how to query a specific chart id in my first post. Check out the results; you'll see that it includes all the photometry data for the field.
Hi Will,
I tried
https://www.aavso.org/apps/vsp/api/chart/X15223Z/?format=api
and the return was json. Did I miss something?
Brian
You may specify the
Hi Brian,
You may specify the API format to XML as given in the example
https://www.aavso.org/apps/vsp/api/chart/?format=xml&fov=20&maglimit=18…
and decoding the XML format is not too difficult.
Pierre
Hi Pierre,
Just finished code on parsing an XML file returned for R AND. Seems to be OK.
Right now I'm using a compiler that doesn't have ready access to the https protocol; http was no problem. So, what I do is have my program generate the necessary URL where it can be copied/pasted into a browser. The return is saved as XML and off the user goes. It would be nice to get the return directly, but all I was getting was a redirect message that provided a link to the same URL I sent. Computers! Gotta love 'em. <g>
Someday I'll come out of the Stone Age...
Brian
Hi Will
The VSP REST API looks great! Thanks!
I was pleased to see that I could add "&format=xml" to get XML vs the default JSON output. I suspect that's a standard offering of the REST framework you're using right? Great nonetheless.
I notice some fields that are either empty or null currently, e.g. title, special.
I look forward to seeing a REST API for AID soon.
David
I've finished writing up complete documentation for the VSP API. You can view it here: https://www.aavso.org/vsp-api
Now that the new VSP is released and stable, we're going to be shutting down the old VSP within the next few days. If you're using the old VSP GET API, please update your program to use the new API as soon as possible.
The old version of the VSP provided the ra and dec of the variable star or of the center of the field if the variable star was not specified.
Could you add those parameters in the new API output? For my LesvePhotometry application program, I need to have those parameters.
Thanks in advance
Pierre
[quote=dpp]
The old version of the VSP provided the ra and dec of the variable star or of the center of the field if the variable star was not specified.
Could you add those parameters in the new API output? For my LesvePhotometry application program, I need to have those parameters.
Thanks in advance
Pierre
[/quote]
I'll second that - having the coordinates of the variable star also included will spare me from making another request to VSX, making my web app feel more responsive.
I also have another suggestion: have a query string parameter that would tell VSP to not bother generating a unique ID, or saving the generated table/chart in the database. My web app only needs the JSON data, and will never interrogate VSP using a code; it doesn't make sense to keep the generated tables in the database, and I want to be able to tell VSP just discard the table.
Alex.
As requested, the Chart API now shows the RA and Dec when the chart was plotted from a star. The Star's AUID is also reported in this case. Enjoy!
Thanks, Will,
Major step forward !
Is there a particular reason why ra and dec info for the star are so much "separated"? At first I saw only "ra", and "dec" appears much earlier...
Best wishes,
Helmar (AHM)
How to format the url request with a star designation containing the + character like
ASAS J162811+0304.3
This designation work well with Visual interface of VSP and VSX but not with the VSP-API.
I presume that the interface replaces the + character by a blank before making the database query as shown in the url example SS+Cyg which is replaced by SS Cyg.
Have you a solution for this problem?
Thanks,
Pierre de Ponthiere
Pierre, you can replace the "+" symbol with "%2B" (without quotes). In general, you should be percent-encoding all strings you intend to put in the URL; you can see more info here: https://en.wikipedia.org/wiki/Percent-encoding
Depending on what language you're using, there may already be a library function available to do percent-encoding for you. I would strongly advice using it if one is available.
Hi Will ,
Thanks for the advice, I found the VBNet function to percent-encode the variable name. Now my VSP queries work well.
Pierre de Ponthiere
This is a very useful tool, and I was excited to learn there's an API available.
When I submit a request with ra & dec params, I'm getting a 500. The example you give above works fine:
https://www.aavso.org/apps/vsp/api/chart/?star=SS+Cyg&fov=60&maglimit=14.5
However, this doesn't work:
https://www.aavso.org/apps/vsp/api/chart/?ra=21%3A42%3A42.94&dec=43%3A35%3A09.9&fov=60&maglimit=14.5
Is there something wrong in my parameter format? I tried using decimal coordinates as well, with no luck.
Thanks!
For those who are going to read and parse the XML output of the new VSP API by scanning, there are a few wrinkles to keep in mind.
You need to keep track of
(1) what level you are in the XML stream and
(2) that you are not guarenteed the order of elements you find within a level.
For instance, from https://www.aavso.org/apps/vsp/api/chart/X15296BK/?format=xml
<list-item>
<band>V</band>
<mag>11.305</mag>
<error>0.032</error>
</list-item>
What if band comes after the mag and error? It doesn't here, but it could by XML rules. You wouldn't know which filter the mag belongs to until you finish that level defined by the list-item start and stop.
Further, some tagnames appear at multiple levels. Eg, "auid" appears at the root level, the star's auid, and in the phtometry level, the auid's of the comp stars. Same with "ra" and "dec"
XML scanners will offer the elements/tags it finds in sequence, offering tagType, tagName and tagContent fjor each. tagTypes are tagStart, tagContent and tagEnd. tagNames will be the string in <>'s (eg "band"). And tagContent will be the value (eg "V")
The way I am doing it is to watch for a tagStart with the tagName of "list-item". That tells me I've moved up one level. Level 1 is photometry and level 2 is bands. While in a level I look for tagContent and collect the expected data for that level, but I don't do anything with it until I see the tagEnd, tagName of "list-item". Then I know its safe to act on the collected data, in this case assigning the comp's V mag and error.
I've been going through this coding for TA, PhotomCap and VPhot. Ignoring these subtleties could cause very hard to debug errors in your data.
Cheers
George
Sorry I've been MIA the last few days, I've been tied up with another project. I've just updated the API to be consistent with regards to RA and Dec; they're now always reported in decimal degrees, not sexagesimal. This also fixed the bug that was causing people to get 500 errors on certain charts.
Since it looks like people were having trouble with the switch to decimal degrees, I've decided to revert to using sexagesimal coordinates for the API. Note that there were some instances originally where you might get decimal degrees instead of sexagesimal; I've made the API consistently return sexagesimal for all instances of RA/Dec in the API's return data. If you see any instance where this is not the case, please let me know so I can fix it.