Skip to main content

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. Как их получить:

  1. Откройте итд.com в браузере
  2. Откройте DevTools (F12)
  3. Перейдите на вкладку Network
  4. Обновите страницу
  5. Найдите запрос к /auth/refresh
  6. Скопируйте значение refresh_token из Cookie из Request Headers

cookie

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"

Прочее

Star History Chart

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itd_sdk-2.2.0.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

itd_sdk-2.2.0-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file itd_sdk-2.2.0.tar.gz.

File metadata

  • Download URL: itd_sdk-2.2.0.tar.gz
  • Upload date:
  • Size: 36.1 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

Hashes for itd_sdk-2.2.0.tar.gz
Algorithm Hash digest
SHA256 a269cf3ddd750b39b4a1a413f533f5adc16023e77899cbd1cd9f1ae301f49fe5
MD5 1d711eb8d58873e462381d60a9df752f
BLAKE2b-256 fb44b999e3b40ca9c915277ebbe1ae4d9b76c89f3e12ff50cd1b4f6414edea54

See more details on using hashes here.

File details

Details for the file itd_sdk-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: itd_sdk-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 50.2 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

Hashes for itd_sdk-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfeae78d2f6e802b83d8aec69f02e3e8b6560cbb8c7746963f103d479cd500b3
MD5 32d6d8578b9b8e84f063baeac43827bb
BLAKE2b-256 c42ecdbd604a71ce4e2e2c78cb7ae44616f8700f15a5fd5605cdfd76f7e3768e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page