跳转到主要内容
POST
/
v1
/
schedules
创建调度
curl --request POST \
  --url https://api.olostep.com/v1/schedules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "endpoint": "<string>",
  "payload": {},
  "cron_expression": "<string>",
  "execute_at": "2023-11-07T05:31:56Z",
  "expression_timezone": "<string>",
  "text": "<string>"
}
'
import requests

url = "https://api.olostep.com/v1/schedules"

payload = {
"endpoint": "<string>",
"payload": {},
"cron_expression": "<string>",
"execute_at": "2023-11-07T05:31:56Z",
"expression_timezone": "<string>",
"text": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
endpoint: '<string>',
payload: {},
cron_expression: '<string>',
execute_at: '2023-11-07T05:31:56Z',
expression_timezone: '<string>',
text: '<string>'
})
};

fetch('https://api.olostep.com/v1/schedules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.olostep.com/v1/schedules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'endpoint' => '<string>',
'payload' => [

],
'cron_expression' => '<string>',
'execute_at' => '2023-11-07T05:31:56Z',
'expression_timezone' => '<string>',
'text' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.olostep.com/v1/schedules"

payload := strings.NewReader("{\n \"endpoint\": \"<string>\",\n \"payload\": {},\n \"cron_expression\": \"<string>\",\n \"execute_at\": \"2023-11-07T05:31:56Z\",\n \"expression_timezone\": \"<string>\",\n \"text\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.olostep.com/v1/schedules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"endpoint\": \"<string>\",\n \"payload\": {},\n \"cron_expression\": \"<string>\",\n \"execute_at\": \"2023-11-07T05:31:56Z\",\n \"expression_timezone\": \"<string>\",\n \"text\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.olostep.com/v1/schedules")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"endpoint\": \"<string>\",\n \"payload\": {},\n \"cron_expression\": \"<string>\",\n \"execute_at\": \"2023-11-07T05:31:56Z\",\n \"expression_timezone\": \"<string>\",\n \"text\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "endpoint": "<string>",
  "cron_expression": "<string>",
  "execute_at": "2023-11-07T05:31:56Z",
  "expression_timezone": "<string>",
  "created": "2023-11-07T05:31:56Z"
}

授权

Authorization
string
header
必填

Bearer身份验证头的格式为Bearer ,其中是你的认证令牌。

请求体

application/json
method
enum<string>
必填

调度的 API 调用的 HTTP 方法。必须是 GET 或 POST。

可用选项:
GET,
POST
endpoint
string
必填

调度执行时要调用的端点 URL。对于带有 Olostep 端点的 POST 请求,你可以使用简短形式(例如,'v1/scrapes', 'v1/batches', 'v1/crawls', 'v1/maps', 'v1/answers'),它们会被自动加上 'https://api.olostep.com/' 前缀。对于其他端点,提供完整的 URL。

payload
object

随 API 调用发送的有效负载。可以包含你需要的任何 JSON 结构。对于 GET 请求,这通常是空的。对于 POST 请求,这应该包含你想发送到端点的数据。

cron_expression
string

用于重复调度的 6 个字段格式的 cron 表达式(分钟 小时 天 月 星期几 年)。重复调度必需。与 execute_at 和 text 互斥。

execute_at
string<date-time>

用于一次性调度执行的 ISO 8601 日期时间字符串。必须是有效的未来日期时间。一次性调度必需。与 cron_expression 互斥。

expression_timezone
string

调度的 IANA 时区标识符(例如,'UTC', 'America/New_York', 'Europe/London')。重复调度必需,一次性调度可选。使用自然语言文本时,默认为 'UTC'。

text
string

用于自动生成 cron 表达式的自然语言文本。系统会将你的文本转换为有效的 cron 表达式。示例:'every 3 minutes', 'every day at 10am', 'every Monday at 9am'。与 cron_expression 和 execute_at 互斥。使用时,expression_timezone 默认为 'UTC'。

响应

调度创建成功。

id
string

唯一的调度标识符

type
enum<string>

调度类型:'recurring' 表示基于 cron 的调度,'onetime' 表示单次执行调度

可用选项:
recurring,
onetime
method
enum<string>

调度调用的 HTTP 方法

可用选项:
GET,
POST
endpoint
string

将被调用的端点 URL

cron_expression
string

Cron 表达式(仅在重复调度中存在)

execute_at
string<date-time>

执行日期时间(仅在一次性调度中存在)

expression_timezone
string

调度的时区

created
string<date-time>

调度创建时的 ISO 8601 日期时间