what is nginx location ~* and ~

As stated in nginx documentation, ~* regex is for case-insensitive matching and ~ are for case-sensitive.

Your syntax is ok, but it can be rewritten without regex (shortest location goes last in request matching):

location /api/postdata {
}

location / {
}