> ## 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-Client-Paket für Ayrshare

## Überblick

Ayrshares [Social-Post-API-PyPI-Paket](https://pypi.org/project/social-post-api/) ermöglicht Ihnen die Integration der Ayrshare-API in Ihre Python-App.

### Installation

Installieren Sie das [Social-Post-API-PyPI-Paket](https://pypi.org/project/social-post-api/), wenn Sie Python auf der Serverseite verwenden. Das Paket vereinfacht die Aufrufe, indem es die RESTful-Aufrufe kapselt.

Holen Sie sich zunächst Ihren geheimen API-Key im [Ayrshare-Dashboard](https://app.ayrshare.com/api).

Installieren Sie anschließend das Python-Paket:

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

### Allgemeine Verwendung

Beispiele für Post, History und Delete. Weitere Informationen finden Sie im [PyPI-Paket](https://pypi.org/project/social-post-api/).

<Info>
  **Posten auf X/Twitter?** Ab dem 31. März 2026 erfordern X/Twitter-Operationen über Ayrshare Ihre eigenen X-Developer-App-Zugangsdaten – Ayrshare erzwingt dies bei jedem X-Aufruf. Fügen Sie Ihrer Anfrage die 2 BYO-Header hinzu. Details finden Sie im [Einrichtungsleitfaden](/dashboard/connect-social-accounts/x-twitter-byo-keys).
</Info>

Ab v1.3.0 enthält das SDK einen Helfer `set_twitter_byo(api_key, api_secret)`, der die beiden erforderlichen `X-Twitter-OAuth1-*`-Header an jede nachfolgende Anfrage anhängt:

```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"]})
```

Verwenden Sie `clear_twitter_byo()`, um die Header zu entfernen – nützlich beim Wiederverwenden einer SDK-Instanz über mehrere Mandanten hinweg:

```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

Sie können den Profile Key für ein User Profile im Body einer POST-Anfrage oder in der Query einer GET-Anfrage mit dem Feld `profileKey` angeben.

### Weitere Informationen und Dokumentation

<ul class="custom-bullets">
  <li>[PyPI-Paket](https://pypi.org/project/social-post-api/)</li>
  <li>[GitHub-Repository](https://github.com/ayrshare/social-post-api-python)</li>
  <li>[Issue-Diskussion](https://github.com/ayrshare/social-post-api-python/issues)</li>
</ul>
