newBingAPI整理

发布于 2023-03-18  282 次阅读


获取ConversationID

GET https://www.bing.com/turing/conversation/create

 注意
中国大陆境内会自动 301https://cn.bing.com/turing/conversation/create
但是不影响使用

返回数据

返回字段返回类型描述
result  JsonObject 见下方#result
conversationIdString对话ID
格式为 51D|BingProd|***
clientIdString每个账号固定
conversationSignatureStringconversation签名
ParentJson
result 中的字段返回类型预期数据
valueStringSuccess
如不为 Success 则上方的字段只存在 result
messageString错误原因
result

返回数据示例

成功获取

{
	"conversationId": "51D|BingProd|***",
	"clientId": "***",
	"conversationSignature": "***",
	"result": {
		"value": "Success",
		"message": null
	}
}

账户没有权限访问

{
	"result": {
		"value": "Forbidden",
		"message": "Sorry, you are not allowed to access this service."
	}
}

未登陆

{
	"result": {
		"value": "UnauthorizedRequest",
		"message": "Sorry, you need to login first to access this service."
	}
}

与NewBing进行聊天

Websocket wss://sydney.bing.com/sydney/ChatHub

数据包发送

需要在每个数据的末尾加上一个Unicode字符""(\u001e)

连接

  1. 与服务器建立连接时发送一个{"protocol":"json","version":1}
  2. 等待服务器回复一个空的JSON字符串 {}
  3. 发送{"type":6}以及一个包含以下数据的Json字符串
Json格式
字段预期类型预期内容
argumentsArray见下方#arguments
invocationIdString本次聊天次数,从0开始自增
targetStringchat
typeInt4
ParentJson
字段预期类型预期内容
sourceStringcib
optionsSetsArray["nlu_direct_response_filter", "deepleo", "disable_emoji_spoken_text", "responsible_ai_policy_235", "enablemm", "harmonyv3", "wlthrottle", "dv3sugg"]
allowedMessageTypesArray["Chat", "InternalSearchQuery", "InternalSearchResult", "Disengaged", "InternalLoaderMessage", "RenderCardRequest", "AdsQuery", "SemanticSerp", "GenerateContentQuery", "SearchQuery"]
sliceIdsArray["anidtest", "scfraithct", "scraith70", "sydpayajaxlog", "perfinstcf", "linkimgincf", "0310wlthrot", "313localgnds0"]
traceIdString随机的32位数字+小写字母字符串
isStartOfSessionBoolean是否为本次conversation第一次聊天
messageJsonObject见下方#message
conversationSignatureString上方获取到的conversationSignature
participantJsonObject见下方#participant
conversationIdString上方获取到的conversationId
arguments
字段预期类型预期内容
localeString(ISO-639 Language Code)-(ISO-3166 Country Codes)
marketString(ISO-639 Language Code)-(ISO-3166 Country Codes)
regionString国家(可不填)
locationString经纬度(可不填)
locationHintsJsonArray位置(可不填)
timestampStringyyyy-MM-dd'T'hh:mm:ssZZZZZ
2023-03-18T16:04:07+08:00
authorStringuser
inputMethodStringKeyboard
textString你要询问的内容
messageTypeStringChat
message
字段预期类型预期内容
idString上方获取到的clientId
participant
json示例
   json示例  ==>  展开 / 收起

获取数据

  • 服务器会回复json格式的数据,其中的type为类型
  • type=1 数据更新事件
  • type=2 本次聊天结束
  • type=7 客户端数据格式出错, 服务器会自动断开
  • type=6 时需要给服务器发送{"type":6}以保持连接
  • type=3 数据响应完毕, 此时客户端断开
   type=2时的Json数据  ==>  展开 / 收起

最后

这样你就可以搓一个API辣,贴一个我写的API

间歇性发奋图强,持续性混吃等死
最后更新于 2023-03-18