Semantics3 API with AngularJS Authentication - api

I am in the process of learning AngularJS. I am building a mobile first application using bootstrap 3.1.0.
Basically I want to consume the Semantics3 API and display the products in a list. How can I do this when Semantics3's API needs authentication via OAuth. I already have my API key and secret, but I do not know how to successfully make the call to the API from my Angular controller.
At the moment my code looks like so:
savvyShop.controller('ProductsCtrl', function($scope) {
$scope.apiResult = $http.get('https://api.semantics3.com/v1/products?q={"cat_id":13658,"brand":"Toshiba","model":"Satellite"}')
});

Unfortunately, there would be no way you can do this from the client-side (via AJAX). This is because you're trying to make a cross-domain request, which all Javascript engines do not allow. In general, if the API provides a JSONP endpoint, you could use that to make cross-domain requests. However, Semantics3 does not have one.
You could write a server-side script that effectively acts as a proxy between the client and our Semantics3 servers. It would basically pass on whatever queries you send to our URL, receive the results, and send it to the client. That way, you can use $http.get in AngularJS to run those queries.

Related

How to automatically generate a web UI from a REST API

Is there any solution to automatically generate a web UI from a REST API?
I found Swagger codegen but it generates a client for the API, not a UI.
I need a basic UI, allowing directly from the browser to use the different endpoints and display the response prettily. Something like a basic Postman that would be directly integrated into my website.
I don't have constraint about how the generation is done. Can be done once at build time, or at runtime on server side or on client side.
I've heard good things about retool.com, it seems to do what you need.

Publishing an API without any existing backend API for it

I linked some existing back-end APIs to the API Publisher.
Due to some reasons, I need to create an API without any existing back-end API for it in a specific route (for example in .../myAPI/ path). The API should do something and then return a response to user.
how can I do this using WSO2 API manager? Do I need to write a handler for it? Thanks for any help.

Could GraphQL be useful for a system without a frontend client?

So far all the guides i have looked at involve communicating with a frontend client via Graphql, I wonder does it have any usage for something purely backend, such as communicating among microservices?
You can certainly make a request to the API from another server as well. Just as you can make a call to any REST endpoint from anywhere, you can perform server to server communication with GraphQL APIs as well.
For example, at Scaphold, we use Lambda for many webhooks and scheduled tasks. And from our microservice, we use the request library to make POST requests to the Scaphold server's GraphQL API.
Here's an example of a create mutation that you can use from a Node server.
Hope this helps!

Is there any way to secure calls from JavaScript to a web service that will write to database with each call?

I need to create a web service to receive feedback from users from a "Was this webpage helpful to you? [Yes] [No]" JavaScript widget that we will put at the bottom of all of our website's webpages. The goal is to have one web service accept requests from all of the websites and then the web service will insert data from each call into the database.
The problem is that I can't seem to find a way to secure pure JavaScript calls to the web service. I want to use C# ASP.NET for this, so my assumption is to use WCF to create the web service. How can one secure these calls solely from JavaScript to ensure that they are legitimate? Or is there a better architecture to consider?

Which proxy to use in sencha touch 2 when i have restful api

I am trying to make a sencha touch 2 mobile app. I have a restful api in server and i want to consume that in my mobile app. Which sencha proxy should i use (rest, ajax, jsonp)? Rest and ajax has issue with cross-site domain issue, so jsonp can be the solution. But how can i send jsonp request to rest api if i have parameters?
You can use REST proxy if your services truly follows REST standards because that way proxy can provide you out-of-the-box functionality to operate on models.
Regarding cross-domain issues, please note that the way app behaves in desktop browser is different from its behaviour when it runs in phone so you are not forced to use JSONP if you don't want, AJAX can also work for you. Its good if you can use JSONP but please keep in mind its limitations of having no support for HTTP headers and other useful methods like POST, PUT & DELETE.
Please go through this for more information : How to use json proxy to access remote services during development