If I am not mistaken, this is another example of rolling on your own. CGI.pm already has the API built so that it is easy to gather the data that the user provided. I would recommend that you look closer at CGI.pm and see how it can solve this problem for you. That way you don't have to make sure that your API is robust enough to handle changes to the website.
This is a good introduction to CGI.pm. You may want to really ask yourself why you don't want to use CGI.pm.
Good Hunting,
kha0z