How to add field masking in rest endpoints of google places autocomplete api?

Viewed 13

I am hitting this url https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Hsr&key=api_key

I am getting this response

But I don't want the entire response. I just want the description to be returned to me. How can I do that?

I also got to know that by using field masking we can do it. But don't know how to implement them in the rest end points.

    "predictions": [
        {
            "description": "HSR Layout, Bengaluru, Karnataka, India",
            "matched_substrings": [
                {
                    "length": 3,
                    "offset": 0
                }
            ],
            "place_id": "ChIJzW7cv5EUrjsRecj7OYRxMvI",
            "reference": "ChIJzW7cv5EUrjsRecj7OYRxMvI",
            "structured_formatting": {
                "main_text": "HSR Layout",
                "main_text_matched_substrings": [
                    {
                        "length": 3,
                        "offset": 0
                    }
                ],
                "secondary_text": "Bengaluru, Karnataka, India"
            },
            "terms": [
                {
                    "offset": 0,
                    "value": "HSR Layout"
                },
                {
                    "offset": 12,
                    "value": "Bengaluru"
                },
                {
                    "offset": 23,
                    "value": "Karnataka"
                },
                {
                    "offset": 34,
                    "value": "India"
                }
            ],
            "types": [
                "sublocality_level_1",
                "sublocality",
                "political",
                "geocode"
            ]
        },
        {
            "description": "Hsr Bda Complex, 12th Main Road, Sector 6, HSR Layout, Bengaluru, Karnataka, India",
            "matched_substrings": [
                {
                    "length": 3,
                    "offset": 0
                }
            ],
            "place_id": "ChIJVaU9EY4UrjsRIrtCkznuBEc",
            "reference": "ChIJVaU9EY4UrjsRIrtCkznuBEc",
            "structured_formatting": {
                "main_text": "Hsr Bda Complex",
                "main_text_matched_substrings": [
                    {
                        "length": 3,
                        "offset": 0
                    }
                ],
                "secondary_text": "12th Main Road, Sector 6, HSR Layout, Bengaluru, Karnataka, India"
            },
            "terms": [
                {
                    "offset": 0,
                    "value": "Hsr Bda Complex"
                },
                {
                    "offset": 17,
                    "value": "12th Main Road"
                },
                {
                    "offset": 33,
                    "value": "Sector 6"
                },
                {
                    "offset": 43,
                    "value": "HSR Layout"
                },
                {
                    "offset": 55,
                    "value": "Bengaluru"
                },
                {
                    "offset": 66,
                    "value": "Karnataka"
                },
                {
                    "offset": 77,
                    "value": "India"
                }
            ],
            "types": [
                "premise",
                "geocode"
            ]
        },
       
    ],
    "status": "OK"
}```



0 Answers
Related