非官方的 Hinge API Python SDK。通过编程方式与 Hinge 交互,获取推荐、发送消息、下载媒体以及自动化交互。
要使用此 SDK,您需要有效的认证凭据。您可以将凭据存储在 .env 文件中,或直接传递给客户端。
BEARER_TOKEN:您的 JWT 认证令牌(例如 L2euNWN...)。SESSION_ID:当前会话 UUID。USER_ID:您的用户/玩家 ID。如果您想使用现有 Hinge 账户,同时避免因新设备登录而触发风险标记,您必须从应用的网络流量中提取这些值。
注意: 您只需一次操作即可获取正确变量。捕获后,后续会话可使用短信登录方法。
prod-api.hingeaws.net 或类似 Hinge 端点的 HTTPS 请求。authorization(Bearer 令牌)x-session-idx-device-idx-install-idUser ID(通常在响应正文中作为 subjectId 或类似字段出现)您可以通过 SDK 通过短信登录生成新凭据。这会执行全新的登录流程。
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"成功获取推荐请求。")
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='你好,这是一条测试消息!'
)
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": "我在迈阿密待了一年,还没去过呢 (╥﹏╥)"
}
)
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": "那么有多少人评论说来过这里呢?"
# }
# )
# print(response)
此示例演示如何抓取推荐并根据特定条件(例如顶尖大学)过滤个人资料。