📖 Hướng dẫn sử dụng API chấm công

1. Thông tin API

2. Tham số truyền vào

3. Ví dụ truy vấn GET

GET https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123

JavaScript

GET

fetch('https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123')
  .then(res => res.json())
  .then(data => console.log(data));

POST

fetch('https://api.aiface.vn/list/json/', {
  method: 'POST',
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  body: new URLSearchParams({
    tu_ngay: '2025-07-01',
    den_ngay: '2025-07-12',
    companyid: '1234567890',
    token: 'abc123'
  })
}).then(res => res.json()).then(console.log);

PHP

GET

$url = 'https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123';
$data = file_get_contents($url);
$json = json_decode($data, true);
print_r($json);

POST

$post = [
  'tu_ngay' => '2025-07-01',
  'den_ngay' => '2025-07-12',
  'companyid' => '1234567890',
  'token' => 'abc123'
];
$ch = curl_init('https://api.aiface.vn/list/json/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
$response = curl_exec($ch);
curl_close($ch);
print_r(json_decode($response, true));

Python

GET

import requests
res = requests.get("https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123")
print(res.json())

POST

import requests
data = {
  'tu_ngay': '2025-07-01',
  'den_ngay': '2025-07-12',
  'companyid': '1234567890',
  'token': 'abc123'
}
res = requests.post("https://api.aiface.vn/list/json/", data=data)
print(res.json())

C#

GET

using System.Net.Http;
HttpClient client = new HttpClient();
string url = "https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123";
var response = await client.GetAsync(url);
var result = await response.Content.ReadAsStringAsync();

POST

using System.Net.Http;
var values = new Dictionary {
  { "tu_ngay", "2025-07-01" },
  { "den_ngay", "2025-07-12" },
  { "companyid", "1234567890" },
  { "token", "abc123" }
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://api.aiface.vn/list/json/", content);
var result = await response.Content.ReadAsStringAsync();

Java

GET

import java.io.*;
import java.net.*;
URL url = new URL("https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
    content.append(inputLine);
}
in.close();

POST

URL url = new URL("https://api.aiface.vn/list/json/");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
String data = "tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123";
try (OutputStream os = conn.getOutputStream()) {
  os.write(data.getBytes());
}

ReactJS

GET

useEffect(() => {
  fetch("https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123")
    .then(res => res.json())
    .then(data => console.log(data));
}, []);

POST

useEffect(() => {
  fetch("https://api.aiface.vn/list/json/", {
    method: "POST",
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
    body: new URLSearchParams({
      tu_ngay: "2025-07-01",
      den_ngay: "2025-07-12",
      companyid: "1234567890",
      token: "abc123"
    })
  }).then(res => res.json()).then(data => console.log(data));
}, []);

Go

GET

resp, err := http.Get("https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123")
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))

POST

data := url.Values{
  "tu_ngay": {"2025-07-01"},
  "den_ngay": {"2025-07-12"},
  "companyid": {"1234567890"},
  "token": {"abc123"},
}
resp, _ := http.PostForm("https://api.aiface.vn/list/json/", data)
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))

Node.js

GET

const https = require('https');
https.get('https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123', res => {
  let data = '';
  res.on('data', chunk => data += chunk);
  res.on('end', () => console.log(data));
});

POST

const https = require('https');
const querystring = require('querystring');
const data = querystring.stringify({
  tu_ngay: '2025-07-01',
  den_ngay: '2025-07-12',
  companyid: '1234567890',
  token: 'abc123'
});
const req = https.request({
  hostname: 'api.aiface.vn',
  path: '/list/json/',
  method: 'POST',
  headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': data.length }
}, res => {
  let body = '';
  res.on('data', chunk => body += chunk);
  res.on('end', () => console.log(body));
});
req.write(data);
req.end();

Flutter (Dart)

GET

final response = await http.get(Uri.parse(
  'https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123')
);
print(response.body);

POST

final response = await http.post(
  Uri.parse('https://api.aiface.vn/list/json/'),
  body: {
    'tu_ngay': '2025-07-01',
    'den_ngay': '2025-07-12',
    'companyid': '1234567890',
    'token': 'abc123'
  },
);
print(response.body);

Ruby

GET

require 'net/http'
uri = URI('https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123')
res = Net::HTTP.get(uri)
puts res

POST

require 'net/http'
uri = URI('https://api.aiface.vn/list/json/')
res = Net::HTTP.post_form(uri, {
  'tu_ngay' => '2025-07-01',
  'den_ngay' => '2025-07-12',
  'companyid' => '1234567890',
  'token' => 'abc123'
})
puts res.body

PowerShell

GET

Invoke-RestMethod -Uri "https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123" -Method GET

POST

$body = @{ tu_ngay='2025-07-01'; den_ngay='2025-07-12'; companyid='1234567890'; token='abc123' }
Invoke-RestMethod -Uri "https://api.aiface.vn/list/json/" -Method POST -Body $body

Shell (cURL)

GET

curl "https://api.aiface.vn/list/json/?tu_ngay=2025-07-01&den_ngay=2025-07-12&companyid=1234567890&token=abc123"

POST

curl -X POST https://api.aiface.vn/list/json/ \
  -d "tu_ngay=2025-07-01" \
  -d "den_ngay=2025-07-12" \
  -d "companyid=1234567890" \
  -d "token=abc123"