#1
  1. A Change of Season
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,247
    Rep Power
    220

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


    Hi;

    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:
    if($_SESSION['how_long_vsl_watched']>10)
                                    {
                                        
    $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. Maddening Moderator
    Devshed Supreme Being (6500+ posts)

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

    Join Date
    Oct 2017
    Location
    Lithuania
    Posts
    25
    Rep Power
    0
    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