Skip to content

Implement RemoteAPI for Node #1328

Description

@susanlinsfu

I'd like to be able to connect to the datastore from any NodeJS application including my local. It would be great if the gcloud-node had the RemoteAPI implemented such as python(https://cloud.google.com/appengine/docs/python/tools/remoteapi).

Activity

  1. stephenplusplus commented on May 18, 2016

    @stephenplusplus
    Contributor

    I might misunderstand, but we support connecting to both the remote API and localhost as well. I know you've been connecting to the emulator, so you already know how to do that. To connect to the remote API, just unset the Datastore emulator environment variable, and make sure to provide a keyFilename with a path to your key file.

  2. susanlinsfu commented on May 18, 2016

    @susanlinsfu
    Author

    I have my nodejs directory which looks something like this:

    MyApp
        -app.js
        -mycredetnials.json
        -package.json
        +node_modules
    

    Inside of my app.js file I have the following code:;

    var options = {
        projectId: 'mydatastoreproject'
    }
    
    var keyFile = './mydatastoreprojectsandbox-5265e25422c.json';
    
    if (keyFile) {
      options.keyFilename = keyFile;
    }
    
    var datastore = gcloud.datastore(options);

    I am running this from my local computer. I want my local computer to be able to connect to the Google Cloud Datastore (not the local emulator).

    In my developer console I have enabled Google Datastore API. I created a KIND in the developer console and created one entity. I have also created credentials (service account key) in the form of a json file. I then included this json file in my code. By doing this I am still unable to connect to the datastore. Am I missing something or doing something wrong? Essentially all I want to do is to have my local machine connect to the Google Datastore.

  3. stephenplusplus commented on May 18, 2016

    @stephenplusplus
    Contributor

    When you start the local datastore and it prints out "Set these environment variables", did you do that? Is that how you've been connecting to your local Datastore so far? By default, gcloud-node tries to talk to the remote API and assumes there is no emulator running. It has to be told to talk to the emulator, which can be done via the env var (DATASTORE_EMULATOR_HOST). If that is what you've been setting, you will have to unset it (or manually do it from the JS script: delete process.env.DATASTORE_EMULATOR_HOST;).

  4. susanlinsfu commented on May 19, 2016

    @susanlinsfu
    Author

    ahhhhh yes I had this variable set. All works now thanks!

  5. stephenplusplus commented on May 19, 2016

    @stephenplusplus
    Contributor

    No problem, glad that it works now!

  6. vinodkumarmarupu commented on Aug 16, 2017

    @vinodkumarmarupu

    how to run on pcf

  7. Dipesh-Das97 commented on Oct 30, 2020

    @Dipesh-Das97

    How will I be able to use the datastore emulator without the key.json for nodejs?

  8. 30 remaining items

  9. added a commit that references this issue on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions