Is it possible to access the adwords API directly through javascript? - google-api

I would like to access the adwords API through a simple single page web application using javascript. I would like to dynamically stop and start some of my adwords campaigns.
I can't seem to find any documentation on the REST endpoints for the API - only documentation for the various libraries.
Is it possible to do this through javascript only?

The current Adwords API is a SOAP-based interface, so there are no REST endpoints to use. It's of course still possible to construct SOAP messages and call operations without using one of the provided libraries.
Having said that, the next evolution of the API (the "Google Ads API") will support both gRPC and JSON REST-based communication, which would probably fit your scenario better. It's not yet ready for production use, however.

Related

Micro-service: How to provide an aggregated documentation?

Here is a simple use case to illustrate my question : imagine a bank mobile app, the features to implement are:
List the beneficiaries
Do a payment
We have one micro-service to handle the payments "PaymentService" and one to deal with the beneficiaries "BeneficiaryService". Both have a documented contract with RAML or OpenAPI.
I think it's not a good idea to let the mobile app call the two micro-services independently: it would expose too much the internal structure of the information system and provide no abstraction and so no mitigation.
So, we need to build a "facade" API that expose the routes of "PaymentService" + "BeneficiaryService" to ease the integration. Let's call it "MyAwesomeMobileApp"
I assume "MyAwesomeMobileApp" can be achieved by writing code (i.e. via an ESB or a dedicated Spring app) or via an API Gateway by configuration.
The thing is how do you provide aggregated documentation to your customer (the people coding the mobile app frontend) ?
By aggregated documentation I mean, a documentation with a set of routes from "PaymentService" and from "BeneficiaryService". A sort of third contract made with a subset of each micro-services.
Thank you
If you're providing (requiring) a gateway API between the application and the other services (which seems like a good choice in your example), you provide documentation only for the gateway API endpoints as the services it consumes are not relevant to the mobile app developer.
The way your facade implements communication with any services behind it could well be different than the services themselves (for example: hiding a field that is for internal use or using different field names) and, as such, the contract even for the service-specific models could well be different.
So, document the facade/gateway API well (and independently) and be on your way. It should internally have brokers or some other separation between the endpoints it exposes and the specific requirements of the services it consumes that allows them to be independently updated without too-tight coupling.
If you are looking for a simple concatenation of the contracts or in other words a "unified" public documentation that contains endpoints from both API specification documents/contracts, then you can give APIMatic's merging feature a try.
A detailed step-by-step walkthrough can be found here: https://docs.apimatic.io/manage-apis/api-merging/#merging-two-api-specifications---a-basic-example . However, in brief, the steps for your scenario can be:
Structure your API contracts in a root directory like shown in an example below:
dir\
payments\
openapi.json
beneficiary\
main.raml
APIMATIC-META.json
Here openapi.json and main.raml can be your OpenAPI and RAML contracts respectively.
A minimalistic APIMATIC-META.json configuration file can look like this to enable merging:
{
"MergeConfiguration": {
"MergedApiName": "My title",
"MergeApis": true
}
}
ZIP the directory, upload it and import it into the APIMatic Dashboard (You will need to sign up first).
Preview your public documentation by doing Generate > Proceed > Preview API Portal. Publish/host it as required.
If you are looking to automate the process, APIMatic has an API too: https://www.apimatic.io/docs/api#/http

Google geocoding API security

