ITD client for python
Project description
itd-sdk
Клиент ITD для python
Документация (beta): https://firedotguy.github.io/itd-sdk
Установка
pip install itd-sdk
Пример
from itd import ITDClient, Me
c = ITDClient('token')
print(Me())
Получение cookies
Для получения access_token требуются cookies с refresh_token. Как их получить:
- Откройте итд.com в браузере
- Откройте DevTools (F12)
- Перейдите на вкладку Network
- Обновите страницу
- Найдите запрос к
/auth/refresh - Скопируйте значение refresh_token из Cookie из Request Headers
API
from itd import Me, User, Post, Posts, File, Hashtag, Notifications
me = Me() # получить себя
me.privacy.update(is_private=True)
user = User('itd_sdk') # получить пользователя
user.follow()
post = Post('725681ba-2aaa-42d8-87fb-490c0f44e162') # получить пост
post.like()
post.add_comment('тест комент 6 7')
posts = Posts() # получить посты из ленты
for i, post in enumerate(Posts()):
post.like() # встроенные защиты, из-за которых рейт-лимит будет получить сложнее + авто ожидание окончания рейт лимита
if i > 10:
break
post = user.posts[5] # индексация, авто-получение до нужного значения
post.repost()
file = File.from_path('1.jpg') # загрузка файлов
Post.new('всем привет!', attachments=file) # attachments может быть списком, файлом, или UUID
hashtag = Hashtag('тестапи') # получить данные хэштэга
print(hashtag.posts_count)
hashtag.posts[0].like()
notifications = Notifications() # получить уведы
notifications[30].read()
notifications.read_all()
for notification in notifications.stream(): # SSE уведомлений
print(notification.type.value)
break
def on_like(notification):
print('лайк от', notification.actor.username)
notifications.stop_stream()
notifications.on_like = on_like
stream = notifications.stream_bg() # background SSE
Post('02bcbba4-f365-4b98-9291-d0bc1fb36fe4').poll.vote('тест') # голосования в опросах
Кастомные запросы
from itd.request import fetch
fetch(c, 'метод', 'эндпоинт', {'данные': 'данные'})
Из методов поддерживается get, post, put итд, которые есть в requests
К названию эндпоинта добавляется домен итд и api, то есть в этом примере отправится https://xn--d1ah4a.com/api/эндпоинт.
[!NOTE]
xn--d1ah4a.com- punycode от "итд.com"
Прочее
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file itd_sdk-2.0.0.post1.tar.gz.
File metadata
- Download URL: itd_sdk-2.0.0.post1.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
892d4ac95b50eaf776a987f7057d1b040fa8e1ecdfd517e420162a624b63eb2f
|
|
| MD5 |
52cdcee333479d36c034cb7d85dbab28
|
|
| BLAKE2b-256 |
cc2a9a80fadc3d1c9ed98eb43b2eee3106e90546027f91cd8efa22b15d211d04
|
File details
Details for the file itd_sdk-2.0.0.post1-py3-none-any.whl.
File metadata
- Download URL: itd_sdk-2.0.0.post1-py3-none-any.whl
- Upload date:
- Size: 47.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01f0df9728aef53689ed2b60175bed8151789e0bf915486f66dc506825235afd
|
|
| MD5 |
2334123c9e59a4de3b5ee39b3c57da8d
|
|
| BLAKE2b-256 |
bc62ff7ec8866aa97fd0d8ef4fedb8e84d0c1a3435fa041c70b03020ed59259e
|