Forum Discussion

geekcubed's avatar
geekcubed
Contributor
12 years ago

Rest API Rate Limit

Hi

 

I'm developing a little desktop application to help out a client who needs to semi-automate some of their day-to-day admin tasks.  One of the tasks is to set  profile background images for a list of users. Specifically, I am making the following API calls: 

 

  • /profiles/name/portrait_badge_background_image_url/set
  • /profiles/name/portrait_badge_theme/set
  • /profiles/name/portrait_display_portrait_badge/set

These are made whilst looping over the list of users. What I am seeing is, very quickly, Timeout errors when trying to make the requests.  Sometimes it's doing a few sets, other times it's failing at the first call for the first user.

 

Is there some sort of rate limiting / throttling in place when it comes to the Lithium Rest API?  Is this something my client will have control over for their instance of Lithium community or is it a blanket thing?  Any clues anyone might have would be gratefully received.

 

Ian

 

  • YuriK's avatar
    YuriK
    Khoros Expert

    Hey Geekcubed,

     

    How are you making these requests? Are you making them from a separately hosted site? Depending on the distance between where you are making a call from, you may be seeing network lag. Also we do some throttling if there are many requests at the same time.

     

    I would suggest creating an Endpoint in Studio that makes all the restapi calls and then just have something call the endpoint once a day or however often you need the job to run.

     

    If you don't have Endpoints enabled for your community, you will need to open a support ticket to have them.

     

    Hope this helps,

     

    Yuri

    • geekcubed's avatar
      geekcubed
      Contributor

      Hi Yuri

       

      Firstly, I will have to appologise in advance if it seems like I am talking rubbish!  This is my first time integrating with a Lithium product, so I'm not really clued in on all the terminology & product offerings.  I'm an external developer for the Lithium customer, so, at the moment, I only have limited access and I'm not fully briefed on their setup and what they are using.

       

      At the moment [we] are just exploring what is possible in terms of reducing their workload.  They currently apply a custom background to a various users who have made an achievement - around 150 uses on a weekly basis. This is quite a time consuming process to do via the normal website interface.

       

      The requests are being made from a bespoke Windows (.Net) application. Currently it is looping through a list of usernames and:

       

      1. call restapi/vc/user/login/<username>  to validate the username is part of the community & parse to get the user-id
      2. call restapi/vc/users/id/<user-id>/profiles/name/portrait_badge_background_image_url/set to set the new background image
      3. call restapi/vc/users/id/<user-id>/profiles/name/portrait_badge_theme/set to set a default theme is being used (so the background displays)
      4. call restapi/vc/users/id/<user-id>/profiles/name/portrait_badge_theme/set so the background is displayed

       

      The app performs Step 1. on the inputted list of usernames and builds up a list of valid user-id's.  It then loops through that list performing 2-4.  I've not timed anything, but step 1. is relatively slow - perhaps 2 or 3 req/sec.  Looping over 2-4 runs at "full speed" - the response isn't parsed, so you could figure 10 - 20+ req/sec easily.

       

      We've made the following observations:

      • Looping over a list of ~20 usernames and calling restapi/vc/user/login/<username> is not problem.
      • Taking that list of 20 and performing steps 2-4 results in Timeout errors at some stage.  These timeouts then persist if you exit the application and restart - the timeouts then occur at the first step (user lookup).

       

      So are we falling foul of the throttling?  Can you give an indication of what the throttling limits are (req/sec) ?

      • YuriK's avatar
        YuriK
        Khoros Expert

        Hey geekcubed,

         

        I don't believe you are running into a throttling issue. You can verify that it's not a throttling issue by adding an artificial delay between calls (maybe about a second between each call), if you still see a timeout, then it's not a throttling issue.

         

        Can you tell me a bit more about how you make the calls, specifically:

         

        1) What are the timeout parameters on your side? (after how long will a call timeout)

        2) Where is your application hosted?

         

         

        Using Endpoints is probably a better solution than making multiple API calls:

         

        In the Lithium community application we allow our customers to create endpoints. You can read more about them here. If you work with someone who has access to Studio in the Lithium application, they will be able to set up an endpoint to make all the calls (thus reducing number of calls made from the external application). From the external application, you will then only need to call the endpoint rather than all the rest APIs.

         

        Thank you,

         

        Yuri