• API 功能

    • 支持全球 IP 地址定位查询;
    • 每周定时更新最新定位基础数据库;
    • 提供精准、高效的 IPv4/IPv6 地址定位查询;
    • 一个接口同时兼容 IPv4 或 IPv6 地址的查询定位;
    • 返回的 IP 定位地址包含详细的位置信息;
    • 全接口支持 HTTPS(TLS v1.0 / v1.1 / v1.2 / v1.3);
    • 全面兼容 Apple ATS;
    • 全国多节点 CDN 部署;
    • 接口极速响应,多台服务器构建 API 接口负载均衡。
    • 接口调用状态与状态监控
  • API 文档

    接口地址: https://api.gugudata.com/v2/location/ip

    返回格式: application/json; charset=utf-8

    请求方式: GET

    请求协议: HTTPS

    请求示例: https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE

    数据预览: https://www.gugudata.com/preview/internationaliplocation

    接口测试:  https://api.gugudata.com/v2/location/ip/demo

    OpenAPI: https://www.gugudata.com/openapi/gugudata.openapi.3.1.json

    请求参数(GET 请求方式可参见下方示例代码)

    参数名 参数类型 是否必须 默认值 备注
    appkey string YOUR_APPKEY 付费后获取的 APPKEY
    ip string YOUR_VALUE IP 地址,可以传递 IPv4 或 IPv6 地址

    返回参数

    参数名 参数类型 备注
    dataStatus.statusCode integer 接口返回状态码
    dataStatus.statusDescription string 接口返回状态说明
    dataStatus.responseDateTime string 接口数据返回时间
    dataStatus.dataTotalCount integer 此条件下的总数据量,一般用于分页计算
    data.countryCode string IP 地址定位国家代码
    data.state string IP 地址定位省份/州
    data.city string IP 地址定位城市
    data.latitude number IP 地址定位纬度
    data.longitude number IP 地址定位经度
  • 接口 HTTP 响应标准状态码

    状态码 状态码解释 备注
    200 接口正常响应 请求成功,业务状态请结合响应体中的自定义业务码判断。
    400 请求参数错误 请求参数缺失、格式错误或参数组合不合法。
    401 鉴权失败 缺少 appkey 或 appkey 无效。
    403 无权限访问 订单到期、权限不足或接口额度不可用。
    404 资源不存在 请求路径不存在。
    405 请求方法不允许 当前路径不支持该 HTTP 方法。
    415 请求内容类型不支持 上传或请求体的内容类型不符合接口要求。
    429 请求频率受限 请求频率超过服务限制,请适当降低调用速率。
    500 服务内部错误 服务端处理异常,请稍后重试。
    502 上游依赖错误 上游依赖服务不可用或返回异常。
  • 接口自定义状态码

    自定义状态码 自定义状态码解释 备注
    200 正常返回
    400 参数错误
    429 请求频率受限 每秒请求不能超过 100 次
    403 账号欠费 请及时关注订单到期短信提醒
    402 APPKEY 错误 请检查传递的 APPKEY 是否为开发者中心获取到的值
    500 接口响应错误
  • 请求示例代码
    curl --location --request GET 'https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE'
    #include <curl/curl.h>
    
    int main(void) {
      CURL *curl = curl_easy_init();
      if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE");
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
        CURLcode res = curl_easy_perform(curl);
        (void)res;
        curl_easy_cleanup(curl);
      }
      return 0;
    }
    
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Net.Http;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Get, "https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE");
    var response = client.SendAsync(request).Result;
    Console.WriteLine(response.Content.ReadAsStringAsync().Result);
    
    package main
    
    import (
      "fmt"
      "io"
      "net/http"
    )
    
    func main() {
      url := "https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE"
      req, err := http.NewRequest("GET", url, nil)
      if err != nil {
        fmt.Println(err)
        return
      }
      res, err := http.DefaultClient.Do(req)
      if err != nil {
        fmt.Println(err)
        return
      }
      defer res.Body.Close()
      body, err := io.ReadAll(res.Body)
      if err != nil {
        fmt.Println(err)
        return
      }
      fmt.Println(string(body))
    }
    
    OkHttpClient client = new OkHttpClient().newBuilder().build();
    Request request = new Request.Builder()
      .url("https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE")
      .method("GET", null)
      .build();
    Response response = client.newCall(request).execute();
    System.out.println(response.body().string());
    
    $.ajax({
      url: "https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE",
      method: "GET",
    }).done(function (response) {
      console.log(response);
    });
    
    const response = await fetch("https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE", {
      method: "GET"
    });
    console.log(await response.text());
    
    const response = await fetch("https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE", {
      method: "GET"
    });
    console.log(await response.text());
    
    #import <Foundation/Foundation.h>
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE"]];
    [request setHTTPMethod:@"GET"];
    NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
      if (error) {
        NSLog(@"%@", error);
        return;
      }
      NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
    }];
    [task resume];
    
    <?php
    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_CUSTOMREQUEST => "GET",
    ));
    $response = curl_exec($curl);
    curl_close($curl);
    echo $response;
    
    import requests
    
    url = "https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE"
    response = requests.request("GET", url)
    print(response.text)
    
    require "uri"
    require "net/http"
    
    url = URI("https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE")
    https = Net::HTTP.new(url.host, url.port)
    https.use_ssl = true
    request = Net::HTTP::Get.new(url)
    response = https.request(request)
    puts response.read_body
    
    import Foundation
    
    let semaphore = DispatchSemaphore(value: 0)
    var request = URLRequest(url: URL(string: "https://api.gugudata.com/v2/location/ip?appkey=YOUR_APPKEY&ip=YOUR_VALUE")!, timeoutInterval: .infinity)
    request.httpMethod = "GET"
    let task = URLSession.shared.dataTask(with: request) { data, response, error in
      defer { semaphore.signal() }
      guard let data = data else {
        print(String(describing: error))
        return
      }
      print(String(data: data, encoding: .utf8)!)
    }
    task.resume()
    semaphore.wait()
    
  • 常见问题 Q&A

    • Q: 数据请求有缓存吗?

      A: 我们为所有数据请求提供实时响应。对于定期更新的数据,我们在其更新周期内实施缓存策略,以优化性能。

    • Q: 如何保证请求时 key 的安全性?

      A: 我们建议将对 API 的请求操作放置在您的应用程序后端。这样,前端请求只与您的后端服务交互,确保了更高的安全性和易于维护的架构。

    • Q: 接口可以用于哪些开发语言?

      A: 我们的接口支持所有能进行网络请求的开发语言,便于在各类项目中快速整合数据。

    • Q: 接口的性能可以保证吗?

      A: 我们的接口后台使用与商业级项目相同的架构,保证了稳定且高效的性能。您可以通过访问测试接口了解更多性能信息。

  • 服务协议以及服务免责声明

    用户应当充分阅读 服务协议 以及 服务免责声明 ,用户购买与使用咕咕数据 API 服务亦视为接受本协议。

  • 技术支持

    • 技术支持邮箱: support@gugudata.com
    • 微信客服: 客服链接

业务相关接口推荐

稳定提供服务 10 年 国内 IP 地址定位
  • 根据 IP 地址进行定位查询
  • 兼容 IPv4/IPv6 / 最新数据
  • 1499元/年限时折扣 499元/年
查看详情 数据校验更新于 5 小时前
30% 折扣
全国三甲医院主体信息
  • 提供全国三级甲等医院主体公开基础信息
  • 主体医院名录 / 公开基础信息
  • 3999元/年限时折扣 1999元/年
查看详情 数据校验更新于 9 小时前
50% 折扣
稳定提供服务 10 年 国家地区基础信息数据
  • 多维度国家基础信息
  • 最新基础信息 / 支持多维度筛选
  • 599元/年限时折扣 299元/年
查看详情 数据校验更新于 4 小时前
50% 折扣
地理坐标系转换
  • 提供地理信息坐标系的相互转换
  • 支持 HTTPS / 多种地理坐标系
  • 399元/年限时折扣 199元/年
查看详情 被调用于 6 秒前
50% 折扣