App idea for App Store, talking with restful API's
Sorry, if I am not correctly using the jargon in the below, please look past that. Hopefully the intent is still clear enough.
Is anyone aware of a mobile app that can query a URL/Rest APIs (with an interface) that returns a json object and has tools that allow you to display the returned json in some meaningful way?
It seems to me this could be a very interesting app and give say Pythonista users a way to deliver some functionality to customers/friends without having to deploy a app themselves to the App Store.
One very simple thing I would like to do is just calculate a date for my team members in a game I play. we are often given a count down time to a particular event. in days, hours, mins, secs. I guess this style helps to avoid problems with time zones etc. Anyway, it's a simple calculation and the Arrow datetime lib makes it even more simple. I have a PythonAnywhere account, so I could say using flask make a URL that takes the d,h,m and required tz items as params and return the date and time of the event.
I realise you could type this into your browser and return the json or plain/html text. It's pretty clunky to do that though. Of course you could write the web forms etc to collect the data and then display it. Firstly, I am really not interested in doing that and secondly would struggle to do something nice.
Hence the idea of a app that could save URL queries with a neat/clean way to enter the params for the calls. then some simple tools that using the return data you could create a viewing profile for the information. maybe a list of a certain key or a form etc. even better if those profiles could be described as a json object, that your own project could supply a recommended layout for.
Look, maybe I am missing something real simple here Or something already exists to do this. I have quite a number of these small queries/helpers I would like to be able to do to help my gaming team. I just don't have a nice way to share it with them, well without becoming a web developer or asking them all to get Pythonista or a Python interpreter. Not a great solution.
So my 2 points to this post.
- if you know of a mobile app or even a desktop app that does something like I am talking about here, would love to hear about it.
- if nothing does exist like this for iOS, and you are looking for some meaningful app to write in Pythonista or whatever language to put on the App Store, this might be something you could get your teeth into. I cant imagine an app like this would break Apple's guildlines, though I am just guessing about that.
If I was younger, more skilled and energetic this would excite me as a project to write.
This is possibly just a stupid idea. But I had to get it out of my system. at the moment it still seems smart to me :)
@Phuket2 Your ideas are good and are probably easier to implement than you might think. You can think of this as a client/server solution (I know you remember those). Write your server in Python and Flask to be run on PythonAnywhere. It should serve up one URL (https://happyhourstarttimes.pythonanywhere.com) that returns a json list of events (alpha_pub, beta_bar, ...). Then there is a URL for each event (https://happyhourstarttimes.pythonanywhere.com/alpha_pub, https://happyhourstarttimes.pythonanywhere.com/beta_bar, etc.) that returns a json record for that particular event with days of the weeks, start times, end times. These json records can be as complicated as you want. On the server side, you could store all event dates and times in UTC time and then have each client app do appropriate timezone math to its local time. You can test your server just using a normal web browser before starting to write your client app in Pythonista.
Apple will allow apps that gather and display information from REST APIs running on remote servers (as long as you can not download executable code). They will not allow socket communications between two different apps running on the same iOS box (but you can use X-callback-URL or share sheet interaction to get around that).
If you want to open a repo with a reasonable license then I would be willing to co-hack with you.
For inspiration: https://github.com/ChamGeeks/HackathonPythonista2015
@ccc , I was hoping someone else would take up the challenge. I would love to contribute, but I am not of the caliber to be the lead on the project. I could muddle something together. But it would be embarrassing. Then to be able to take it through the Pythonista objective c template and to get something that could be published on the App Store is beyond me. I still just tinker at best. So hopefully you or someone sees it as a worthwhile challenge to take it up.
I have been doing a little bit better as I have been going through some of the Python courses from Talk Python To Me. But again I am still rusty as I hardly did anything for 6 months with python. Was a bad time to stop actually. I didn't really get over the learning hump so to speak. Also going through these courses, I see how bad I was about expressing code in a Pythonic way.
Anyway, I really do hope someone takes it on. Seems to me it could be very useful
OK... we need two things to get started...
- Three sample events (include who, what, where, when, URL for more info)
- A name or at least code name for the repo.
I did the below, just playing around with tuples after watching Talk to me, courses. I also added a pic of the generated model from the App JSON Designer.
Ccc, not what sure what you think about that data/API. Presumably we will be able work with any json data.
Nested or not.
As for the Repo Name. Anything you choose is ok with me. I am sure you are more likely to choose an appropriate and legal Repo name than I am.
***Edit: brings up another point that I had considered before. Caching of data on the client. I though that we could just use the json.dumps()/load methods to cache the data calls. The interface could allow for the clearing of the cache as well as a flag to indicate data should not be cached and a new call made each time. Just need to be able to work in the params into the filename if possible which would allow for easy checking if we have previously cached the data or not. I just talk about this detail now as if we were to use this service for testing we should limit the number of hits we make against it while testing
Anyway, let me know that you think
from collections import namedtuple import requests import clipboard import json flds = ['season', 'round', 'time', 'raceName', 'date' , 'url', 'Circuit'] race = namedtuple('race', flds) url = 'http://ergast.com/api/f1/current.json' r = requests.get(url) clipboard.set(r.text) data = r.json()['MRData']['RaceTable']['Races'] races = [race(**r) for r in data] print(races)
Continuing this thread at https://github.com/cclauss/f1_hack
@Phuket2, is your idea to create what would essentially be a configurable REST API "nicefyer" front-end? One mobile app that is actually many, through the various functionality provided by APIs, without the need to deploy changes to the mobile app itself.
Count me very interested & active on this topic.
Just browsed through 20 REST API apps in the App Store - most seemed old, and all too technical and focused on API testing.
Now Apple-owned and price-free Workflow has actions that allow you to ask for parameters, build a URL, retrieve URL contents, create a dictionary from input, then pick and display various values from the dictionary, and potentially continue with other workflow actions. So, essentially you can build and distribute an "app" as a Workflow. Have to think what would be the potential added value on top of that option.
I am also thinking whether this should somehow work around Swagger files to have a standard basis for the API.
Ah... Now (I think that) I start to understand. You want a system for doing API discovery... You give it a URL and it discovers the format of the data behind the API at that URL?
I found this a few days ago. Exactly what you’re looking for.
@bslayton, thanks, looks cool, although I think that’s something different than what I had in mind. Where Jasonette is using json to describe a UI (an alternative to HTML, essentially), I was thinking more about something that would just look at the data, then provide a UI for the user to manipulate the data.
I guess the big difference is whether the ”server-side” needs to know about and provide the specs for the ”client-side”, or just focus on providing and receiving the content.
@mikael Granted, I’m not an expert in Jasonette as I’ve only been lurking on the project, but looks like it supports user actions. IE: submitting form data when a user taps button, swipes, errors, etc. I don’t think I understand the the difference between jasonette and what your idea is (Its too early, still trying to wake up).
After re-reading, it sounds like you’re saying you want an app that consumes JSON (perhaps from REST API) and shows you the data in a way where you can build your own interface around it. Similar to pythonista’s UI builder but it would allow you to associate UI elements with keys/values from your JSON response.
Regardless, that would be a cool app!