Want to Stop Rebuilding "Expensive" Parts of your Flow? Explicit Builds are the Answer!READ MORE

API Query enrichment through custom function

yashpuranik
Neuron
Neuron
API Query enrichment through custom function

Hi All,

 

I know that API Developer allows for enrichment with look ups from a particular dataset/SQL table. Can this enrichment happen through a custom Python function or with a visual recipe?

I am thinking of a use case say where I have input data with latitude/longitude information. In my flow, using suitable prepare steps, I can create additional features for say county/city with reverse geocoding and use them for my prediction models. I can also develop an API endpoint for this prediction model with API Developer.

However, this API now expects county/city information in the query. The county/city information cannot be looked up from a table. How can I have this information generated within the API so that these features are available for my prediction model?

yashpuranik
0 Kudos
1 Reply
HarizoR
Developer Advocate
Developer Advocate

Hi yashpuranik,

You will need to code the reverse geocoding logic yourself and include it in a Python function endpoint which will take your raw input data point, enrich it (i.e. add the relevant key-value pairs in the JSON payload) and forward it to the Prediction endpoint. To learn more about this usage pattern, you can read this page of the documentation explaining the concept of "dispatcher endpoint".

It is unfortunately impossible to reuse the reverse geocoding step from the Prepare recipe/Analysis script, as it relies on a plugin installed on your Design node that cannot be packaged in your API service. 

 

Hope this helps.

Best,

Harizo

0 Kudos