使用 Dataify 的网页监控 API 发送您的第一个请求。开始之前,请确保您已拥有 Dataify 账户、有效的 API Token 和充足的余额。
获取 API Token 并确认账户余额充足后,您可以使用以下代码发送第一个请求。
请将示例中的 <YOUR_API_TOKEN> 替换为您自己的 API Token。
请将示例中的 ^<YOUR_API_MONITOR_URL^> 替换为您自己想要监控的 URL。
请将示例中的 ^<YOUR_API_WEBHOOK_URL^> 替换为您自己用于接收 Webhook 通知的地址。
curl -X POST "http://接口地址/watch/jobs/create" ^
-H "Authorization: Bearer <YOUR_API_TOKEN>" ^
-H "Content-Type: application/json" ^
-d "{\"url\":\"^<YOUR_API_MONITOR_URL^>\",\"webhook_url\":\"^<YOUR_API_WEBHOOK_URL^>\",\"schedule_type\":1,\"interval_seconds\":3600,\"timezone\":\"UTC\",\"country\":\"US\",\"diff_modes\":\"auto\",\"retention_days\":30}"
curl -X POST 'http://接口地址/watch/jobs/create' \
-H 'Authorization: Bearer <YOUR_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{"url":"<YOUR_API_MONITOR_URL>","webhook_url":"<YOUR_API_WEBHOOK_URL>","schedule_type":1,"interval_seconds":3600,"timezone":"UTC","country":"US","diff_modes":"auto","retention_days":30}'
</Accordion>
<Accordion title="Python">
```python
import requests
url = "http://接口地址/watch/jobs/create"
headers = {
"Authorization": "Bearer <YOUR_API_TOKEN>",
"Content-Type": "application/json",
}
data = {
"url": "<YOUR_API_MONITOR_URL>",
"webhook_url": "<YOUR_API_WEBHOOK_URL>",
"schedule_type": 1,
"interval_seconds": 3600,
"timezone": "UTC",
"country": "US",
"diff_modes": "auto",
"retention_days": 30,
}
response = requests.post(url, headers=headers, json=data)
print(response.text)
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.Json;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://接口地址/watch/jobs/create");
request.Headers.Add("Authorization", "Bearer <YOUR_API_TOKEN>");
var data = new Dictionary<string, object>
{
["url"] = "<YOUR_API_MONITOR_URL>",
["webhook_url"] = "<YOUR_API_WEBHOOK_URL>",
["schedule_type"] = 1,
["interval_seconds"] = 3600,
["timezone"] = "UTC",
["country"] = "US",
["diff_modes"] = "auto",
["retention_days"] = 30,
};
request.Content = new StringContent(JsonSerializer.Serialize(data), Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
data := map[string]interface{}{
"url": "<YOUR_API_MONITOR_URL>",
"webhook_url": "<YOUR_API_WEBHOOK_URL>",
"schedule_type": 1,
"interval_seconds": 3600,
"timezone": "UTC",
"country": "US",
"diff_modes": "auto",
"retention_days": 30,
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "http://接口地址/watch/jobs/create", bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <YOUR_API_TOKEN>")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
const url = "http://接口地址/watch/jobs/create";
const body = {
"url": "<YOUR_API_MONITOR_URL>",
"webhook_url": "<YOUR_API_WEBHOOK_URL>",
"schedule_type": 1,
"interval_seconds": 3600,
"timezone": "UTC",
"country": "US",
"diff_modes": "auto",
"retention_days": 30,
};
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer <YOUR_API_TOKEN>",
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
console.log(await response.text());
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
my $ua = LWP::UserAgent->new;
my $data = encode_json({
'url' => '<YOUR_API_MONITOR_URL>',
'webhook_url' => '<YOUR_API_WEBHOOK_URL>',
'schedule_type' => 1,
'interval_seconds' => 3600,
'timezone' => 'UTC',
'country' => 'US',
'diff_modes' => 'auto',
'retention_days' => 30
});
my $req = HTTP::Request->new(POST => 'http://接口地址/watch/jobs/create');
$req->header('Authorization' => 'Bearer <YOUR_API_TOKEN>');
$req->header('Content-Type' => 'application/json');
$req->content($data);
my $response = $ua->request($req);
print $response->decoded_content;
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://接口地址/watch/jobs/create");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'url' => '<YOUR_API_MONITOR_URL>',
'webhook_url' => '<YOUR_API_WEBHOOK_URL>',
'schedule_type' => 1,
'interval_seconds' => 3600,
'timezone' => 'UTC',
'country' => 'US',
'diff_modes' => 'auto',
'retention_days' => 30,
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <YOUR_API_TOKEN>",
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String body = "{\"url\":\"<YOUR_API_MONITOR_URL>\",\"webhook_url\":\"<YOUR_API_WEBHOOK_URL>\",\"schedule_type\":1,\"interval_seconds\":3600,\"timezone\":\"UTC\",\"country\":\"US\",\"diff_modes\":\"auto\",\"retention_days\":30}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("http://接口地址/watch/jobs/create"))
.header("Authorization", "Bearer <YOUR_API_TOKEN>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("http://接口地址/watch/jobs/create")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == 'https'
request = Net::HTTP::Post.new(uri.request_uri)
request["Authorization"] = "Bearer <YOUR_API_TOKEN>"
request["Content-Type"] = "application/json"
request.body = {
'url' => '<YOUR_API_MONITOR_URL>',
'webhook_url' => '<YOUR_API_WEBHOOK_URL>',
'schedule_type' => 1,
'interval_seconds' => 3600,
'timezone' => 'UTC',
'country' => 'US',
'diff_modes' => 'auto',
'retention_days' => 30,
}.to_json
response = http.request(request)
puts response.body
{
"success": true,
"code": "OK",
"message": "",
"data": {
"id": 1,
"dataify_job_id": "mwj_01K7HR3SWNZ6D",
"jdata_job_id": "job_01K7HQ2R3SWNZ6D",
"url": "<YOUR_API_MONITOR_URL>",
"webhook_url": "<YOUR_API_WEBHOOK_URL>",
"timezone": "UTC",
"country": "US",
"schedule_type": 1,
"interval_seconds": 3600,
"cron_expr": "",
"selector": "",
"selector_type": "css",
"diff_modes": "auto",
"retention_days": 30,
"headers": "",
"mask_enabled": 1,
"mask_exclude": "",
"status": 1,
"last_check_at": 0,
"last_check_status": 0,
"next_run_at": 1762838400,
"last_error": "",
"total_point_cost": "0.0000",
"total_credit_cost": "0.0000",
"created_at": 1762834800,
"updated_at": 1762834800
}
}