1. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Next Door
    Rep Power

    Do I need to check with my database first before calling some api?


    I got periodic updaters running and on specific times, then I call APIs.

    For example:

    If the time spent on a specific page exceeds 10 minutes, I remove the contact from a sequence.

    PHP Code:
    $client = new Ontraport("","");
    $requestParams = array(
    "objectID"     => 0// Contact object
    "ids"          => $ontraport_user_id,
    "remove_list"  => 68,69
    $response $client->object()->removeFromSequence($requestParams); 
    Do I need to check my database first before calling some api?

    Or it really won't hurt to make extra calls even if not related?

    If I wanna do it, then I have to add fields to my db like "Already_tagged_with_tag_id_x" or things like that.

    With my knowledge, it's either the database or the api who has to take it.
    Last edited by English Breakfast Tea; November 13th, 2017 at 10:36 PM.
  2. #2
  3. Backwards Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Washington, USA
    Rep Power
    You should try to avoid calling an API if you don't need to. Common courtesy.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2017
    Rep Power
    It depends on API itself. If that's your own API (like some other website you need to connect to, etc.), sometimes it may be a better idea to call API directly and perform the task there, then synchronize records (once again, greatly depends on login and your code on both websites). However, such occasions will be very rare (but they may exists under some circumstances).

    Otherwise, API should only be called when it's needed. Not only it will reduce script's run/response time, but also keep the number of hourly/daily/monthly API calls lower (as most of APIs have request limits).

IMN logo majestic logo threadwatch logo seochat tools logo