Pushing data from iOS to Google Cloud BigQuery - ios

I am new to Google Cloud Platforms and not quite sure with the whole architecture but what I am trying to achieve is to save some data to Google Cloud from an iOS application and do some analytics work on this data using Google Cloud Products, such as: Dataproc and Datalab. From what I read so far I would need to create a dataset in Google Cloud BigQuery and create a table in it. I have done this using the Google Cloud Web UI but now I want to populate the table from my iOS app. I can't seem to find how to do that.

The most painless route would be to wire up Firebase Analytics and then turn on its daily log export to Big Query, as described by Google in the walkthrough Importing Firebase Analytics Data into BigQuery. Google maintains the entire analytic export stack for you then, seeing as they also maintain Firebase. The downside is that the analytics export happens only daily.
Alternatively, you'd be looking at using the Big Query REST API to upload data, as documented by Google in their Loading Data with a POST Request how-to guide. The iOS tooling for that would be your usual NSURLSession and NSURLDataTask APIs, or whatever abstraction you prefer that's built atop them.
Google does maintain a collection of iOS-native APIs, but unfortunately, Big Query is not included amongst the supported APIs as of May 2017. There are native Big Query clients for Go, C#, and Java, amongst others. So you could use your own API for upload to a server you control, and then use one of those client APIs serverside to implement the actual Big Query integration, if you wished.

Related

How to use API instead of using Google BigQuery Data Transfer Service?

I am trying to create BigQuery Data transfer config for Google Adwords through API using a programming language (Python, Java). I looked at the documentation about BigQuery data transfer API. But there is no proper process for that. Maybe I could not understand properly. Can anyone help me in understanding how to use API to get daily analytic data from YouTube instead of paying YouTube to use their BigQuery Data transfer?
You need to get started using Adwords SQL
https://developers.google.com/adwords/api/docs/guides/first-api-call
Refer to the Getting Started section of the Python client library README file to download and install the AdWords API client library for Python.

Can we use Google Spreadsheet as a backend database

