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

> Ayrshare 用の Python PyPI クライアントパッケージ

## 概要

Ayrshare の [Social-Post-API PyPI Package](https://pypi.org/project/social-post-api/) を使用すると、Ayrshare API を Python アプリに統合できます。

### インストール

サーバーサイドで Python を使用する場合、[Social-Post-API PyPI Package](https://pypi.org/project/social-post-api/) をインストールします。このパッケージは RESTful 呼び出しをラップすることで、呼び出しを簡素化します。

まず、[Ayrshare Dashboard](https://app.ayrshare.com/api) でシークレット API Key を取得します。

次に、Python パッケージをインストールします:

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

### 一般的な使用法

Post、History、Delete の例。詳細については [PyPI Package](https://pypi.org/project/social-post-api/) を参照してください。

<Info>
  **X/Twitter に投稿しますか?** 2026 年 3 月 31 日以降、Ayrshare を通じた X/Twitter 操作には独自の X Developer App 認証情報が必要です — Ayrshare はすべての X 宛の呼び出しでこれを強制します。リクエストに 2 つの BYO ヘッダーを追加してください。詳細については [セットアップガイド](/dashboard/connect-social-accounts/x-twitter-byo-keys) を参照してください。
</Info>

v1.3.0 以降、SDK には後続のすべてのリクエストに 2 つの必須の `X-Twitter-OAuth1-*` ヘッダーを付ける `set_twitter_byo(api_key, api_secret)` ヘルパーが含まれています:

```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()` を使用してヘッダーを削除します — 1 つの 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

`profileKey` フィールドを使用して、POST のボディまたは GET のクエリで User Profile の Profile Key を指定できます。

### 詳細情報とドキュメント

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