Socialift
Instagram, Facebook va LinkedIn uchun asinxron Python SDK — OAuth, kontent, Direct chat, Lead Ads va webhook'lar. Bitta kutubxona, uchta platforma, bitta xato modeli.
pip install socialift
import asyncio
from socialift import Facebook
async def main():
async with Facebook(app_id="...", app_secret="...", config_id="...") as fb:
token = await fb.exchange_code(code, redirect_uri="https://siz.uz/cb")
for page in await fb.pages(token.access_token):
print(page.name, "→ instagram:", page.instagram_username)
asyncio.run(main())
Nega Socialift
Meta va LinkedIn API'lari bilan ishlash — hujjatlarda yozilmagan o'nlab tafsilotni bilishni talab qiladi. Socialift ularni sizdan yashiradi:
| Muammo | Socialift'da |
|---|---|
Business tipidagi app scope emas, config_id ishlatadi |
login_url(config_id=...) — avtomatik |
| Instagram'ning ikki oqimi turli host va token talab qiladi | Instagram(...) va Instagram.via_facebook(...) |
| Page webhook obunasi app sozlamasidan alohida | subscribe_page() |
| Lead webhook'da lead mazmuni kelmaydi | fb.lead(leadgen_id, token) |
| Forma savollari o'zbekcha/ruscha nomlanadi | normalize() — kanonik kalitlar |
| Rate limit, 5xx, tarmoq uzilishi | avtomatik backoff + jitter |
| Har provayder xatoni o'zicha qaytaradi | bitta ApiError ierarxiyasi |
LinkedIn /rest/* versiya sarlavhasini talab qiladi |
avtomatik |
Chat'da suhbatdosh haqida faqat id keladi |
to'liq profil, parallel + keshli |
Imkoniyatlar
| OAuth (login, token, yangilash, bekor qilish) | ✅ | ✅ | ✅ |
| Profil | ✅ | ✅ | ✅ |
| Page'lar va page token'lari | ✅ | — | — |
| Postlar (o'qish / e'lon / o'chirish) | ✅ | ✅ | ✅ |
| Izohlar (javob, yashirish, o'chirish) | ✅ | ✅ | — |
| Statistika va demografika | ✅ | ✅ | — |
| Direct chat + to'liq suhbatdosh profili | — | ✅ | — |
| Lead Ads (formalar, lead'lar, targeting) | ✅ | ✅ | — |
| Webhook (imzo, hodisalar, dedupe) | ✅ | ✅ | — |
Litsenziya va narxlar
Socialift — tijorat mahsuloti. Ishlatish uchun amaldagi obuna kaliti kerak:
export SOCIALIFT_LICENSE_KEY="slk_..."
# yoki kodda
from socialift import Facebook
fb = Facebook(app_id="...", app_secret="...", license_key="slk_...")
| Reja | Imkoniyatlar | Seat |
|---|---|---|
| Trial (14 kun, bepul) | Profil, postlar, izohlar, webhook | 1 |
| Starter | + kontent e'lon qilish | 1 |
| Pro | + Instagram Direct, statistika va demografika | 3 |
| Enterprise | + Lead Ads, CRM quvuri, prioritet qo'llab-quvvatlash | cheksiz |
Kalit olish: https://socialift.uz/pricing
Rejaga kirmagan imkoniyatni chaqirsangiz so'rov Meta'ga yuborilishidan oldin to'xtatiladi:
from socialift import FeatureNotInPlan
try:
await fb.leads(form_id, page_token)
except FeatureNotInPlan as exc:
print(exc) # `lead_ads` imkoniyati `starter` rejasiga kirmaydi...
Litsenziya qanday ishlaydi (texnik tafsilot)
Kalit — Ed25519 bilan imzolangan JSON. Ikki bosqichda tekshiriladi:
- Offline — imzo paketga joylangan ochiq kalit bilan tekshiriladi. Kalit mazmunini (reja, muddat, seat) o'zgartirish imzoni buzadi.
- Online — SDK har 12 soatda
api.socialift.uz/api/v1/license/activatega murojaat qilib qisqa muddatli lease oladi. Bu obunani bekor qilish va seat nazoratini ta'minlaydi.
Litsenziya serveri javob bermasa 7 kunlik offline grace ishlaydi — tarmoq uzilishi prod'ingizni to'xtatmaydi.
Havosiz muhit (CI, izolyatsiyalangan tarmoq) uchun:
export SOCIALIFT_LICENSE_OFFLINE=1 # faqat imzo tekshiriladi
Ochiq aytamiz: Python paketi manba kodi sifatida tarqaladi, shuning uchun bu DRM emas — huquqiy va tashkiliy himoya vositasi. Litsenziya shartlari LICENSE faylida.
Misollar
Instagram Direct — to'liq suhbatdosh profili
/me/conversations javobida ishtirokchi haqida atigi id va username
keladi. SDK har bir suhbatdosh uchun User Profile API'ga parallel so'rov
yuboradi (asyncio.gather, 8 tadan) va natijani 6 soatga keshlaydi:
from socialift import Instagram
ig = Instagram.via_facebook(app_secret=FB_APP_SECRET)
chats = await ig.conversations(page_token, page_id="1111", ig_user_id="2222")
for chat in chats["data"]:
c = chat["contact"]
print(c["name"], c["follower_count"], "bizni kuzatadi:", c["is_user_follow_business"])
Lead Ads — webhook'dan CRM'gacha
from socialift import Facebook, verify_request, parse_events
# 1. Imzoni tekshirish (XOM baytlar!)
if not verify_request(APP_SECRET, raw_body, request.headers):
return 403
# 2. Hodisalarni ajratish
for event in parse_events(payload):
if event.field != "leadgen":
continue
if await already_processed(event.key): # takroriy yetkazish
continue
# 3. Meta lead MAZMUNINI yubormaydi — Graph API'dan o'qiymiz
async with Facebook(app_id=APP_ID, app_secret=APP_SECRET) as fb:
lead = await fb.lead(event.leadgen_id, page_token)
print(lead.fields) # {'full_name': ..., 'phone': '+998901234567'}
print(lead.campaign_name) # qaysi reklamadan kelgan
Xatolarni ishlash
from socialift import AuthError, PermissionError, RateLimitError
try:
await ig.send_message(recipient_id, token, "Salom!")
except RateLimitError as exc:
await asyncio.sleep(exc.retry_after or 60)
except PermissionError:
... # 24 soatlik javob oynasi tugagan
except AuthError:
... # token bekor qilingan → qayta login
To'liq server
Tayyor backend kerak bo'lsa — webhook qabul qilish, PostgreSQL'ga yozish, lead'larni CRM'ga imzolangan webhook bilan uzatish, Django admin:
pip install "socialift[server]"
socialift init # .env namunasi + kalitlar generatsiyasi
socialift check # sozlamalar to'g'rimi
socialift migrate # alembic upgrade head
socialift serve # http://localhost:8000/docs
62 endpoint · PostgreSQL + Redis talab qilinadi · docs/BACKEND_SETUP.md
Hujjatlar
| Hujjat | Kimga |
|---|---|
| docs/SDK.md | SDK API ma'lumotnomasi |
| SECURITY.md | Xavfsizlik modeli, token saqlash, zaiflik xabari |
| docs/BACKEND_SETUP.md | Meta / LinkedIn / CRM sozlash |
| docs/FRONTEND.md | Server API'si frontend uchun |
| docs/ARCHITECTURE.md | Arxitektura va qatlamlar |
| docs/DEPLOYMENT.md | Server, nginx, CI/CD |
Xavfsizlik — qisqacha
- Token'lar SDK'da saqlanmaydi. Har chaqiruvga argument sifatida uzatiladi — bitta klient bilan ko'p foydalanuvchi nomidan parallel ishlash xavfsiz.
appsecret_proofhar Graph so'rovga avtomatik qo'shiladi: o'g'irlangan token boshqa muhitdan ishlamaydi.- Page token
repr()da ko'rinmaydi — log'ga tasodifan tushmaydi. - Webhook imzosi
hmac.compare_digestbilan — timing attack'dan himoya. - Server: rate limiting,
TrustedHostMiddleware, xavfsizlik sarlavhalari, prod'da yopiq/docs, bazadagi token'lar Fernet bilan shifrlangan.
Batafsil va zaiflik xabar berish: SECURITY.md.
Platformalarning real cheklovlari
Bularni SDK yashira olmaydi:
- Instagram xabar matni faqat oxirgi 20 kun uchun keladi.
- Javob oynasi — mijozning oxirgi xabaridan 24 soat.
- Suhbatdosh profili faqat u biznesga yozgan bo'lsa ochiladi.
- Demografika obunachilar 100 tadan kam bo'lsa berilmaydi.
- Development rejimidagi Meta app haqiqiy foydalanuvchilardan webhook olmaydi — App Review kerak.
- Page webhook obunasi app sozlamasidan alohida:
subscribe_page().
Talablar
Python 3.11+ · aiohttp · cryptography
Qo'llab-quvvatlash
- Hujjatlar: https://github.com/1fayoz/socialift/tree/main/docs
- Savol va xatolar: https://github.com/1fayoz/socialift/issues
- Tijorat: hello@socialift.uz
Litsenziya
Tijorat litsenziyasi — LICENSE. Obuna: https://socialift.uz/pricing
Metadata
Release files for socialift 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| socialift-1.0.0.tar.gz | 200.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| socialift-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 461.5 kB
Security for socialift 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for socialift-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
Release files / socialift-1.0.0.tar.gz
How to use checksums
3579e80eaf40e7cff8852d6ea99744f671f5008692e66c254429dac4f58e073eHow to use checksums
81b3b50ff113cf841f27b7dd84f19dfec784ac6166b5bf6f45df29b4158aa456What is trusted publishing?
twine/7.0.0 CPython/3.13.14Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.
Transparency logIdentity
Workflow
Artifact
socialift-1.0.0.tar.gz3579e80eaf40e7cff8852d6ea99744f671f5008692e66c254429dac4f58e073eVerifying attestations