
孤独で退屈したソフトウェアエンジニア向けのHingeデーティングアプリ用Python SDK
Hinge APIの非公式Python SDK。プログラムでHingeと連携し、おすすめの取得、メッセージ送信、メディアのダウンロード、インタラクションの自動化を行います。
SDKを使用するには、有効な認証情報が必要です。これらの情報は.envファイルに保存するか、クライアントに直接渡すことができます。
BEARER_TOKEN: JWT認証トークン(例:L2euNWN...)。SESSION_ID: 現在のセッションUUID。USER_ID: あなたのユーザー/プレイヤーID。既存のHingeアカウントを新しい端末でのログインによるフラグリスクなしで使用したい場合は、アプリのネットワークトラフィックからこれらの値を抽出する必要があります。
注意: 正しい変数を取得するためには、この操作は1回だけ行えば十分です。取得後は、将来のセッションにはSMSログイン方式を使用できます。
prod-api.hingeaws.net または同様のHingeエンドポイントへのHTTPSリクエストを調査します。authorization(Bearerトークン)x-session-idx-device-idx-install-idUser ID(レスポンスボディ内で subjectId などとしてよく見られます)SDKを介してSMSでログインすることで新しい認証情報を生成できます。これは新しいログインフローを実行します。
from hingesdk.client import HingeClient
# これらのIDはアカウントに関連付けられた実際の値と一致している必要があります。
# ランダムなUUIDは使用できません。アカウントの登録端末と一致している必要があります。
client = HingeClient.login_with_sms(
phone_number="+15551234567",
device_id="your_device_id_uuid",
install_id="your_install_id_uuid"
)
print(f"BEARER_TOKEN={client.auth_token}")
print(f"SESSION_ID={client.session_id}")
print(f"USER_ID={client.user_id}")
リポジトリをクローンしてパッケージをインストールします:
git clone https://github.com/reedgraff/hingesdk
cd hingesdk
pip install .
以下は認証してユーザーおすすめを取得する最小限の例です。
import os
from hingesdk.api import HingeAPIClient
# 認証情報で初期化
client = HingeAPIClient(
auth_token=os.getenv("BEARER_TOKEN"),
session_id=os.getenv("SESSION_ID"),
user_id=os.getenv("USER_ID")
)
# おすすめを取得
recs = client.get_recommendations()
print(f"Successfully fetched recommendations request.")
from hingesdk.client import HingeAPIClient
auth_token = 'your_auth_token'
user_id = 'your_user_id'
client = HingeAPIClient(auth_token=auth_token, user_id=user_id)
response = client.send_message(
subject_id='receiver_id',
message='Hello, this is a test message!'
)
print(response)
from hingesdk.api import HingeAPIClient
client = HingeAPIClient(auth_token=auth_token, user_id=user_id)
recommendations = client.get_recommendations()
print(recommendations)
from hingesdk.tools import HingeTools
from hingesdk.api import HingeAPIClient
from hingesdk.media import HingeMediaClient
api_client = HingeAPIClient(auth_token=auth_token, user_id=user_id)
media_client = HingeMediaClient(auth_token=auth_token)
tools = HingeTools(api_client, media_client)
tools.download_recommendation_content(output_path='path_to_save_images')
import os
import json
from hingesdk.tools import HingeTools
from hingesdk.api import HingeAPIClient
from hingesdk.media import HingeMediaClient
auth_token = os.getenv("BEARER_TOKEN")
session_id = os.getenv("SESSION_ID")
user_id = os.getenv("USER_ID")
api_client = HingeAPIClient(
auth_token=auth_token,
session_id=session_id,
user_id=user_id
)
media_client = HingeMediaClient(auth_token=auth_token)
tools = HingeTools(api_client, media_client)
# 例:ユーザー情報を取得
tools.create_profile_json(
source=ProfileSource.STANDOUTS,
output_file="standouts.json"
)
# 例:ユーザーにいいね
with open("standouts.json", "r") as f:
profiles = json.load(f)
personData = profiles["35582109789..."]
# ユーザーの質問にいいね
questionIDToLike = "5c4a346828fd883a24..."
response = api_client.like_profile(
subject_id=personData["interaction_data"]["subject_id"],
rating_token=personData["interaction_data"]["rating_token"],
prompt={
"questionId": questionIDToLike,
"response": "I've been in Miami for a year and still haven't gone (╥﹏╥)"
}
)
print(response)
# ユーザーの写真にいいね
# photoIDToLike = "2c6411ac-66e4-4194-..."
# response = api_client.like_profile(
# subject_id=personData["interaction_data"]["subject_id"],
# rating_token=personData["interaction_data"]["rating_token"],
# photo={
# "contentId": photoIDToLike,
# "comment": "So how many people have commented saying they've been here before?"
# }
# )
# print(response)
この例では、おすすめをスクレイピングし、特定の条件(例:トップ大学)に基づいてプロフィールをフィルタリングする方法を示します。