What's a good language to use for polling WEB API's and parsing JSON results?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What's a good language to use for polling WEB API's and parsing JSON results?
I would like to write a program to poll remote WEB API's and parse the JSON results.
Im familiar with C/Fortran,KSH/Bash,Perl and SQL.
Names I have heard floating around include Python and Java (although this is a complex language). I wold prefer something simple and easy to work with.
Looking for a simple Linux bases scripting language I might interface with postgres. Needs to be able to manipulate Linux shell jobs.
Im good with Bash, but don't know anything about curl. Ill have to look that one up and see what it does.
Is there a name for the "command line JSon" parser? I don't know where to find that. What package is it installed in? Does it work on CentOS? Does it have a yum install 'package' name?
Does it populate postgres or do you have to do that manually in the script?
For command-line Json parsers, I don't have a recommendation. However, "jq" and "Jshon" looked interesting last I checked. My best recommendation is to use a search engine to find information on either one, or on use "command-line JSON parser" as a search term.
Nothing will automatically populate postgress. You script that.
Last edited by dugan; 08-05-2016 at 06:14 PM.
Reason: Edited so that I sound less like a jerk
It seems utterly ridiculous to me to use Bash for any purpose such as this.
When you write "a shell script," you can insert a #!commandprocessorname ("shebang") line at the top of the file, and the shell will invoke whatever command-processor you specify to execute the command. (The end-user will neither know nor care.) Therefore, "the world's your oyster" as to what language you prefer to use.
All of the languages you might pick ... uhh, other than 'bash scripting' ... come with rich, ready-made, fully debugged libraries to handle all of the core tasks that you will face: HTTP, JSON, even complete servers(!).
Thus, your task really becomes choosing a language. and then discovering and leveraging what has already been done(!) to accomplish your intended task. This "build vs. buy" decision is mostly "buy," and the wonderful news is that it won't cost you a dime. Not only "underlying plumbing," but quite possibly "more than 99% of the whole darned thing," might be "sitting on the shelf," waiting for you to find it, take it down and put it to work.
Quote:
Actum Ne Agas:Do Not Do A Thing Already Done.™
"Since you are 'a Good Programmer,'" the first thing that naturally happens when you're faced with a "new" (to you ...!) problem is to "start writing source-code in your head." Unconsciously, you assume that you are going to have to write (from scratch) your solution. These days, this is almost never the case.
Therefore, "Good Programmer" though you might be, your first task should be systems analysis, specification, and then research(!). First, to discover the cornucopia of existingsoftware that might be brought to bear against your problem. Then, to discover (e.g. at GitHub) the many hundreds of existing applications, all of them available to you in source-code form, that already used that software to tackle a problem very similar to yours.
Last edited by sundialsvcs; 08-07-2016 at 09:14 PM.
It seems utterly ridiculous to me to use Bash for any purpose such as this.
When you write "a shell script," you can insert a #!commandprocessorname ("shebang") line at the top of the file, and the shell will invoke whatever command-processor you specify to execute the command. (The end-user will neither know nor care.) Therefore, "the world's your oyster" as to what language you prefer to use.
All of the languages you might pick ... uhh, other than 'bash scripting' ... come with rich, ready-made, fully debugged libraries to handle all of the core tasks that you will face: HTTP, JSON, even complete servers(!).
Thus, your task really becomes choosing a language. and then discovering and leveraging what has already been done(!) to accomplish your intended task. This "build vs. buy" decision is mostly "buy," and the wonderful news is that it won't cost you a dime. Not only "underlying plumbing," but quite possibly "more than 99% of the whole darned thing," might be "sitting on the shelf," waiting for you to find it, take it down and put it to work.
"Since you are 'a Good Programmer,'" the first thing that naturally happens when you're faced with a "new" (to you ...!) problem is to "start writing source-code in your head." Unconsciously, you assume that you are going to have to write (from scratch) your solution. These days, this is almost never the case.
Therefore, "Good Programmer" though you might be, your first task should be systems analysis, specification, and then research(!). First, to discover the cornucopia of existingsoftware that might be brought to bear against your problem. Then, to discover (e.g. at GitHub) the many hundreds of existing applications, all of them available to you in source-code form, that already used that software to tackle a problem very similar to yours.
This thread is part of what you call "Research".
My initial discovery phase indicated that "C" was not a good fit for what I was trying to do, in looking around, I found many possible languages which might be a better fit, and the purpose of this thread is to get feedback from those who have already done this (thus making use of what was already done, and not trying to re-invent the wheel).
Im already doing exactly what you suggest in your thread...
PHP appears more for creating web pages rather than reading them from a remote server.
PHP is a rich language very suitable for scripting and certainly VERY suitable for working with APIs and not just to produce web pages. I've maintained PHP scripts that perform extremely complicate work on large (1M+ records) datasets that has had nothing to do with web pages.
most kodi add-ons are written in python. they are essentially scraping urls and title/author/publication/... data from webpages such as you-toob.com/dis-nee.com/...
This thread is part of what you call "Research".
My initial discovery phase indicated that "C" was not a good fit for what I was trying to do, in looking around, I found many possible languages which might be a better fit, and the purpose of this thread is to get feedback from those who have already done this (thus making use of what was already done, and not trying to re-invent the wheel).
Im already doing exactly what you suggest in your thread...
Reckon that, "across these many (koff koff ...)decades, now," I've probably used "most of 'em," and I don't reckon I ever did arrive at any "favorites."
"Pick a girl, ask her to marry you, and be genuinely(!) amazed when she says, "Yes!" Then, jump headlong into the rapids and hope for the best." Even though you might, from time to time, "not be entirely satisfied with your decision," the project will be achieved, and maybe she will still love you anyway.
Last edited by sundialsvcs; 08-08-2016 at 05:59 PM.
PHP appears more for creating web pages rather than reading them from a remote server.
Actually, PHP is a terrific scripting language as well. I'd definitely consider it for such an application.
I use it as a quick prototyping language for things eventually to be written in C/C++, and also have written several large applications in PHP that are part of my own critical infrastructure.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.