I am using Directions api with HTTP Url connection in my Android application. I want to restrict an api key.
Does it work if I add HTTP referrer as a restriction?
If you're using the Directions API web service in an Android app, then you cannot restrict the API key with HTTP referrers. These only work for API keys used with client-side Web APIs such as these.
You cannot restrict your API key by IP address either though, since you are calling it from a mobile application so you may have to use a proxy server. Please see How to use Google-Directions-Android library with a restricted API key
Hope this helps you!