Api Documentation¶
-
class
API
¶ Vyper Methods
-
configure
(token, functions={}, debug=False)¶ Configures the bot with the token and functions to run on updates.
Parameters: - token (str) – The token of the bot retrieved from the BotFather
- functions (dict) – A dictionary that has the message types and functions
- debug (boolean) – An experimental value that doesn’t have a use yet, but will in later versions
Raises: ValueError – if token is blank or not a string
-
request
(endpoint, parameters=None, file=None)¶ Requests the endpoint from the telegram API. Shouldn’t need to be called as the other functions run this more effectively.
Parameters: - endpoint (str) – The endpoint to be requested
- parameters (dict) – The parameters attached to the request
- file (file) – A file that is sent with the request
Returns: Value retrieved from API, usually updates or a success dictionary
Return type: dict
Valid parameter keys for
parameters
:message
edited_message
channel_post
edited_channel_post
inline_query
chosen_inline_result
callback_query
shipping_query
pre_checkout_query
Telegram Commands
-
getMe
(self)¶ Retrieves the user object for the bot.
Returns: The bot Return type: User Object
-
getUpdates
(self)¶ Gets the updates that are pending an update. Will store the current update value in the file
lastupdate.vyper
.Returns: Doesn’t return a value, but instead runs the corresponding function
-
sendMessage
(chat_id, text, parse_mode=None, disable_web_page_preview=False, disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends a message to the chat specified.
Parameters: - chat_id (int) – Chat id of the target chat
- text (str) – Text to send in the message
- parse_mode (str) – Markdown or HTML, depending on which formatting style is preferred
- disable_web_page_preview (boolean) – Whether to show a preview of the webpage on the message
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_to_message_id (int) – The message id to make the message reply to
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
forwardMessage
(chat_id, from_chat_id, message_id, disable_notification=False)¶ Forwards a message from one chat to another.
Parameters: - chat_id (int) – Chat id of the target chat
- from_chat_id (int) – Chat id of the original chat
- message_id (int) – Message id of the message from the original chat
- disable_notification (boolean) – Whether to disable the notification for the message
-
sendPhoto
(chat_id, photo, caption='', disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends a photo to the chat specified.
Parameters: - chat_id (int) – Chat id of the target chat
- photo (file) – Photo to send
- caption (str) – The text displayed with the photo
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_to_message_id (int) – The message id to make the message reply to
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
sendAudio
(chat_id, audio, caption='', duration=None, performer='', title='', disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends an audio track to the chat specified.
Parameters: - chat_id (int) – Chat id of the target chat
- audio (file) – Audio track to send
- caption (str) – The text displayed with the audio
- duration (int) – The duration of the track
- performer (str) – Performer of the track
- title (str) – Title of the track
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_to_message_id (int) – The message id to make the message reply to
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
sendDocument
(chat_id, document, caption='', disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends a document to the chat specified.
Parameters: - chat_id (int) – Chat id of the target chat
- document (file) – Audio track to send
- caption (str) – The text displayed with the audio
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_to_message_id (int) – The message id to make the message reply to
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
sendVideo
(self, chat_id, video, duration=None, width=None, height=None, caption='', disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends a video to the chat specified.
Parameters: - chat_id (int) – Chat id of the target chat
- audio (file) – Audio track to send
- duration (int) – The duration of the video
- width (int) – Width of the video
- height (int) – Height of the video
- caption (str) – The text displayed with the video
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_to_message_id (int) – The message id to make the message reply to
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
sendVoice
(self, chat_id, voice, caption=None, duration=None, disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends a voice message to the chat specified.
Parameters: - chat_id (int) – Chat id of the target chat
- voice (file) – Audio to send (.ogg)
- caption (str) – The text displayed with the audio
- duration (int) – The duration of the message
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_to_message_id (int) – The message id to make the message reply to
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
sendVideoNote
(self, chat_id, video_note, length=None, duration=None, disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends a video note to the chat specified.
Parameters: - chat_id (int) – Chat id of the target chat
- video_note (file) – Video to send
- duration (int) – The duration of the track
- length (int) – Video width and height
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_to_message_id (int) – The message id to make the message reply to
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
sendLocation
(chat_id, latitude, longitude, disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends a location to the chat specified.
Parameters: - chat_id (int) – Chat id of the target chat
- latitude (float) – Latitude of the location
- longitude (float) – Longitude of the location
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_to_message_id (int) – The message id to make the message reply to
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
sendVenue
(chat_id, latitude, longitude, title, address, foursquare_id='', disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends a venue to the chat specified.
Parameters: - chat_id (int) – Chat id of the target chat
- latitude (float) – Latitude of the venue
- longitude (float) – Longitude of the venue
- title (str) – Name of the venue
- address (str) – Address of the venue
- foursquare_id (str) – Foursquare id of the venue
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_to_message_id (int) – The message id to make the message reply to
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
sendContact
(chat_id, phone_number, first_name, last_name='', disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends a contact to the chat specified.
Parameters: - chat_id (int) – Chat id of the target chat
- phone_number (str) – Latitude of the contact
- first_name (str) – Longitude of the contact
- last_name (str) – Name of the contact
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_to_message_id (int) – The message id to make the message reply to
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
sendChatAction
(chat_id, action)¶ Sends the bot’s current status to the chat.
Parameters: - chat_id (int) – Chat id of the target chat
- action (ChatAction) – Type of action to broadcast
-
getUserProfilePhotos
(user_id, offset=None, limit=None)¶ Returns an array of profile photos from the target user
Parameters: - user_id (int) – The user id of the target user
- offset (int) – The first photo to be returned
- limit (int) – The maximum number of photos to be retrieved
-
getFile
(file_id)¶ Gets simple file information to be downloaded from
https://api.telegram.org/file/bot<token>/<file_path>
.Parameters: file_id (str) – File identifier
Administrative Commands
-
kickChatMember
(chat_id, user_id, until_date=0)¶ Kicks a chat member until the date specified or until unbanned.
Parameters: - chat_id (int) – The id of the target chat
- user_id (int) – The id of the target user
- until_date (int) – The date in unix time that the user will be unbanned
-
unbanChatMember
(chat_id, user_id)¶ Unbans a chat member from a chat.
Parameters: - chat_id (int) – The id of the target chat
- user_id (int) – The id of the target user
-
restrictChatMember
(chat_id, user_id, until_date=0, can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True)¶ Restricts a chat member’s permissions in a chat.
Parameters: - chat_id (int) – The id of the target chat
- user_id (int) – The id of the target user
- until_date (int) – The date in unix time that the user will be unbanned
- can_send_messages (boolean) – Whether a user can send messages
- can_send_media_messages (boolean) – Whether a user can send media messages
- can_send_other_messages (boolean) – Whether a user can send other messages
- can_add_web_page_previews (boolean) – Whether a user can create web page previews
-
promoteChatMember
(chat_id, user_id, can_change_info=False, can_post_messages=False, can_edit_messages=False, can_delete_messages=False, can_invite_users=False, can_restrict_members=False, can_pin_messages=False, can_promote_members=False)¶ Promotes a chat member
Parameters: - chat_id (int) – The id of the target chat
- user_id (int) – The id of the target user
- can_change_info (boolean) – Whether a user can change group info
- can_post_messages (boolean) – Whether a user can make channel posts
- can_edit_messages (boolean) – Whether a user can edit other messages in a channel
- can_delete_messages (boolean) – Whether a user can delete other users’ messages
- can_invite_users (boolean) – Whether a user can invite members to the group
- can_restrict_members (boolean) – Whether a user can restrict members in the group
- can_pin_messages (boolean) – Whether a user can pin messages
- can_promote_members (boolean) – Whether a user can promote users
-
leaveChat
(chat_id)¶ Makes the bot leave the target chat
Parameters: chat_id (int) – The id of the target chat
-
getChat
(chat_id)¶ Returns information on the target chat
Parameters: chat_id (int) – The id of the target chat
-
getChatAdministrators
(chat_id)¶ Returns list of administrators in the target chat
Parameters: chat_id (int) – The id of the target chat
-
getChatMembersCount
(chat_id)¶ Returns number of members in the target chat
Parameters: chat_id (int) – The id of the target chat
-
getChatMember
(chat_id, user_id)¶ Returns information on the target chat member
Parameters: - chat_id (int) – The id of the target chat
- user_id (int) – The id of the target user
-
answerCallbackQuery
(callback_query_id, text='', show_alert=False, url='', cache_time=None)¶ Sends an answer to a callback query from an inline keyboard.
Parameters: - callback_query_id (str) – Callback query id
- text (str) – Text for the notification
- show_alert (boolean) – Shows an alert instead of a notification
- url (str) – Url of game or to open bot with parameter
- cache_time (str) – Time to cache the query on the client
-
editMessageText
(text, chat_id=None, message_id=None, inline_message_id=None, parse_mode=None, disable_web_page_preview=False, reply_markup=None)¶ Edits a message from a chat.
Parameters: - text (str) – New text for the message
- chat_id (int) – Chat id of the target chat
- message_id (int) – Message id in the target chat
- inline_message_id (str) – Inline message id in the target chat
- parse_mode (str) – Markdown or HTML, depending on which formatting style is preferred
- disable_notification (boolean) – Whether to disable the notification for the message
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
editMessageCaption
(chat_id=None, message_id=None, inline_message_id=None, caption=None, reply_markup=None)¶ Edits a caption from a chat.
Parameters: - chat_id (int) – Chat id of the target chat
- message_id (int) – Message id in the target chat
- inline_message_id (str) – Inline message id in the target chat
- parse_mode (str) – Markdown or HTML, depending on which formatting style is preferred
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
editMessageReplyMarkup
(chat_id=None, message_id=None, inline_message_id=None, reply_markup=None)¶ Edits the reply markup on a message.
Parameters: - chat_id (int) – Chat id of the target chat
- message_id (int) – Message id in the target chat
- inline_message_id (str) – Inline message id in the target chat
- reply_markup (dict) – The custom markup applied to the message, such as inline keyboards
-
deleteMessage
(chat_id, message_id)¶ Deletes a message from a chat.
Parameters: - chat_id (int) – Chat id of the target chat
- message_id (int) – Message id in the target chat
-
answerInlineQuery
(inline_query_id, results, cache_time=None, is_personal=False, next_offset='', switch_pm_text='', switch_pm_parameter='')¶ Answers an inline query
Parameters: - inline_query_id (str) – The id of the inline query
- results – The results to send to the user
- cache_time (integer) – The time to cache the results on the server
- is_personal (boolean) – Should results be cached server side only for that user
- next_offset (str) – Offset a client should send in the next query to recieve more results
- switch_pm_text (str) – Clients display button with specified text that switches to private chat
- switch_pm_parameter (str) – The parameter for the /start message sent when the button is pressed
-
sendInvoice
(chat_id, title, description, payload, provider_token, start_parameter, currency, prices, photo_url='', photo_size=None, photo_height=None, photo_width=None, need_name=False, need_phone_number=False, need_email=False, need_shipping_address=False, is_flexible=False, disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends an invoice to the user.
Parameters: - chat_id (int) – Private chat id
- title (str) – Product name
- description (str) – Product description
- payload (str) – Invoice payload
- provider_token (str) – Payment token from BotFather
- start_parameter (str) – Deep linking parameter when used as a /start parameter
- currency (str) – Three letter currency code
- prices (list) – Array of prices
- photo_url (str) – Product photo
- photo_size (int) – Photo size
- photo_width (int) – Photo width
- photo_height (int) – Photo height
- need_name (boolean) – Needs full name to complete order
- need_phone_number (boolean) – Needs phone number to complete order
- need_email (boolean) – Needs email to complete order
- need_shipping_address (boolean) – Needs shipping address to complete order
- is_flexible (boolean) – Final price depends on shipping method
- disable_notification (boolean) – Disable the notification
- reply_to_message_id (int) – Message id to reply to
- reply_markup (dict) – The inline keyboard applied to the message
-
answerShippingQuery
(shipping_query_id, ok, shipping_options=None, error_message='')¶ If
is_flexible
andneed_shipping_address
are in the invoice, sends an update.Parameters: - shipping_query_id (str) – The shipping query id
- ok (boolean) – Is the address ok
- shipping_options (list) – Sends the shipping options
- error_message (str) – The error message to send to the user as a reason for the shipping to fail.
-
answerPreCheckoutQuery
(pre_checkout_query_id, ok, error_message='')¶ After shipping and payment details are confirmed, send a confirmation.
Parameters: - pre_checkout_query_id (str) – The precheckout query id
- ok (boolean) – Is the order ok
- error_message (str) – The error message to send to the user as a reason for the order to fail.
-
sendGame
(chat_id, game_short_name, disable_notification=False, reply_to_message_id=None, reply_markup=None)¶ Sends a game to users in a chat.
Parameters: - chat_id (int) – The id of the target chat
- game_short_name (str) – The id of the target chat
- disable_notification (boolean) – Disable the notification
- reply_to_message_id (int) – Message id to reply to
- reply_markup (dict) – The inline keyboard applied to the message
-
exportChatInviteLink
(chat_id)¶ Exports an invite link
Parameters: chat_id (int) – The id of the target chat
-
setChatPhoto
(chat_id, photo)¶ Sets the chat photo
Parameters: - chat_id (int) – The id of the target chat
- photo (file) – The photo to set as the chat photo
-
deleteChatPhoto
(chat_id)¶ Deletes a chat photo
Parameters: chat_id (int) – The id of the target chat
-
setChatTitle
(chat_id, title)¶ Sets the chat title
Parameters: - chat_id (int) – The id of the target chat
- title (str) – The text to set as the chat title
-
setChatDescription
(chat_id, description)¶ Sets the chat description
Parameters: - chat_id (int) – The id of the target chat
- description (str) – The text to set as the chat description
-
pinChatMessage
(chat_id, message_id, disable_notification=False)¶ Sets the chat description
Parameters: - chat_id (int) – The id of the target chat
- message_id (int) – The id of the target message
- disable_notification (boolean) – Disable the notification
-
unpinChatMessage
(chat_id)¶ Unpins the message in the target chat
Parameters: chat_id (int) – The id of the target chat
-
getStickerSet
(name)¶ Returns the sticker set with the name specified
Parameters: name (str) – The name of the sticker set
-
sendSticker
(chat_id, sticker, disable_notification=False, reply_to_message_id=None, reply_markup=None)¶
-
uploadStickerFile
(self)¶ Uploads a new sticker
Parameters: - user_id (int) – The user id of the sticker owner
- png_sticker (file) – The png file with at least one side of 512px
-
createNewStickerSet
(user_id, name, title, png_sticker, emojis, contains_masks=False, mask_position=None)¶ Uploads a new sticker
Parameters: - user_id (int) – The user id of the sticker owner
- name (str) – The short name of the sticker set
- title (str) – The title of the sticker set
- png_sticker (file) – The png file with at least one side of 512px
- emojis (str) – Emoji to correspond to a sticker
- contains_masks (boolean) – Set of mask stickers should be created
- mask_position (dict) – Position of the mask
-
addStickerToSet
(user_id, name, png_sticker, emojis, mask_position=None)¶ Adds sticker to set
Parameters: - user_id (int) – The user id of the sticker owner
- name (str) – The short name of the sticker set
- png_sticker (file) – The png file with at least one side of 512px
- emojis (str) – Emoji to correspond to a sticker
- mask_position (dict) – Position of the mask
-
setStickerPositionInSet
(sticker, position)¶ Moves sticker to position in the set
Parameters: - sticker (str) – File id of sticker
- position (int) – New sticker position, zero-based
-
deleteStickerFromSet
(sticker)¶ Deletes sticker from set.
Parameters: sticker (str) – File id of sticker
-