API Connect

 View Only
Expand all | Collapse all

Rate limit on API level

  • 1.  Rate limit on API level

    Posted Mon September 09, 2024 10:36 AM

    Hi team

    I want to apply on rate limit on a API not a product level. When I apply using rate limit policy it doesn't work. it is possible rate limit without client id ?



    ------------------------------
    Shah Wajahat
    ------------------------------


  • 2.  RE: Rate limit on API level

    Posted Thu September 12, 2024 06:19 AM

    Anyone please help me 



    ------------------------------
    Shah Wajahat
    ------------------------------



  • 3.  RE: Rate limit on API level

    Posted Thu September 12, 2024 12:57 PM

    Hi Shah,
    In the API Gateway, the only mechanism I'm aware of the accomplish this is to have a product with multiple plans where your one API would be associated with one plan and the other APIs (if any) would be associated with the default plan.  The ability for a product's specific plan rate limits to indicate that you'd want the rate limits to be applied by API would be an enhancement request.  See https://secure.aha.io/session/new?requested_domain=bigblue  to make that request if using a specific plan in the product isn't sufficient.
    Best Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 4.  RE: Rate limit on API level

    Posted Fri September 13, 2024 02:54 AM

    Hi steve Linn

    I am using rate limit policy and select gateway by name  and rate limit name is test 

    but it give an error when i execute it 

     why it give me an error this.



    ------------------------------
    Shah Wajahat
    ------------------------------



  • 5.  RE: Rate limit on API level

    Posted Fri September 13, 2024 08:52 AM

    Hi Shah,
    I've not seen that error before "API configuration is invalid: rate limit policy".  Do you have access to the DataPower logs to see if there is any additional information there that would provide more detail?
    Best Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 6.  RE: Rate limit on API level

    Posted Fri September 13, 2024 09:30 AM

    Hi steve linn

    following are the error show on datapower logs



    ------------------------------
    Shah Wajahat
    ------------------------------



  • 7.  RE: Rate limit on API level

    Posted Fri September 13, 2024 01:32 PM

    Hi Shah,
    I've recreated your issue.  The rate limit policy with a source of Gateway by Name (my version of the APIM UI has gateway-named) assumes you have an assembly rate limit definition configured on the API Gateway object.

          - ratelimit:
              version: 2.4.0
              title: ratelimit
              source: gateway-named
              rate-limit:
                - name: test
                  operation: consume
    

    Since you don't have one there named "test", as I don't either, you get in the DP logs

    20240913T171424.564Z [0x88c00232][apigw][error] apigw(apiconnect): tid(193314)[request][***.***.***.***] gtid(196c556566e472f00002f322): Rate limit test is in rate limit assembly action swlinnorg_sandbox_test-rate-limit_1.0.0_ratelimit_0 but not in API gateway apiconnect.

    You'll see on the API Gateway Object where you would configure your assembly rate limit named "test"
    To update and persist the rate limit to the Gateway object, you'll need to do that with a Gateway Extension and in particular, in the manifest.json of the extension a type gwd_extension.  The documentation on Gateway Extensions and the manifest can be found at https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=gateway-extensions-manifest and the gwd_extension.json file in https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=manifest-gwd-extension-type.  The example there actually shows an update to the Gateway object's rate limit, adding two assembly rate limits named ratelimit-reject-ALL and ratelimit-alert-ALL.

    I'm not sure why you chose a gateway-named ratelimit unless you wanted this rate limit to apply for all requests coming into the Gateway.  There are other choices of where the rate limit definition must be defined, for example, plan-named is one I've used often that would have the definition in the plan of the product that the API is published, but there are different locations based upon what your specific rate limit requirements are.

    Best Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 8.  RE: Rate limit on API level

    Posted Tue September 17, 2024 03:59 AM

    Hi steve Linn:

    Hope you are fine

    I also try to apply plan-named but it give me error rate limit is not define in product but i define in product you can see in screenshot



    ------------------------------
    Shah Wajahat
    ------------------------------



  • 9.  RE: Rate limit on API level

    Posted Tue September 17, 2024 09:03 AM

    Hi Shah,
    Please post your source to your product here for review.  Your screen shot shows "a" rate limit, but is it "the" ratelimit you're wanting, ie, one named "test".  Just off the screen shot I'd believe you're showing your default rate limit, but you would need an assembly rate limit named "test" in your default plan.  Something like:

    plans:
      default-plan:
        title: Default Plan
        description: Default Plan
        approval: false
        rate-limits:
          default:
            value: 100/1hour
        assembly-rate-limits:
          test:
            - value: 200/1minute
              hard-limit: true
              cache-only: false
              is-client: true
              use-api-name: false
              use-app-id: false
              use-client-id: true
              weight: '1'
        apis:
          testapi1.0.0: {}


    Best Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 10.  RE: Rate limit on API level

    Posted Wed September 18, 2024 06:49 AM
      |   view attached

    hi steve 

    I uploaded my product source code



    ------------------------------
    Shah Wajahat
    ------------------------------

    Attachment(s)

    yaml
    test-rate-limit_1.0.0.yaml   531 B 1 version


  • 11.  RE: Rate limit on API level

    Posted Thu September 19, 2024 11:03 AM

    Hi steve linn

    I don't have any option assembly-rate-limit in product 



    ------------------------------
    Shah Wajahat
    ------------------------------



  • 12.  RE: Rate limit on API level

    Posted Fri September 20, 2024 11:37 AM

    Hi Shah,
    Unfortunately the UI doesn't allow you to add an assembly rate limit at the moment.  You'll need to update it via the source and you can use my example above as a template.  The UI will show that assembly rate limit as a "GraphQL" rate-limit which you'll see in the UI doesn't have an Add button.

    Best Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 13.  RE: Rate limit on API level

    Posted Fri September 20, 2024 12:05 PM

    Hi Steve 

    Thankyou for your response I will updated products according to your example.

    I have one question after that I need to subscribe this product for testing or it work without subscription.



    ------------------------------
    Shah Wajahat
    ------------------------------



  • 14.  RE: Rate limit on API level

    Posted Fri September 20, 2024 01:18 PM

    Hi Shah,
    You will need a subscription.

    Best Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 15.  RE: Rate limit on API level

    Posted Sun September 22, 2024 09:08 AM

    Hi steve linn

    Thankyou for your response i want to know about one thing is their any way to apply rate limit without subscription or client id



    ------------------------------
    Shah Wajahat
    ------------------------------