Page 1 of 1

API Recruitment Telegrams

PostPosted: Wed Jun 03, 2020 9:59 am
by Kassimo
Hello, I have a question. If several people in a region wish to carry out a recruitment campaign via API automated telegrams, should we all use the same API client key (I already have one for the region), or do we each need our own client key? And I presume, either way, we would all use the same TGID to send out the same telegram. If several people are recruiting for the same region, how do we avoid exceeding the API rate limit? (If it makes any difference, we will be using PyNS.)
Thanks in advance.

PostPosted: Wed Jun 03, 2020 11:19 am
by Merni
Kassimo wrote:Hello, I have a question. If several people in a region wish to carry out a recruitment campaign via API automated telegrams, should we all use the same API client key (I already have one for the region), or do we each need our own client key?

A region can only have one client key. Per the Telegram API docs:
the API docs wrote:API Client Keys are tied to a particular region, and each region may only have one (although they can be revoked and re-issued). Multiple people and scripts within a region can use the same API Client Key. If they do, they will be bound by the same rate limit: that is, when anyone uses the API Client Key to send a recruitment telegram, no-one else using the same API Client Key will be able to send more messages until the rate limit expires.

Kassimo wrote:And I presume, either way, we would all use the same TGID to send out the same telegram.

Don't do that. The API docs say:
the API docs wrote:Never share your telegram's Secret Key, as this will allow others to send your telegram to the recipients of their choice. You are responsible for all usage of your keys.

Besides, the telegram will always appear to be sent from the nation that created the TGID and secret key.
Kassimo wrote: If several people are recruiting for the same region, how do we avoid exceeding the API rate limit? (If it makes any difference, we will be using PyNS.)

If I'm not mistaken, exceeding the API rate limit has no penalty except that you will not be able to send telegrams until the rate limit expires. Again from the docs:
the API docs wrote: If you attempt to send telegrams faster than this, your request will fail, and the response will include a 'X-Retry-After' header with information on when you can try again successfully. There is no penalty for trying too soon, although each request does count toward your overall API Rate Limit.

I don't know what effect this has on PyNS, though.

PostPosted: Wed Jun 03, 2020 3:03 pm
by Imperium Anglorum
It makes no difference if you have a single client polling the API every 3 minutes or eight thousand clients polling the API every 3 minutes (or one client polling the API ever 3/8000 minutes). The API will reject all calls exceeding the rate limit and lock you out. The best way to do this is to have a computer which can sit there and is always on and connected to the internet. It will then run your Telegram API calls within the rate limit.