I am trying to develop an application, where I where fetching data from multiple clients related to some transactions. Now I want to make some analysis using the Google Spreadsheet. Is there any way by which I can achieve this using the ASP.Net MVC(using C#). Google provides OAuth and When I implement the code and when I am trying to send the data to Google spreadsheet which I receive form the clients. However, when I am doing that, for every new client, Google asks for login credential. Client enter their own credentials, and the Google sheet instead a common sheet, client own sheet is used. Thus, my purpose is not solved. Is there any way possible to do this. I does not seem to find proper documentation on Google as well. Please provide some suggestions to implement this. Thanks in advance.
This can be done very easily if you just want a read only database.
You must publish your Google Sheet to the web and, from its url, copy its id.
For example my sheet has this url: https://docs.google.com/spreadsheets/d/1IHF0mSHs1HdYpIlIzYKG3O8SnAhKU_a6nEJSz04Togk/edit
The long alphanumeric string in the middle is my sheet id. Copy it and place it instead of XXXX in the following url, as follows:
https://spreadsheets.google.com/feeds/list/XXXX/1/public/basic?alt=json"
So the final url would look like this:
https://spreadsheets.google.com/feeds/list/1IHF0mSHs1HdYpIlIzYKG3O8SnAhKU_a6nEJSz04Togk/1/public/basic?alt=json
Then you can simply access this url and get all your data as json.
Using jQuery:
var $url = 'https://spreadsheets.google.com/feeds/list/1IHF0mSHs1HdYpIlIzYKG3O8SnAhKU_a6nEJSz04Togk/1/public/basic?alt=json';
$.getJSON($url,function(data){
alert(JSON.stringify(data.feed.entry));
});
You will get a long json structure. The relevant data is in data.feed.entry. There you'll have many entries. On each one you'll have a "content" property and within it, a "$t" one. These will give you all the cells.
So for getting the first row, you will have to get data.feed.entry[0].content.$t.
Hope it helps.
This can be accomplished using Google Apps Script. In particular, you can achieve this with a "bound" script in Google Sheets (i.e. a script that was created in the context of the sheet that you wish to create as the "backend") that you then publish as a "web app" script. When you publish it, you can make it execute with the authority of the owner of the spread sheet (rather than the authority of the user who invokes the url), which will not require the end user to explicitly authorize themselves (since it is the script publisher's credentials, not the user's credentials, that are being used).
It should be noted that, while this (and generally building on top of Google Apps Script) is a reasonable approach for small-to-medium apps, you'll probably find using Google Cloud Platform (and, in this particular case, the Cloud Datastore) as the better, more scalable solution for small-to-large apps. That is, if you are prototyping or creating an internal tool that is unlikely to catch fire overnight, I'd go with whichever approach you find more convenient / simpler; if you are creating an app that could potentially experience a "success disaster", I'd go with Cloud Platform, instead.
If your sheet is public, you can do it withouth authentication. You can use google API Visualization with the query language or use the Google Sheets API.
But if your sheet is private, it is mandatory the use of OAuth2 authentication through service account credentials.
In order to do that, you have to create a service account (with owner of the project role for example). Then you have to download the client_secret.json file which will be the one you use in your code.
Finally you have to share your spreadsheet with the email you get in this file. Look in the file and you will see it.
I have made a tutorial. You can visit at http://edba.xyz/google-sheets-as-database. It is mainly based in PHP but it is easily trasportable to
other languages.
I have recently been developing a website using google sheet as backend. It is great. The speed is also appreciable.
I have integrated the custom backend which I wrote on google apps script with my Django app. So now my website stores the user information on google sheets. The google sheet code and Django app interact via Rest API which can be easily developed using doGet() and doPost() in apps script and python request on the Django side. Once the necessary structure is built( it does take some time tweaking if you are new) but then it works as a great database for your website.
Google spreadsheet is a great solution for quick prototyping database and even in some cases for production use.
People have already realized the potential and there are many tools today for turning your Google spreadsheet into a backend api
There are couple of libraries such as node-sheets for obtaining a json feed from a Google spreadsheet (read-only)
Also, if you need a complete standalone service you have some paid options like
https://sheetsu.com
And also open source options such as
https://github.com/scheduleonce/express-sheets
This can be installed on any cloud provider via Docker and you can point it to your spreadsheet and it will dynamically turn it into an api.
So if, for example, your spreadsheet has the following sheets:
| articles | products | users |
It will automatically create the 3 endpoints
GET /articles
GET /products
GET /users
It is suitable for read-only apis (you update the spreadsheet directly, not through code) that don't need to be changed too often (although you can control the update interval)
You can use Kodem.io.
Google Sheets As Backend allows you to do CRUD requets using Google Sheets.
Disclaimer: I work at Kodem

Accessing and manipulating Google Sheets in iOS

I'm attempting to use Google Sheets as a back-end for an iOS app. The spreadsheets in question are private, so will require Oauth 2.0 for interactions.
So far I have come across three different ways to access spreadsheet data, but I'm not sure which one is the right one.
GData library
Google API Client
Google Apps Script
Has anyone here found success with any of these options, and if so how?
Rather than any of the options you've listed, you should be looking at the
Apps Script Execution API, which is a supported component of the Google Apps Script environment. It was introduced just over a month ago, in response to the growing demand for ubiquitous access to Google Apps.
As for the "how" - the Quick Start should get you started.

Using google endpoints with sql

I'm still new to GAE, and I would like to have more wisdom about couple of things.
I searched in documentation, but I think I'm just too stupid to understand some things from documentation.
How can I combine Google Cloud SQL with endpoints? Is there such possibility?
How can I use endpoints to upload videos to google platform?
You should be able to use anything you can do on a non cloud endpoints api to cloud endpoints like google cloud sql. But since it's on preview you might encounter bugs/changes when it goes out of preview. You should create a Cloud SQL tests models on regular app engine app then try to use it on cloud endpoints, so you can minimize debugging for errors.
https://developers.google.com/appengine/docs/python/cloud-sql/
You will need to use a blobstore api:
https://developers.google.com/appengine/docs/python/blobstore/
on your endpoints have a method that creates the upload url and use that to upload from your app then on the uploadHandler it will trigger once the whole file has been uploaded, process your blobInfo key store it appropriately.

Using google map API to open *.map or other map file ( offline map )

Is it possible to open map file at local computer (offline) using google map API? If yes, How?
I have programed an application in delphi. It shows the company cars on the map. but now we need the map to be offline. I have *.map file and may be I can find other map file from internet. I have not a point where to start at all. What do I have to do? tnx.
The google maps works by transferring data asynchronously from Google's servers to a user's computer. So if you are offline there's no way to communicate with Google's servers and retrieve such info. Even if you accomplish store the cached google maps and display offline you must follow the Google Maps API Terms of Service.
(b) No Pre-Fetching, Caching, or Storage of Content. You must not
pre-fetch, cache, or store any Content, except that you may store: (i)
limited amounts of Content for the purpose of improving the
performance of your Maps API Implementation if you do so temporarily,
securely, and in a manner that does not permit use of the Content
outside of the Service; and (ii) any content identifier or key that
the Maps APIs Documentation specifically permits you to store. For
example, you must not use the Content to create an independent
database of "places" or other local listings information.
As alternative you can use the Google Static Maps API V2 service you can retrieve a image, which can be saved to a file, basically you need build a URI like so
http://maps.google.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&sensor=false
And the using a GET you save the response in a file, check this article for a delphi sample Using Google maps (Static Maps) without TWebBrowser
Google maps API interact with google servers, online. There is no way to use maps API's. If its a web interface you can try looking at HTML5 projects which have ported maps offline with co-ordinate resolution.
Here is your FAQ related to storing google maps data offline
What I suggested about HTML5 projects, you can take a look at this.
This combined with offline html5 offline data caching should be a good solution for your problem.

Resources