> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Python PyPI

> حزمة العميل Python PyPI الخاصة بـ Ayrshare

## نظرة عامة

تتيح لك [حزمة Social-Post-API PyPI](https://pypi.org/project/social-post-api/) من Ayrshare دمج واجهة Ayrshare API في تطبيق Python الخاص بك.

### التثبيت

قم بتثبيت [حزمة Social-Post-API PyPI](https://pypi.org/project/social-post-api/) إذا كنت تستخدم Python على جانب الخادم. تبسّط الحزمة الاستدعاءات عن طريق تغليف استدعاءات RESTful.

ابدأ بالحصول على مفتاح API السري الخاص بك في [لوحة تحكم Ayrshare](https://app.ayrshare.com/api).

بعد ذلك، قم بتثبيت حزمة Python:

```bash theme={"system"}
pip install social-post-api
```

### الاستخدام العام

أمثلة على Post وHistory وDelete. يُرجى الاطلاع على [حزمة PyPI](https://pypi.org/project/social-post-api/) لمزيد من المعلومات.

<Info>
  **تنشر على X/Twitter؟** اعتبارًا من 31 مارس 2026، تتطلب عمليات X/Twitter عبر Ayrshare بيانات اعتماد تطبيق X Developer الخاص بك — يفرض Ayrshare هذا على كل استدعاء موجّه إلى X. أضف ترويستَي BYO إلى طلبك. راجع [دليل الإعداد](/dashboard/connect-social-accounts/x-twitter-byo-keys) للتفاصيل.
</Info>

اعتبارًا من الإصدار v1.3.0، تتضمن الـ SDK وظيفة مساعدة `set_twitter_byo(api_key, api_secret)` تُلحق ترويستَي `X-Twitter-OAuth1-*` المطلوبتَين بكل طلب لاحق:

```python theme={"system"}
from ayrshare import SocialPost

social = SocialPost(API_KEY)
social.set_twitter_byo(MY_X_API_KEY, MY_X_API_SECRET)

social.post({"post": "Hello from BYO", "platforms": ["twitter"]})
```

استخدم `clear_twitter_byo()` لإسقاط الترويسات — وهو مفيد عند إعادة استخدام مثيل SDK واحد عبر عدة عملاء:

```python theme={"system"}
social.clear_twitter_byo().set_twitter_byo(next_tenant_key, next_tenant_secret)
```

```python theme={"system"}
from ayrshare import SocialPost
social = SocialPost('8jKj782Aw8910dCN') # get an API Key at ayrshare.com

# Required for any post that includes 'twitter' in platforms (BYO is enforced).
social.set_twitter_byo('YOUR_X_CONSUMER_KEY', 'YOUR_X_CONSUMER_SECRET')

# Post to Platforms Twitter, Facebook, and LinkedIn
postResult = social.post({'post': 'Nice Posting 2', 'platforms': ['twitter', 'facebook', 'linkedin'], 'profileKey': 'JKSDJI-JKKJKKJ'})
print(postResult)

# Delete (use the top-level Ayrshare post id from postResult['id'])
deleteResult = social.delete({'id': postResult['id']})
print(deleteResult)

# History
print(social.history())
```

### Profile Key

يمكنك تحديد Profile Key لملف المستخدم في نص طلب POST أو استعلام طلب GET باستخدام الحقل `profileKey`.

### مزيد من المعلومات والوثائق

<ul class="custom-bullets">
  <li>[حزمة PyPI](https://pypi.org/project/social-post-api/)</li>
  <li>[مستودع Github](https://github.com/ayrshare/social-post-api-python)</li>
  <li>[مناقشة المشكلات](https://github.com/ayrshare/social-post-api-python/issues)</li>
</ul>
