How do I use Google datastore for my web app which is NOT hosted in google app engine?

I want to use datastore of google in my web app but do not want to host it in google app engine, I want to host it some other machine. So how i can use datastore in such web app ? will it be more economical ?


Solution 1:

You would need to follow the Accessing the Cloud Datastore API from another platform procedure:

This section shows how to activate and access the Cloud Datastore API from an external application running on a platform outside of Google Cloud.

  1. Enable the Cloud Datastore API for the project. You can enable the API for an existing project, or create a new project and then enable the API. Enable the Cloud Datastore API

  2. To use the Cloud Datastore API, your Cloud project requires an active App Engine application. Open the App Engine dashboard and confirm your Cloud project has an active App Engine app. Open the App Engine dashboard

    Create an App Engine app if needed. The app must not be disabled.

  3. Go to the Create service account key page.

  4. Click the drop-down box below Service account, then click New service account.

  5. Enter a name for the service account in Name.

  6. Use the default Service account ID or generate a different one.

  7. Select JSON in Key type.

  8. Click Create.

  9. Upon successful creation, your browser will download the private key. The Cloud Platform Console provides a prompt that displays the private key file name. Note the file name so you can locate it, then click Close to dismiss the prompt.

  10. Your Service Account is the Email address displayed under the Service Account section.

  11. Your Private Key is the file you just downloaded.

At this point all services and authorizations are configured for your project and you can start writing code or exploring the API.

You don't actually need to write code for the GAE app and deploy it, see Is an App Engine instance required for accessing Datastore?

As for being more economical or not (I presume compared to running the app on GAE) - it depends a lot on the app's usage/scale, what the app does and how it does it.