How to call freebase api using nodejs ExpressJS or Superagent - node.js

I have this Freebase query and need to use it in NodeJS + ExpressJS or NodeJS + Superagent. I tried Google API module and the Freebase module (that doesn't npm install!), but i'm very confuse about how to use. I dig into google and documentation without success. I already have my Google Freebase API Key and read in some web posts that always need to use it and in others that it's not necessary. I'm very confuse about it.
Thanks!

For future generations who google here like I did, the npm module is now working and appears to be awesome.
https://www.npmjs.org/package/freebase

Related

Caching the response to an external web service in hapi.js

Im building a web app in hapi.js. Im pretty new to hapi.js so may not be following the framework correctly. But here is what I intend to do.
Create a hapi route which will use one of the route params to make a series of web service calls to an external host. These calls need to be done in series.
I am currently using axios to make the calls and chaining them with
.then().then() etc.
I would like to cache these responses to a redis store. I read up on the hapi caching examples of using catbox and hapi "server.methods" feature but not sure how they could be applied to a promise based call chain that I have currently. Is there something wrong with my thinking.
Catbox the caching module used by hapi does not support promises as stated here, maybe open an issue on Github or ask a question on gitter or on Github user forum to see what other users are doing.

How should I use google api node js client ?

I'm trying to call GA api in a react/webpack/babel project using google-api-nodejs-client. However it doesn't work. I've got multiple error in my console. On the google-api-nodejs-client GitHub's issues I found the following answers about a similar issue :
google-api-nodejs-client is not meant to be used in a browser—it won't
work. googleapis (google-api-nodejs-client) will work in Node.js.
Excluding googleapis from any server-side bundle (just let Node's
module system load it for you) is the best option.
To access Google APIs from a browser, please use the Google API Client
Library for JavaScript (gapi).
I don't really understand it. Can someone explain this differently ?
thanks.

Maintaining request scope in Express/Node.js

I am using Express to expose a REST API in my Node.js application. When a REST request comes in, I extract the user information from the HTTP headers. I would like this information to be available throughout the life of this request, no matter what function I am in. An obvious but kludgy way is to pass around the user information as parameters to all function calls. Is there a better way? So far I have found the following solutions, but I am not sure if they are ready for prime time:
StrongLoop Zone Library: Docs say "The zone library and documentation are still under development: there are bugs, missing features, and limited documentation."
Continuation-Local Storage: Not sure if this is slated to be part of Node.js. This issue at the end recommends looking at StrongLoop zone.
Node.js Domains: Does not look like this actually took off.
I'm not sure if you're still looking, but a while back I built express-http-context for this very purpose. It's an express middleware that sits on top of cls-hooks (formerly continuation-local-storage).
Full disclosure: this is an npm package that I built and maintain.

Nodejs - Is there any module existing similar to request module in nodejs?

I want to make rest api calls from node server. I have currently request module in my mind.
Would you suggest any other best module for REST calls(get/post) for production practise in nodejs ??
Regards,
Ram
Restify was designed specifically for serving RESTful APIs (instead of serving web pages). And it can call RESTful APIs as well.
Here is a nodeJS module called "Deployd" that will help you in creating REST APIs (get/post) in seconds, its community is very limited though. Its quite powerfull as well.
Simply install deployd, it expects nodeJS and mongoDB to be installed already. Deployd provides PHPMyAdmin like web interface through which you can create your APIs and for fine tuning work on deployd's Event API which gives you control on behavior of individual events like GET/POST/DELETE/PUT/VALIDATE etc
I'm using Sails.js to create Rest API. Very easy to use!
Sails.js automatically generates a RESTful JSON API for your app. That means you don't have to write any backend code to build simple database apps.
Install:
sudo npm -g install sails
Create app:
sails new testProject
Lift server:
cd testProject
sails lift
And you are ready!
Update
Regarding your comment, you don't want to create a REST API, but rather consume an existing one.
I found this node module called Node-rest-client. I haven't tried it myself, but looks like this could be what you are looking for.
Allows connecting to any API REST and get results as js Object.

Node.js or Express.js REST API document generator

I'm working on a restAPI using Express.js and I'm wondering if there is a way for me to generate API documents that allow a user to view API definitions or possibly even try out the API call?
What you are looking for is a good JavaScript documentation generator. I found a decent one here http://apidocjs.com/example/.
This will allow you to use just Express as OP asked.
Swagger isn't for generating docs, it's for making APIs. So you are going to need to learn a full system to get that feature.
I found a couple more here that I haven't fully looked into yet which seem promising:
Docco here JSDoc here and an article on Documentor for Node
Swagger is an amazing project for auto generating API documentation. It includes an Express module.
http://swagger.io/
https://github.com/wordnik/swagger-node-express
I found this library to be very useful when it comes to keeping your documentation and route declaration logic close together:
https://www.npmjs.com/package/swagger-jsdoc
If you use Postman while developing you might already have a Postman collection containing the most relevant calls.
If that is the case Postman has a docs feature https://learning.postman.com/docs/publishing-your-api/documenting-your-api/

Resources