NATION

PASSWORD

API Recruitment Telegrams

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.
User avatar
Kassimo
Lobbyist
 
Posts: 12
Founded: May 10, 2015
Left-wing Utopia

API Recruitment Telegrams

Postby Kassimo » Wed Jun 03, 2020 9:59 am

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.

User avatar
Merni
Ambassador
 
Posts: 1164
Founded: May 03, 2016
Democratic Socialists

Postby Merni » Wed Jun 03, 2020 11:19 am

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.
Last edited by Merni on Wed Jun 03, 2020 11:21 am, edited 1 time in total.
COVID19 still exists! | Free time? Help Gutenberg!
The Labyrinth | GA Committee List | Tools written by me | NS Parliament 2: Zhang Xiaoqing

Admins: Please allow blocking WA TGs!
Fora
I've noticed that everybody that is for abortion has already been born. — Ronald Reagan

When the people are being beaten with a stick, they are not much happier if it is called 'the People’s Stick.' — Mikhail Bakunin (to Karl Marx)

You're supposed to be employing the arts of diplomacy, not the ruddy great thumping sledgehammers of diplomacy. — Ardchoille

The West won the world not by the superiority of its ideas or values or religion [...] but rather by its superiority in applying organised violence. — Samuel P. Huntington (even he said that!)

Compass E:-7.75 S:-3.64

User avatar
Imperium Anglorum
Powerbroker
 
Posts: 9539
Founded: Aug 26, 2013
Left-Leaning College State

Postby Imperium Anglorum » Wed Jun 03, 2020 3:03 pm

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.

Author: 1 SC and 34 GA resolutions
Maintainer: GA Passed Resolutions
Developer: Communiqué and InfoEurope
Toxic villainous globalist kittehs
Delegate for Europe
Elsie Mortimer Wellesley (EMW); OOC unless otherwise indicated
Ideological Bulwark 285, WALL delegate
Dastardly villain providing free services to the community sans remuneration


Return to Technical

Who is online

Users browsing this forum: No registered users

Advertisement

Remove ads