Search code examples
iosserver-side

How can I schedule hourly request to a server and store data on my own server to access from iOS app?


I have very little server side experience. I am wondering what my best option would be for the following situation. There is an API I want to get data from, but there is a limit to how many times I access that data per second, something like less than 10 requests per minute or so, before it gets frozen. What can I use as a server to schedule a request to the API for all the information I need, every hour or so, so that I can then access the data from my server as many times as I want to from my mobile app?

Are there tools out there that I can take advantage of?


Solution

  • Good question, I recently had to learn a bit on the server side for the push notifications i'm trying to implement in a market data (fx) app i'm writing.

    The best solution i've found is:

    Assuming you're on a Mac,

    1. Get MAMP here - it's PHP, MySQL and Apache webserver.

      • best bit about MAMP is it's a self contained app, so it won't mess with your OS X install
    2. You can write PHP code to pull the data from the API, store it on your MySQL database you set up with MAMP.

    3. You can then write a little objective C code, to hit up your Apache webserver on another PHP file that pulls the data you stored earlier.

    That's basically it, now I know what you're thinking, you probably don't know any PHP. Either did I until last weekend and you should see what I'm able to do in it now!

    I only knew objective C, but even so learning PHP was very easy - and i'm not the best coder out there.

    I have a PHP script that (within about 10 lines of code) goes to a website's API pulls JSON values for FX prices and stores them in my DB. I can then hit up my Webserver and pull the values.

    Learning all of this has made me realise that Web applications are incredibly powerful, where before I never considered them when developing iOS apps.