Consuming a RESTful...
 

  You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more

[Closed] Consuming a RESTful API

7 Posts
6 Users
0 Reactions
111 Views
Posts: 2022
Full Member
Topic starter
 

Hello,

As a non-programmer who can bluff his way in Python and HTML/CSS I need some advice about how to consume REST based API's.

I can use Postman for testing and write Python scripts to interact with API's but I need a simple way of constructing basic tools for customer use. Probably in a web interface but maybe as a Windows app.

After a bit of reading I have come to the conclusion that low code solutions are good but spendy so a single page web app using a Javascript library might be the best way to go. I am struggling to find good guides for this though.

Am I thinking along the right lines and what would be the best tool for this type of work?

An example of what I want to do I send a simple POST request that contains credentials and then initiates an LDAP sync - I would want a web page with text boxes for username and password then a "Sync LDAP" button.

Thanks


 
Posted : 13/08/2018 10:30 am
 nerd
Posts: 433
Free Member
 

Django Rest Framework?

http://www.django-rest-framework.org/


 
Posted : 13/08/2018 11:45 am
Posts: 822
Free Member
 

I think Cletus is after the opposite to the Django Rest Framework.

This example  https://codepen.io/jaywolters/pen/meaOow uses AngularJS to pull data from an API. Does that help get you started?


 
Posted : 13/08/2018 12:52 pm
 poly
Posts: 8699
Free Member
 

Cletus,

You already have the experience consuming in python so do you want to keep doing so rather than move to JS?  I do this fairly routinely for stuff I consume via REST with Python scripts.  I share these for "internal" use with basic command prompt interfaces on them - which helps stop people expecting too much and keep total technophobes away!  It would be fairly trivial to add a WxPython or Tkinter UI on that as a simple desktop app.  If you've used Flask or Django before you could also wrap them in a web app - but there is at least a little learning curve there is you are new to them.


 
Posted : 13/08/2018 1:42 pm
Posts: 2022
Full Member
Topic starter
 

Thanks for the responses all.

sl2000 has is right when he says that I would rather keep away from server based solutions such as Django/Python.

The example provided is interesting and I will spend some time reviewing it thanks.

poly if the tools were only to be used by my colleagues I could get away with simple Python scripts but the brief is that it should run with a gui and without needing anything like python installed on the users PC. Most of the products i am working with at the moment seem to have REST APIs added to them so I figure I need to get up to speed with this.

Any more suggestions welcome!


 
Posted : 13/08/2018 3:08 pm
 5lab
Posts: 7921
Free Member
 

everything you need is (probably) in jquery for a simple request..  https://spring.io/guides/gs/consuming-rest-jquery/

$.ajax({
url: "myURL"
}).then(function(data) {
//some code based on the response
});


 
Posted : 13/08/2018 3:17 pm
 poly
Posts: 8699
Free Member
 

if the tools were only to be used by my colleagues I could get away with simple Python scripts but the brief is that it should run with a gui and without needing anything like python installed on the users PC. Most of the products i am working with at the moment seem to have REST APIs added to them so I figure I need to get up to speed with this.

You can bundle python apps together to run on the end user machine without it being preinstalled (py2exe) - it does make them huge and is not a beautiful solution - but if you already have scripts that work you can focus your efforts better.  You can build UI's too (tkinter is probably lowest learning curve).  However the alternative is you are going to have to host the web "app" somewhere.  People may be more comfortable with providing login credentials to a local client than a "website" although neither is necessarily better.

In any case - if you are going to let the code loose on customers you better spend 5x as much effort providing error trapping / feedback / help / status info - because otherwise you get all the shit to deal with.


 
Posted : 13/08/2018 3:55 pm
Posts: 0
Free Member
 

If you want to be able to run on a desktop and want a GUI, have you considered Electron ( https://electronjs.org/ ).  If you are happy to build a simple javascript app, then there's no reason you can't just host it in Electron.  Dead simple to set up and works a treat for us.


 
Posted : 13/08/2018 9:39 pm

6 DAYS LEFT
We are currently at 95% of our target!