Set API MaxTimeout in Loopback.io and detect slow apis - node.js

We are using loopback.io for writing and exposing our apis.
I need to do two things on my apis -
Need to set max timeout say 30 sec. max, for all apis. ( I tried some ways from Internet, none of them worked. )
If I am able to set the timeout for apis, I Need to get Slow apis list like alert, email or slack notification whatever possible.
All APIs which are not able to give response withing 29 seconds, I will send the api name as an slack notification that the API is taking time.
Any workaround on this?
Thanks,

Related

API call to link a number to a 10 DLC campaign

I buy numbers and set up callbacks on them through the Vonage API without any problems. Now, however, I am required to link every new number with a 10 DLC campaign. Do I have to resort to the console to do this, or is there an API call that will do the job? I've searched the API documentation without success.

How to send a notification at a random time?

I would like to find out how, using Node.js, Express, Typeorm I can send notifications at random times to users to add a post etc.
I would like to create something of the BeReal sort. Notifications should be sent according to the user's selected time zone at random times.
If you want to send automated notifications, I'd recommend using
node-cron. However, for your case, I'd propose to add a timeZone
indicative information in the database to link the user with the
timeZone(you can find it in HTTP Requests, update it after each
login).
For the actual sending of the notifications, I think you should use
some third party service like Google Firebase for mobile
notifications, and web-push for web applications.

How to send different message to multiple users by hitting single api of FCM?

I have a use case where I want to send a notification using FCM to multiple users(say 1000) every minute.
Below are some conditions that I also need to take care of
Every minute users will be different based on some conditions. So i can't create a group or topic using fcm.
Every user will receive a different message.
I don't want to hit fcm's request 1000 times every single minute.
Please help here
You can send a batch of (up to 500) messages, where each message has its own payload and audience (such a topic of tokens). So for 1000 unique tokens, you'd in that case only hit the API endpoint twice.
The Admin SDK (which is available for Node.js) implement a simple method call for this, but I also recommend having a look at the REST API example on the page I linked, as I found it interesting to see how this is implemented behind the scenes.

How to get instant changes in background from private api in mobile app?

I am planning to create a mobile application for android and ios users, i think i will take a try with xamarin since i will be alone on this project and i don't have a lots of time.
I want that the mobile app for both platform get datas from the api, then if there is new datas available we notify the user by a notification.
How the mobile will work in that kind of project? I mean should i make a background service then check every x seconds/minutes by http request? In that case which time interval? Should i use websockets instead for this case?
The app might be used by many people, so i would to know the scenario in this kind of project: Getting very fast changes, without overload the server due to too many connects or whatever else.
I'm confused about this and i need some lights around, any mobile application/server experiences related would be apprecied!
EDIT:
As suggered by an user, here additional infos:
The api is homemade, restful using JWT made in NodeJS.
Each users on their device should get messages from server asap, even when the app is in background/closed.
Maybe in the future a way to send messages between users themselves.
You have to implement push notification.
It is quite easy to implement this in xamarin. just send the push notification to the device and on the notification received call back send the API request to retrieve the updated data.
Here is the document for sending push notification from custom API.
https://learn.microsoft.com/en-us/appcenter/push/pushapi
I'm not a mobile developer, so take this with a grain of salt.
The answer to this really depends on what you're doing, which informs how often to check the API. If it's a messaging app, for example, you could have it check every couple minutes to see if there are undelivered messages, then check more frequently for the next X minutes (to facilitate a conversation in real time).
If it's a GPS navigation app to be used while driving, you'd need much more frequent requests.
As for the API, that also depends on what type of API and the number of requests you can make to it. Is it a commercial API that you get x number of calls per hour on? Is it an API that you built? Etc.
Basically, you need to give more information in order to get more specific answers.

Instagram API posting likes rate limit

I created an iOS app that using Instagram API and have a critical issue posting likes to Instagram.
Using endpoint – POST /media/media-id/likes, with user-specific access token. I request scope – likes from users.
Instagram API works fine for all requests except saving likes. We can only save/post a couple hundred likes to Instagram, and then response is "We've taken extra measures to protect the Instagram API from abnormal activity. Since you have recently created your API application, please contact apidevelopers#instagram.com to receive whitelisting for a higher rate limit."
There is other developers with same issue with no support or any feedback waiting for months.
Please, let me know if there is limits and how it works, or how to become whitelisted
I don’t want to create many Instagram API clients and assign users among them. It seems like bad acting for me, if there is official API with strict limits I want to work with it.
Instagram has new API limits: 100 likes/hr 60 follows/unfollows/hr per access token. That is only if you authenticate serverside and sign your headers. Check out the new authentication: http://instagram.com/developer/authentication/
I'm using it for my new site that automates likes/follows/unfollows, haven't had any problems works great. Check it out: http://instapromobiz.com
Instagram takes increased measures to limit your API requests based on IP address. This is not common knowledge, it's just something I've come to know from working with the API extensively.
They've built an API that is FAR from perfect, but have been upgrading it to be "smart". Smart enough to know that a newer client, pinging the API many times just for one user, may very well be a script kiddie trying to bot the system. For this reason, they do not give you a rate limit error, they politely say "we have taken extra measures to protect our API from being spammed by bots".
The good news is, other users should still be able to access your liking mechanism. Just not you, from that IP.

Resources