API Interface - paulmoore/AstroCalendar GitHub Wiki
Note This is a preliminary design for testing purposes. This does not reflect the final state of the API
Clients are able to communicate with the remote server using a RESTful API design based on URL GET requests. The flow of information is one-way (the client can only ever request information, it does not post information to the server).
Example URL:
https://cisxserver1.okanagan.bc.ca/~astrocal/apiv2.php?requestType=all&startDate=14-11-2011&endDate=28-11-2011&latitude=49.9&longitude=-119.49350&altitude=350&GMTOffset=-8Note: Altitude is optional, default is set to 0.
- api.php: Main api entry point.
- requestType: API function we wish to access (to specify the kind of data being returned). For the time being, this must be set to "all". This will return all information available for each day in the given date range.
- startDate: The inclusive day to start requesting information for, format is: dd-mm-yyyy
- endDate: The inclusive day to stop requesting information for, format is: dd-mm-yyyy
- latitude: The user's current latitude, if available.
- longitude: The user's current longitude, if available.
- altitude: The user's current altitude, if available.
- GMTOffset: The user's offset from GMT.
The API server will respond to HTTP GET requests via JSON. Note that times returned are localized 24-hour clocks (based on the lat and long of the user) in the format: hh-mm-ss.
Example response:
{ "count" : "2", "0" : { "day" : "Monday", "dayNumerical" : "14", "month" : "03", "year" : "11", "payload" : { "lunarMonth" : "Kartik", "sunrise" : "07-44-00", "sunset" : "17-34-23", "moonrise" : "13-08-00", "moonset" : "22-08-00", "tithi" : "5. Panchami", "tithiStart" : "19:30", "fortnight" : "Shukla", "lunarMonth" : "Kartika" } }, "1" : { "day" : "Tuesday", "dayNumerical" : "15", "month" : "03", "year" : "11", "payload" : { "lunarMonth" : "Kartik", "sunrise" : "07-52-00", "sunset" : "17-28-00", "moonrise" : "13-02-22", "moonset" : "22-15-38", "tithi" : "6. Shashti-7. Saptami", "tithiStart" : "00:30-22:45", "fortnight" : "Shukla", "lunarMonth" : "Kartika" } } }
Currently the requests are put into an array of the following form:
( "startDate" => ( "day" => "14" "month" => "11" "year" => "2011" ) "endDate" => ( "day" => "28" "month" => "11" "year" => "2011" ) )