Wondering what the differences between REST and JSON APIs are, how you interface with them, and how to go about parsing the results. My goal is to build a small application for my android phone to tell me when the next train will get to the subway station by my house, using the developer API provided by the transit agency.
I'm learning C++ in university, but hope to go about this in Java. I'm sorry if this is more of a discussion question rather than a black and white answer question, but I can't find any information elsewhere.
APIs in Question
Very first thing to mention, JSON is not an API but a data format webservices and programs use to communicate to each other.
Webservices can be of many forms but most popular are REST and SOAP. Webservices give you a way to interact with remote machines and communicate with them.
To read more about Json, visit http://www.json.org/ , http://en.wikipedia.org/wiki/Json
And to read more about Webservices, visit, http://en.wikipedia.org/wiki/Webservices
Related
let me ask my question with an example:
Assume that I have some PHP files for my android app that I put it on 000webhost[dot]com; so, my question is how can I use parse (parseplatform[dot]org) in this situation?
I'm new in backend, so I'm sorry if this question is stupid!
For some reason I can't use back4app, aws, etc.
Don't worry about php language, if it's necessary I can write it in another language. (my backend logic is not complex)
If you need a simple web-site with simple backend logic, I'd do that using Express.js. Since Parse Server is essentially an Express.js middleware, you can use the same process to serve both Parse Server and the web-site.
If you prefer to use a different technology, Parse Platform provides many different sdks (https://parseplatform.org/#sdks) that you can use for many different backend technologies (including PHP), or you can connect directly to the REST (https://docs.parseplatform.org/rest/guide/) or GraphQL (https://docs.parseplatform.org/graphql/guide/) apis using any client.
When I asked this question, I didn’t know what exactly should I search until I found this amazing article. This article opened my mind, the most helpful thing that I found there, was this:
Parse is more flexible. Given the freedom to host Parse on the
server of your choice.
You can choose the self-hosting option and deploy your Parse project
on your selected server, such as Digital Ocean.
And then I found this awesome video on youtube.
Now I can run parse on my own server (vps or cloud).
I know the title of this question may not be clear, but I don’t want to change it, because someone like me doesn’t know the right keyword for research.
Hope this help someone else too.
I just finished a tutorial on how to develop an android application that retrieves updated posts from a Blog using JSON data.
The link to the JSON data used to retrieve the posts, was the blog name ending with "/api/get_recent_summary"
How can I find the link of the JSON data for different websites?
For example the website for The Time Magazine
http://time.com
The quickest and easiest way is to use google developer tools in Google Chrome.
1st go to google developer tools. F12 or Ctrl+Shift+I or top right Ellipsis->More Tools->Developer Tools
2nd Click on the "Network" tab.
3rd click on the "XHR" sub-tab. XHR(XMLHttpRequest)
if a site uses json it will be listed under the XHR sub-tab. You can search through the different return objects, select one and use the "preview" sub-sub-tab to view it.
View JSON
View JSON URL
Although the above way is the easiest it is not the most stable way of getting the info you need. Many sites make changes to the return data without any notice. This will probably break your app...
I think what you are looking for is an API(Application programming interface). Most web APIs return json or xml. You should start by searching for the api documentation for the specific site that you want to get json data from. Example documentation for sites that have public api feeds are github api or youtub api. Many of these will require authentication in order to get the desired json response but the documentation should show you how to do it.
Using a legitimate web api is the most stable way to go. Meaning your app has less chance of randomly breaking all of the time due to feed changes, url changes... I hope this helps!
I know this is an older question, but I felt compelled to chime in. If you goal is to simply determine if a site uses JSON for data exchange, then the solution proposed by Tim is a very good solution. However, if you are looking to scrape data from an arbitrary site, there is no guarantee that the site uses JSON as data exchange, as stated by #KenanZahirovic. There are numerous sites that do not do this. Instead they embed the data into the HTML, or use XML, or some other method for getting the content to the client. There is no standard way of doing it, which is why data scraping is so difficult. It requires figuring out how data is transferred and building a client for that.
For scenarios where you need to gather data from multiple sources, you may end up with multiple clients due to the nuances between the sources. This site explains some best practices for data scraping. However, this would likely require a server-side application. Having a server-side application that gathers data and stores it in a database would make the most sense for this scenario. This way you can have a consistent API that the client hits to access the data.
An algorithm has been proposed that can scrape many sites fairly confidently. If you only want to have a client, this may or may not be the best way to go. It all depends on how much processing you want the client to do. If at all possible, try and off load processing to a server.
This answer might be way more than is required, but ,again, I felt compelled to chime in. I am sure the previous answer was sufficient. I do recommend though that you mark an answer as the accepted answer.
Best of luck!
I've come across this problem when thinking about creating different apps for Android. I see these apps that show you the weather cast or sport results, and I wonder which is the source they get all data from.
I assume they don't have their own database which they fill with data manually and live. I suppose they use some kind of web service, data source or something like that. I don't know if web service is the correct term to use in this case (english is not even my native language).
So I would like to know the correct term for what I'm looking for, plus any guidance on finding this kind of services, in order to be able to develop apps using this kind of data sources.
I think this question will help many programming students like me.
It depends what you trying to develope- Some apps use simple GET/POST Requests and get it's data back formatted as JSON or XML (which is the common case).
Some uses SOAP for getting their data.
In some cases they are using plain Sockets or CouchDB.
In some cases they are using Push Mechanism (specially for android) like GCM to send their data to the client.
It always depends what you want to do.
I am currently a student of Android.
My aim is to develop Android Apps that talk with different websites and exchange/process/return data.
But I am really not sure what should be starting point.
Coming from a backend development I can put the layout for backend development as follows
a) Understand Relational DB concepts
b) SQL
c) PLSQL
d) Procedures/Functions
e) Solve realworld problems
....etc
Similarly can someone tell me what should be starting point for learning Android integration.
HTTP or Web Services or REST API or JSON/XML or anything else
All these terms are new to me and when I googled/wikied the terms I can (kinda) grasp what they mean but I am not able to see the big picture as to how they fit etc...wrt integrating an app with a website.
TLDR.what should be the starting point for learning Android Integration ?.
PS : If this is a wrong forum, then do let me know which forum to post this on. Thanks !!!
Your question is so general, and there is no clear answer for it, and you are not ready to build a real app unless you can answer it by your own, so you need to know more about each term of the above, then your question will be "what is the best practice?"
You can start from below:
IBM: Using XML and JSON with Android
XML vs JSON Based Web Services: Which is the Best Choice?
XML vs JSON parsing in Android
JSON or XML in Android
By the way many developers prefere JSON, because JSON is simpler than XML/SOAP and has less overhead, and payload will be smaller than the XML representation, beside Android has JSON parseing APIs.
I am developing application for iPhone and android. In code i need to access the data from database(oracle) .
I am planning to use REST web services to return JSON data to devices. I dont know much about developing web servies(all i did is 'consumption' part).
Now the question came to my mind, i can still manage to return the JSON data from java servlets.
IS there any advantage of using web services. I know for sure I am missing something but want to know what is it.
Now the question came to my mind, i can still manage to return the JSON data from java servlets.
Yes, you can return JSON from java servlets. There are plenty of libraries out there for taking what ever data you've retrieved from you database and serializing it into JSON.
IS there any advantage of using web services. I know for sure I am missing something but want to know what is it.
This is a super general question, but yes. I think the best answer is that (among other things) it gives you an API that arbitrary clients can plug into. So you can expand to new platforms trivial. That's the main benefit as far I see it.