Google API with / without key - javascript

Which one is the best way (with or without key) to use Google map in mobile app to show location? I am able to show location without key using this http://maps.google.com/maps/api/js?sensor=false .
But people are saying that this is not correct way. Is there any limitation to use Google API without key? What is the purpose of having key for google API?
Please suggest me the best way to do.
Thanks,

The API limits non business users to 2,500 requests per day. If you don't provide a key, the request are limited by your IP-address. If you do provide a key, the quota limits are per-key instead of per-IP-address. You can also use a key to monitor your application's API usage.

Related

Is it possible to force the Google Maps API to use a specific Transit Provider

I am writing an app (in react) that provides an ETA to a user on a train for when they will reach the next NJTransit station based on their location.
I would like to use Google Maps, but I do not see a way to ensure it will only use NJTransit. For instance, if I were to ask for directions from Newark to New York, it is possible Google Maps would give a route using the Path.
I have the GTFS data, but calculating it off of that would be inaccurate due to lack of delay information. NJTransit seems to have a real-time GTFS feed, but it is designed for servers and this has to be completely client based.
From my experience using google maps api, you have limited ways that you can form a request. To make routes you will have to use gooole routes so you can take a look over there on how you can tweak your request to have the best response. Hope it helps, if not let me know

should I keep my geocode api key a secret?

I'm working with the geocoding api from google. I'll be hitting the following endpoint with ajax like so...
$.ajax({
url: https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=MY_API_KEY,
success: function(data) {
console.log("yay");
}
})
Is it safe to add my api key directly into my javascript? This means it will be viewable from my website and also on source control. What precautions should I take?
No, you should absolutely hide your API key(s) from the client and source control. A malicious user could use the key to exhaust your quota, making your application potentially unusable.
To avoid this, create a server which fetches the data from the API and then serves it to the user. Additionally, you should apply rate limiting, to prevent users exhausting your quota through your own application.
For more information, see this support article.
Consider also using the Geocoding Service in the Google Maps JavaScript API. When loading the JavaScript API, make sure to use an API key that is restricted to your website.
Remember that results from the Google Geocoding services must be displayed on a Google map (see 10.4.d and 10.4.e).

YouTube API difference between API Key and Developer Key

I'm having some issues understanding the differences between an API Key and a Developer's Key when it comes to utilizing the YouTube API.
My application is using the restful requests in v3 of the Youtube API and I can set an API key via the gapi.client.setApiKey() function , which I have done during development, but when I was looking at the quotas, https://groups.google.com/forum/?fromgroups=#!topic/youtube-api-gdata/e1JDQ4lqbXU, it states that they are tied to a developer key instead and that the developer key should be sent with each request. I went ahead and got one for development purposes, but I'm not sure how they interact with each other.
I also didn't find any details on how to send the developer's key with each restful request (such as gapi.client.youtube.channels.list), only how to include it in the header or query string when making a regular get request.
Can someone help me understand the difference between the two, how they are related, whether I need both, and how to use them in restful requests, or if I need to switch to regular get requests?
Sorry for the confusion.
"Developer keys" refer to keys that worked with v1 or v2 of the YouTube Data API. You can obtain them here. There's a separate quota system in place for v1/v2 and yes, developer keys do come into play there.
"API Keys" refer to keys that you use when making unauthenticated requests using v3 of the YouTube Data API. (If you're making an authenticated request, you don't include an API Key, since the OAuth 2 client id/secret identifies your application.) You get an API Key that you could use with YouTube from the Google APIs console, after turning on the YouTUbe Data API v3 as one of the Services you're using. Quota in v3 is tied to your API Console project, and your API Key identifies which project you're using.
The takeaway is that if you're making unauthenticated YouTube Data API v3 calls, you should only include an API Key from the Google APIs console in your request. If you're using the JavaClient library, that's done via gapi.client.setApiKey().

using google maps api without a key

The instructions for v.3 of the Google Maps API say that I
should load the Maps API using an API key
Curiously it says I should..., rather than I must..... Anyhow, at the moment, I am not using an API key simply because (as far as I can remember) there was no mention of an API key when I was writing the code that calls this API.
Should I go back and add an API key to the URL that loads the API? It seems to work fine without the key, so I don't have any particular incentive to do this.
You're actually required to not have a key if you're a business user. Here's a quote from Google:
Google Maps API for Business developers must not include a key in their requests. Please refer to Loading the Google Maps JavaScript API for Business-specific instructions.
Normal users, however, will be fine with or without a key, although Google recommends having a key so you can monitor the API usage. Here is a quote verifying this:
The Google Maps JavaScript API V3 does not require a key, but there are benefits to using one.
You only need a key if you want to use the API management console to restrict access, collect usage statistics, etc. So, a key is recommended but not required.
See Obtaining an API key
In Api version 2 a key is required to run gmap out of localhost
in the API v3 a key is not required

Google API Key for Local Testing

Is there any way to get a Google API key for local testing purposes? I intend to use some of the Google APIs mainly for educational purposes (i.e For learning about it..) and I need to generate an API key without supplying a web site URL..Thanks in advance..
P.S: If it helps I'm trying to learn about Google Translate API
As far as I know, you can supply a local host name (e.g. localhost or testserver) when generating the API key.
Q) Is there any way to get a Google API key for local testing purposes?
Ans:- There seems no way to have google maps API key free without credit card.

Categories

Resources