Anybody knows of an API or service to convert cities/locations into coordinates?

I´m trying to build a map app for my portfolio where users can save their visited cities into a map. Then the user would have a customized map where all of the visited places that he saved would appear as “pins”.

So for this i have planned to make a simple search bar where the user would enter their city that wants to save, and then under the hood have a function that with the name of the city the user just entered, connects to an api that converts this city to coordinates. Once I have this coordinates I can make the app locate the pin exactly where it should in the map.

Here´s an example, in this web you can enter a city and it converts it to coordinates:

I basically have to build a function that does that. Any ideas? I´m not sure if its possible to do it manually.

Pd: I just signed for free GCP credit for 12 months. Maybe in Google Maps API is there a service that can help me with this?

Hi, already found a service (an npm package) . I leave it here if anyone encounters in the future the same challenge: