import{_ as n,c as a,a as t,o as l}from"./app-CDdN0tOz.js";const e={};function o(p,s){return l(),a("div",null,s[0]||(s[0]=[t(`<h1 id="通过ip确定地理位置" tabindex="-1"><a class="header-anchor" href="#通过ip确定地理位置"><span>通过ip确定地理位置</span></a></h1><h2 id="根据请求ip确定属地" tabindex="-1"><a class="header-anchor" href="#根据请求ip确定属地"><span>根据请求IP确定属地</span></a></h2><blockquote><p>https://api.bilibili.com/x/web-interface/zone</p><p>https://api.live.bilibili.com/xlive/web-room/v1/index/getIpInfo</p><p>https://app.bilibili.com/x/resource/ip</p></blockquote><p><em>请求方式：GET</em></p><p><strong>json回复：</strong></p><p>根对象：</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>code</td><td>num</td><td>返回值</td><td>0：成功</td></tr><tr><td>message</td><td>str</td><td>错误信息</td><td>默认为0</td></tr><tr><td>ttl</td><td>num</td><td>1</td><td></td></tr><tr><td>data</td><td>obj</td><td>信息本体</td><td></td></tr></tbody></table><p><code>data</code>对象：</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>addr</td><td>str</td><td>公网IP地址</td><td></td></tr><tr><td>country</td><td>str</td><td>国家/地区名</td><td></td></tr><tr><td>province</td><td>str</td><td>省/州</td><td>非必须存在项</td></tr><tr><td>city</td><td>str</td><td>城市</td><td>非必须存在项</td></tr><tr><td>isp</td><td>str</td><td>运营商名</td><td></td></tr><tr><td>latitude</td><td>num</td><td>纬度</td><td></td></tr><tr><td>longitude</td><td>num</td><td>经度</td><td></td></tr><tr><td>zone_id</td><td>num</td><td>ip数据库id</td><td>第二个接口无</td></tr><tr><td>country_code</td><td>num</td><td>国家/地区代码</td><td>第二个接口无</td></tr></tbody></table><p><strong>示例：</strong></p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-shell"><span class="line"><span style="color:#DCDCAA;">curl</span><span style="color:#CE9178;"> &#39;https://api.bilibili.com/x/web-interface/zone&#39;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><details><summary>查看响应示例：</summary><div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-json"><span class="line"><span style="color:#D4D4D4;">{</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;code&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;message&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#CE9178;">&quot;0&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;ttl&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;data&quot;</span><span style="color:#D4D4D4;">:{</span></span>
<span class="line"><span style="color:#9CDCFE;">            &quot;addr&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#CE9178;">&quot;36.40.120.145&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">            &quot;country&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#CE9178;">&quot;中国&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">            &quot;province&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#CE9178;">&quot;陕西&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">            &quot;city&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#CE9178;">&quot;渭南&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">            &quot;isp&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#CE9178;">&quot;电信&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">            &quot;latitude&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#B5CEA8;">34.4995</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">            &quot;longitude&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#B5CEA8;">109.492821</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">            &quot;zone_id&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#B5CEA8;">4472912</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">            &quot;country_code&quot;</span><span style="color:#D4D4D4;">:</span><span style="color:#B5CEA8;">86</span></span>
<span class="line"><span style="color:#D4D4D4;">        }</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h2 id="查询任意-ip-地址的归属地" tabindex="-1"><a class="header-anchor" href="#查询任意-ip-地址的归属地"><span>查询任意 IP 地址的归属地</span></a></h2><blockquote><p>https://api.live.bilibili.com/ip_service/v1/ip_service/get_ip_addr<br> https://api.live.bilibili.com/client/v1/Ip/getInfoNew</p></blockquote><p>注: 以上接口等效</p><p><em>请求方式：GET</em></p><p><strong>URL参数:</strong></p><table><thead><tr><th>参数名</th><th>类型</th><th>内容</th><th>必要性</th><th>备注</th></tr></thead><tbody><tr><td>ip</td><td>str</td><td>IP地址</td><td>不必要</td><td>IPv4或IPv6地址不限, 留空与<a href="#%E6%A0%B9%E6%8D%AE%E8%AF%B7%E6%B1%82ip%E7%A1%AE%E5%AE%9A%E5%9C%B0%E7%90%86%E4%BD%8D%E7%BD%AE">根据请求IP确定地理位置</a>基本相同</td></tr></tbody></table><p><strong>JSON回复:</strong></p><p>根对象：</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>code</td><td>num</td><td>返回值</td><td>0: 成功</td></tr><tr><td>message</td><td>str</td><td>错误信息</td><td>默认为空</td></tr><tr><td>msg</td><td>str</td><td>错误信息</td><td>同message</td></tr><tr><td>data</td><td>obj</td><td>信息本体</td><td>出错时为空数组</td></tr></tbody></table><p><code>data</code>对象：</p><p>与<a href="#%E6%A0%B9%E6%8D%AE%E8%AF%B7%E6%B1%82ip%E7%A1%AE%E5%AE%9A%E5%9C%B0%E7%90%86%E4%BD%8D%E7%BD%AE">根据请求IP确定地理位置</a>回复的<code>data</code>对象基本相同, 但无 <code>zone_id</code> <code>country_code</code> 字段</p><p><strong>示例:</strong></p><p>查询请求IP地址的归属地:</p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-shell"><span class="line"><span style="color:#DCDCAA;">curl</span><span style="color:#569CD6;"> -G</span><span style="color:#CE9178;"> &#39;https://api.live.bilibili.com/client/v1/Ip/getInfoNew&#39;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><details><summary>查看响应示例:</summary><div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-json"><span class="line"><span style="color:#D4D4D4;">{</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;code&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;msg&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;message&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;data&quot;</span><span style="color:#D4D4D4;">: {</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;addr&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;104.28.156.113&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;country&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;新加坡&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;province&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;新加坡&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;city&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;isp&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;cloudflare.com&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;latitude&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;1.352083&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;longitude&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;103.819836&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">  }</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><p>查询IP地址<code>8.8.8.8</code>的归属地:</p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-shell"><span class="line"><span style="color:#DCDCAA;">curl</span><span style="color:#569CD6;"> -G</span><span style="color:#CE9178;"> &#39;https://api.live.bilibili.com/ip_service/v1/ip_service/get_ip_addr&#39;</span><span style="color:#D7BA7D;"> \\</span></span>
<span class="line"><span style="color:#D4D4D4;">--data-urlencode </span><span style="color:#CE9178;">&#39;ip=8.8.8.8&#39;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><details><summary>查看响应示例:</summary><div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-json"><span class="line"><span style="color:#D4D4D4;">{</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;code&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;msg&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;message&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;data&quot;</span><span style="color:#D4D4D4;">: {</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;addr&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;8.8.8.8&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;country&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;GOOGLE.COM&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;province&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;GOOGLE.COM&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;city&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;isp&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;level3.com&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;latitude&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;longitude&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">  }</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details>`,30)]))}const r=n(e,[["render",o]]),c=JSON.parse('{"path":"/docs/clientinfo/ip.html","title":"通过ip确定地理位置","lang":"zh-CN","frontmatter":{},"git":{"updatedTime":1750530532000,"contributors":[{"name":"SocialSisterYi","username":"SocialSisterYi","email":"1440239038@qq.com","commits":2,"url":"https://github.com/SocialSisterYi"},{"name":"SessionHu","username":"SessionHu","email":"102411014+SessionHu@users.noreply.github.com","commits":2,"url":"https://github.com/SessionHu"},{"name":"114514ns","username":"114514ns","email":"121270969+114514ns@users.noreply.github.com","commits":1,"url":"https://github.com/114514ns"}],"changelog":[{"hash":"2f48f6c81ab400d03ac40921b25906ad8719e725","time":1750530532000,"email":"121270969+114514ns@users.noreply.github.com","author":"114514ns","message":"添加部分直播相关api (#1297)"},{"hash":"60a0c5d1a2f44fe61335da04571305fa7727a968","time":1724238159000,"email":"102411014+SessionHu@users.noreply.github.com","author":"Session小胡","message":"feat: 各种接口补充与错误修正 (#1066)"},{"hash":"18c1efbc102ae6b44c8f5314c90e5e64f0d926cd","time":1721909032000,"email":"102411014+SessionHu@users.noreply.github.com","author":"Session小胡","message":"feat: bili_ticket 算法 Java 实现 及 信息补充 及 错误修正 (#1061)"},{"hash":"f6760f4be38d5b592d396b211e48c666286524de","time":1677124138000,"email":"1440239038@qq.com","author":"SocialSisterYi","message":"🔨remove header index"},{"hash":"7d89ece2ac46425810647c4ac92acf5f3721cb68","time":1676998806000,"email":"1440239038@qq.com","author":"SocialSisterYi","message":"🚀调整项目结构"}]},"filePathRelative":"docs/clientinfo/ip.md"}');export{r as comp,c as data};
