Receive email notifications by changing your settings.
Click on your picture in the top right corner, go to Preferences and select your notification preferences.
Thank you for contributing to our forum!
Please keep in mind:
1. To only comment on the topic where the discussion is about. Do you have a new question or topic? Please start a new discussion.
2. Be kind to other users!

XA Queries with the api

Hi Tygron,


I am trying to make an XA query work with the API. With no succes. Is it true that you can not use an XA statement when working with the API?


Thank you,


Ward

Tagged:

Comments

  • Hey Ward,


    An X query (including the XA query) is not a valid TQL statement as such. Behind the scenes, they are parsed into individual statements which are then invisibly related to specific cells in an excel. In other words, an X query is an instruction to the Tygron Platform which states "I want a bunch of individual TQL statements to be written below here".


    Assuming your use-case is that you want to perform a number of queries, namely one for each item of a given type, possibly with the presence of a specific attribute, you can recreate this functionality in your own script. The steps would be:

    1. Request all items of a specific type (e.g. neighborhoods, areas, buildings, etc) using the content items endpoint of the API.
    2. Check all items to see whether they meet your criteria, and add them to a separate list of items which will hold all the items you want to query. (For emulating a normal X query, no check is needed. For emulating an XA query, check whether the item has the desired attribute, and that that attribute has a non-zero value)
    3. For each item in the new list, construct the desired query by placing the ID of the item in place of the X (or XA_[attribute]) in the query.
    4. Send the query to the API, and store/process the result as desired.

    An added benefit is that you can fine-tune the check as desired. E.g. not ignoring items which have the desired attribute but with a value of zero, checking whether items have a set of attributes, including more or fewer items in your list of items to query as a session progresses and more things are added, and most anything you'd like.


    Will this help you move forward?


    Kind regards,


    Rudolf

  • Hey Rudolf,


    Yes, very well. Thanks for the advice. It is no biggy to make a loop function in R/Python to request a query,


    Thank you!

Sign In or Register to comment.