API docsAPI docs
  • English
  • zh-CN
  • English
  • zh-CN
    • 概述
    • 请求 & 响应
    • 获取Auth Token
    • 使用 Auth Token
    • Api Example
    • 区域API
    • 部门API
    • 职位API
    • 人员API
    • 离职API
    • 设备API
    • 考勤记录API
    • 考勤报表API

Api Example

Python example

get area list

import json
import requests


url = "http://{host}:{port}/personnel/api/areas/"
# use General token
headers = {
    "Content-Type": "application/json",
    "Authorization": "Token ae600......2b7",
}
# or use JWT tokn
headers = {
    "Content-Type": "application/json",
    "Authorization": "JWT ey.........oQi98",
}

response = requests.get(url, headers=headers)
print(response.text)

add area

import json
import requests


url = "http://{host}:{port}/personnel/api/areas/"
# use General token
headers = {
    "Content-Type": "application/json",
    "Authorization": "Token ae600......2b7",
}
# or use JWT tokn
headers = {
    "Content-Type": "application/json",
    "Authorization": "JWT ey.........oQi98",
}

data = {
    'area_code': '0001',
    'area_name': 'test area'
}

response = requests.post(url, data=json.dumps(data), headers=headers)
print(response.text)

filter area list

import json
import requests


url = "http://{host}:{port}/personnel/api/areas/"
# use General token
headers = {
    "Content-Type": "application/json",
    "Authorization": "Token ae600......2b7",
}
# or use JWT tokn
headers = {
    "Content-Type": "application/json",
    "Authorization": "JWT ey.........oQi98",
}

filter_params = {
    'area_name': 'test area'
}

response = requests.get(url, params=filter_params, headers=headers)
print(response.text)

edit area

import json
import requests


url = "http://{host}:{port}/personnel/api/areas/"
# use General token
headers = {
    "Content-Type": "application/json",
    "Authorization": "Token ae600......2b7",
}
# or use JWT tokn
headers = {
    "Content-Type": "application/json",
    "Authorization": "JWT ey.........oQi98",
}

data = {
    'area_name': 'test area name'
}

response = requests.put(url, data=json.dumps(data), headers=headers)
print(response.text)

get area info

import json
import requests


url = "http://{host}:{port}/personnel/api/areas/2/"
# use General token
headers = {
    "Content-Type": "application/json",
    "Authorization": "Token ae600......2b7",
}
# or use JWT tokn
headers = {
    "Content-Type": "application/json",
    "Authorization": "JWT ey.........oQi98",
}


response = requests.get(url, headers=headers)
print(response.text)

delete area

import json
import requests


url = "http://{host}:{port}/personnel/api/areas/2/"
# use General token
headers = {
    "Content-Type": "application/json",
    "Authorization": "Token ae600......2b7",
}
# or use JWT tokn
headers = {
    "Content-Type": "application/json",
    "Authorization": "JWT ey.........oQi98",
}


response = requests.delete(url, headers=headers)
print(response.text)
Prev
使用 Auth Token