KP Astrology REST API

Written by on August 30, 2017 in Astrology, C++ with 0 Comments

In today’s post I want to share my experience in implementing a set of REST API calls for Astrology. The series on iLangGen will resume after this.

As readers of this column probably know, I am the author of an Astrology software called KPAstro. You can read about it here. First released in the year 2004, KPAstro has been widely accepted by KP (Krishnamurti Padhdhati)  astrologers all over the world, thanks to its rich set of features and accurate calculations. The product currently runs on Windows platforms. Interestingly, over the past year I have received several emails (and some calls) from software developers asking me to expose the core functionality as API so that they can use the service to build apps for multiple devices. In fact, last week a developer from Kerala called me and spoke at length as to why building the API is a great idea. It was then that I thought I should take this suggestion seriously.

I started developing KPAstro in 2003 soon after I completed a course on KP system in Chennai. At that time, there was just one popular DOS-based software for KP system, and so I thought I should develop one for Windows. Over the past thirteen years, I have been gradually adding features based on my own evolution (as an astrology enthusiast) and the feedback from users of the software. The code is 100% C++ (Visual Studio) and uses third-party libararies for GUI, etc.

In order to get started, I spent a few days last week reviewing the existing functionality and decided on a core set of features (even this will be implemented in stages) to expose via REST. In terms of the compiler/tool to use, I chose Embarcadero RAD Studio C++ Builder 10.2.1 Tokyo for this exercise. I could have chosen VS 2015/2017 too (in fact, I might switch to that later).

It was quite straightforward to take the sources and rebuild for this new project. The following screens show the initial steps in RAD Studio project creation.

Project Step 1

Project Step 1

 

Project Step 2

Project Step 2

 

Project Step 3

Project Step 3

 

Project Step 4

Project Step 4

 

Project Step 5

Project Step 5

I then proceeded to build the application. No hitches here.

First I tested the server on my local machine. Since it was working as expected,  I decided to host it on Google cloud (I have a free tier subscription for one year). I created a Windows Server 2012 VM with 3.75 GB RAM and uploaded my executables there. Because this is not a full-fledged app, I decided to go with the Ephemeral IP (not Static IP) for communicating with the outside world. This means that every time I stop and restart the VM, the IP will change. That is acceptable for now.

I had to add custom firewall rule to allow inbound HTTP traffic at port 8080.

Google Firewall Rules

Google Firewall Rules

Similarly, I had to configure Windows Server 2012 firewall rules as well.

Finally, I launched my server app on the VM. See the image below.

KPAstro REST Server

KPAstro REST Server

Well, I don’t have a client application yet, so decided to check with the browser. The following screen image shows the data received from the server (in JSON format) for a query requesting Planets information for a chart with given ID.

Planets Data

Planets Data

I chose JSON output format for now since that is the most common. Here is another query getting information about Cuspal positions:

Cuspal Positions

Cuspal Positions

I have so far exposed half a dozen end points. Clearly, there is a lot more that needs to be done, which I will complete in due course.

Of course, before I make it commercial, I need to include Authentication, decide on proper versioning of the end points and support different SDKs (Java, C++, Python, etc.).

Well, I am happy I got off to a good start! Will share updates as and when I make further progress on this service.

Note: The good news is that the REST server engine is now fully implemented and ready for deployment. Read more about it here.

Tags: , , ,

Subscribe

If you enjoyed this article, subscribe now to receive more just like it.

Subscribe via RSS Feed

Leave a Reply

Your email address will not be published. Required fields are marked *

Top