所有API使用统一的调用格式:通过HTTP POST发送JSON参数,返回JSON格式数据。
JavaScript (Fetch)
const response = await fetch('https://api.fwerkor.com/v1/execute', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
api: "example_api",
params: { param1: "value", param2: 123 }
})
});
const data = await response.json();
console.log(data);
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
api: "example_api",
params: { param1: "value", param2: 123 }
})
});
const data = await response.json();
console.log(data);
Python (Requests)
import requests
url = "https://api.fwerkor.com/v1/execute"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
payload = {
"api": "example_api",
"params": {
"param1": "value",
"param2": 123
}
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
print(data)
url = "https://api.fwerkor.com/v1/execute"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
payload = {
"api": "example_api",
"params": {
"param1": "value",
"param2": 123
}
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
print(data)
PHP (cURL)
$url = 'https://api.fwerkor.com/v1/execute';
$apiKey = 'YOUR_API_KEY';
$payload = [
'api' => 'example_api',
'params' => [
'param1' => 'value',
'param2' => 123
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
"Authorization: Bearer $apiKey"
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
$apiKey = 'YOUR_API_KEY';
$payload = [
'api' => 'example_api',
'params' => [
'param1' => 'value',
'param2' => 123
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
"Authorization: Bearer $apiKey"
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);