Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Retrieving Geographic Metadata and Adcodes via IP Location Services

Tech May 10 3

API Endpoint Overview

This API provides detailed geographic information based on a provided IPv4 address. It returns administrative data including province names, city names, standard adcode identifiers, and the bounding rectangle (latitude/longitude coordinates) for the identified urban area.

Request Specification

The service utilizes the GET method for data retrieval. To authenticate, users must provide a static access code retrieved from the "Digital Xujian" (数字续坚) WeChat mini-program.

Parameter Requirement Data Type Description
ip Required String The target IPv4 address (primarily suports Mainland China addresses).
code Required String Persistent authentication token obtained via the mini-program sign-in.

Endpoint URL: https://www.xujian.tech/atlapi/data/m/query/ipLocation

Response Schema

The API returns a JSON object containing the status code, a descriptive message, and the geographic payload.

Field Type Description
code Integer Success identifier (200 indicates a successful request).
msg String Status description (e.g., "succeed.").
data Object Container for location-specific attributes.
data.province String Name of the province or autonomous municipality.
data.city String Name of the city.
data.adcode String Standard administrative division code.
data.rectangle String Semicolon-separated coordinate pairs defining the city's bounding box.

Implementation Examples

Using cURL

curl -G "https://www.xujian.tech/atlapi/data/m/query/ipLocation" \
     --data-urlencode "ip=219.152.38.5" \
     --data-urlencode "code=YOUR_AUTH_CODE"

Using Python (Requests)

import requests

def get_location_by_ip(ip_address, token):
    api_url = "https://www.xujian.tech/atlapi/data/m/query/ipLocation"
    params = {
        "ip": ip_address,
        "code": token
    }
    
    response = requests.get(api_url, params=params)
    if response.status_code == 200:
        return response.json()
    return None

# Example execution
result = get_location_by_ip("219.152.38.5", "YOUR_AUTH_CODE")
print(result)

Sample Response Data

{
    "code": 200,
    "msg": "succeed.",
    "data": {
        "province": "Chongqing",
        "city": "Chongqing",
        "adcode": "500000",
        "rectangle": "106.2832832,29.36962828;106.8138242,29.7401968"
    }
}

Usage Monitoring

Access statistics and daily call volumes can be monitored through the service dashboard. Users can log in to view real-time metrics for their specific authentication code at the following monitoring utility:

https://www.xujian.tech/monitor

Tags: IP Location

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.