Retrieving Geographic Metadata and Adcodes via IP Location Services
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