editSharedWidgetData
Edits the public data of a shared widget (Bot API 10.4).
Returns: On success, returns True.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
widget_id | String | Yes | Shared widget ID (widget.id from the sent message) |
public_data | String | Yes | New public state, 0-1024 bytes (empty string = remove) |
cache_time | Integer | Optional | Client-side refresh period in seconds, 5-3600 (30 by default) |
Example request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/editSharedWidgetData" \
-H "Content-Type: application/json" \
-d '{"widget_id":"WIDGET_ID","public_data":"{\"r\":1,\"votes\":[3,5]}"}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/editSharedWidgetData",
json={
"widget_id": "WIDGET_ID",
"public_data": "{\"r\":1,\"votes\":[3,5]}"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/editSharedWidgetData`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"widget_id": "WIDGET_ID",
"public_data": "{\"r\":1,\"votes\":[3,5]}"
}),
});
console.log(await res.json());
Step-by-step guide: Telegram Widget Examples: Complete HTML and Python Bot Code
Related methods
sendWidgetSends a message with an HTML widget (Bot API 10.4).sendSharedWidgetSends again a shared widget created by the bot (Bot API 10.4).answerWidgetQueryAnswers a query from a widget (Bot API 10.4).editMessageWidgetDataEdits the data of a widget in a message (Bot API 10.4).