Firstly, it is easier to develop and debug the session relevance and then plug it into the API call. I use the session relevance tester, but other options are available.
You should read this Efficient Session Relevance Query for Computer Properties and the other threads linked from it to get hints on retrieving the information you want in an efficient manner.