I am asking this question after extensively reading Google's recommended approach, but I do have a problem with all these approaches, let me explain the situation.
I use combination of geolocation and geocoding API to know the approximate state location and then display relevant content. The geolocation API needs to be called obviously from the browser to get appropriate geolocation of the user. Google provides HTTP Referrer based restriction for this API. I know someone can easily spoof the referrer and make calls with the same API key. I do not see a huge advantage even though Google recommends this.
On the other hand Google does not allow HTTP Referrer for geocoding API, but it does allow that for the MAPS JavaScript API. But again if you are not using Google maps then using that API is violation of Google's terms. Now google recommends to move the code that uses geocoding web services API to be on the back-end so that your key will be protected. But since ultimately I need to deliver the result to a front-end web application that is publicly accessible and I can only make a browser based Ajax call to first get the geolocation to feed to geocoding, I ultimately need to make an Ajax call to get my geocoding information. Then someone can easily just latch onto my end-point to piggy back on and call the geocoding API as much as they want. So for situations like this I want to know what is the ideal and secured way to deal with. May be there are other APIs that might be an ideal situation for this.
In my case, I am not doing any maps so it's all purely server-side to get latitudes, longitudes and driving distance between two points. This today from Google support which might help and if you're using maps, then the links may provide further insight.
Regarding API restrictions, please note that HTTP referrers will not
work on Geocoding API since HTTP referrers can only be used for client
side services. In other words, Geocoding is a web service API and
should only be used on server-side implementation. IP address
restrictions should be used for web service APIs. However, if you are
using the Geocoding API in a website, IP address restriction would not
work. Please check the suitable restrictions for each API in the
following link:
https://developers.google.com/maps/api-key-best-practices#api_key_table
To make this work, you should create a separate key and use the new
one in your Geocoding API request URL. You may add a restriction to
this key by using an "API restriction", and restrict it to Geocoding
API only. If you don't want to create another key, you may keep using
your current one but make sure to change your implementation and use
the client side Geocoding service from the Maps JavaScript API. In
that case, please refer to this documentation:
https://developers.google.com/maps/documentation/javascript/geocoding
Another suggestion would be to get a static IP address from your ISP,
especially if you are planning to use it on a public website. For
development purposes, a sound solution would be to get three separate
keys: one for the staging and tests, another for server-side requests
and a third one for client-side requests. That way, you are making
sure your API key is protected.

Oauth 2.0 | Google Documentation for operations

I am not able to find google documentation where all valid possible operation url per scope are mentioned?
I am consuming google API, using oauth 2.0 by Httpclient ie without using google api client jar or dependency.
To fetch Users profile I set emailId profile in scope and made a get request to https://www.googleapis.com/oauth2/v1/userinfo?access_token=XXX using HttpClient,this is working.
There is a page where all scopes are mentioned but unable to find list of possible operations for particular scope.Please help me into this.Thanks!
On the page describing scopes, if you click on the title of a scope section, say the Calendar API, you are brought to that API's home page. From here you can got to the guides tab and follow the quick start for the language of your choice (which Google encourages since their client libraries tend to do a lot of the work for you), or go to the reference tab and view the available endpoints. From here you can send your access token as described here
As far as which scope applies to which endpoint, I assume view and read only scopes will probably only work for GET requests, while other manage scopes will probably encapsulate the other endpoints. Apart from that assumption, I don't know if Google has the scope exactly lined up with the endpoints they are valid for.

Ruby: Fetch data from google analytics?

I want to gather google analytics data for daily/monthly report. All visitors, visitors for specific path and conversion rate. Setting for google analytics is already done (I think).
I searched ruby libraries, but many informations are out-of-dated and google api is sometimes update.
Now(2012-09-28) what library is popular? And How to get data? I searched ruby-toolbox, but both two libraries are still active?
Libralies
'garb'
https://github.com/vigetlabs/garb
'google-api-client'
http://code.google.com/p/google-api-ruby-client/
Purpose:
My first step: view data
My second step: edit data(Add note or notation)
thanks,
Google-Api-Client works fine, is an official client and is constantly updated, just check the commit logs and you will see. Note that this API is not for Google Analytics only but for any Google API that uses the Google Discovery API. You should try that.
Regardless of the client that you use make sure it's compatible with the latest version of the API. If it's built using the Google API Discovery service it's a plus because that means the client library will have support for new methods as soon as they are available. It's like an API for building API clients.
GARB on the other hand seems to be abandoned for a while and is probably missing out on several features that came recently.
Note that the Google Analytics API are currently read only. So no client library will support that since there's no API for writing annotations. There's a feature request for that though.

I am developing an application using google places api. Is check-ins to a place are per application

As per google places API documentation, no authentication is required for using the API. Is that how even check-ins to a place works? number of check-ins to a place are application dependent or aggregation of all check-ins across all registered apps.
Why checks-ins API is not provided via Google Places Javascript API
Using the Google Places API requires you to authenticate each request using an API Key.
Any Places API Check-In Requests sent using the Places API will only affect subsequent Places API Search Request for the API Key used to issue the Check-Ins.
As the Places Library of the Google Maps JavaScript API v3 does not require authentication to use, Check-Ins are not part of the library.

Resources