How to use filters/params in wordpress as headless cms api

ACF adds post meta, so, you will need to modify the query using the pre_get_posts action. Specifically, you’ll need to get the city name from the $_GET params and modify the query adding something like the examples in the pre_get_posts documentation. Essentially, something like this:

add_action( 'pre_get_posts', function(&$query) {
    if( is_main_query() && '' != $_GET['city'] ) {
        $query->set( 'meta_query', [
            [
                'key'     => 'city',
                'value'   => $_GET['city'],
                'compare' => '='
            ]
        ]);
    }
});

Note that you should also sanitize the input prior to adding it to the meta_query.

It is imperative that you read the documentation and understand it fully. There are plenty of small things that can throw you off, like the fact that the $query variable is passed in by reference (not returned by the function) so any changes you make are indeed affecting the main query in realtime (you don’t return anything in an action, only in filters).

If you are unable to get this to work, you might also consider using the posts_clauses filter but I’m not sure if that’s what you are looking for.

Sorry for the delay in responding. I had to do a fair amount of research and testing to make sure this answer would work.