I am trying to build an autocomplete where people can start typing a postal code, and get meaningful suggestions before the postal code is complete.
An existing example can be found here: https://weisse-liste.de/de/arzt/arztsuche/
Typing "120" in "Ort oder Postleitzahl" gets a list of suggestions where the postal code starts with "120". I am not affiliated with this site, and don't know if they are even using the Google geocoding API. (The request goes to their own server, then they do something with it.)
The closest I can get with Google API is http://maps.googleapis.com/maps/api/geocode/json?address=120&sensor=false&components=country:DE
But the only result this gives me is the one with "formatted_address" : "Germany", so the entire country.
The existing answer proposes client-side javascript. Which is totally valid given the question.
It would still be interesting to see an answer giving a hand-crafted url similar to the one above, which can be used in a server-side request. If this is not possible, no problem. An advantage could be privacy of the visitor, by avoiding a client-side request to Google. I am not even saying this is a good idea, but it could still be useful information.
The server side variant of the request is the following:
You can read about Places API Autocomplete web service at
https://developers.google.com/places/web-service/autocomplete