B
B
BitSky
Search…
BitSky RESTFul API
post
http://localhost:9099
/apis/tasks
Add Tasks to BitSky

Request Body Array Item Schema

Item is a subset of Task Schema
Schema
Example
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "https://raw.githubusercontent.com/bitskyai/bitsky-supplier/develop/src/schemas/task.json",
"type": "object",
"title": "Task Schema",
"version": "1.0.0",
"required": ["retailer", "url"],
"additionalProperties": false,
"properties": {
"retailer": {
"type": "object",
"description": "After producer execute this task, which Retailer to send **callback** to",
"required": ["globalId"],
"properties": {
"globalId": {
"$ref": "#/definitions/globalId"
},
"state": {
"$ref": "#/definitions/retailerState"
}
}
},
"priority": {
"type": "integer",
"minimum": 1,
"default": 100,
"description": "Priority of this task. Only compare priority for same Retailer, doesn't compare cross Retailer. Big value low priority. Priority value 1 is higher than priority value 2."
},
"suitableProducers": {
"type": "array",
"description": "What kind of producer types can execute this task",
"default": ["HEADLESSBROWSER"],
"items": {
"$ref": "#/definitions/producerType"
},
"minItems": 1,
"uniqueItems": true
},
"url": {
"$ref": "#/definitions/url"
},
"metadata": {
"type": "object",
"additionalProperties": true,
"description": "Additional metadata for this task",
"properties": {
"script": {
"type": "string",
"description": "Code want to execute after **window.onload**. You only need to pass function body. And Default you will get following parameters - **resolve**, **reject**, **task**, **axios**. You need to resolve(data) or reject(err), and will send data or err to Retailer. If you need producer to execute your code, Only work with **HEADLESSBROSWER** producer"
}
}
}
},
"definitions": {
"globalId": {
"title": "Global ID",
"description": "globally unique identifier, if you don't pass, then it will automatically generate one",
"type": "string",
"examples": ["59f43b55-46a3-4efc-a960-018bcca91f46"]
},
"producerType": {
"title": "Producer Type",
"type": "string",
"description": "Producer type of this producer",
"enum": ["HTTP", "HEADLESSBROWSER"]
},
"url": {
"type": "string",
"format": "uri",
"description": "Target URL for this task.",
"examples": ["https://json-schema.org"]
},
"dataset": {
"type": "object",
"additionalProperties": true,
"description": "All data that was collected by producer when it executed task. You also can use **metadata.script** to add more properties",
"properties": {
"url": {
"type": "string",
"description": "The finally URL that collect this information. Sometime, previous URL maybe redirect.",
"format": "uri",
"examples": ["https://json-schema.org"]
},
"data": {
"type": "object",
"description": "Collect ",
"properties": {
"contentType": {
"type": "string",
"title": "Content Type",
"description": "Content Type of return data",
"default": "html",
"enum": ["html", "json", "text"]
},
"content": {
"oneOf": [
{
"type": "string",
"description": "Collect html or text string"
},
{
"type": "object",
"description": "Collect JSON data"
}
]
}
}
}
}
}
}
}
{
"retailer": {
"globalId": "32e9671f-8f3c-45ac-8dfe-d5b5d9a0cbc1"
},
"url": "https://exampleblog.bitsky.ai/",
"metadata": {
"type": "bloglist"
}
}

Examples

Copy the following curl command to your terminal, it will create a Task in your BitSky
curl --location --request POST 'http://localhost:9099/apis/tasks' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"retailer": {
"globalId": "32e9671f-8f3c-45ac-8dfe-d5b5d9a0cbc1"
},
"url": "https://exampleblog.bitsky.ai/",
"metadata": {
"type": "bloglist"
}
}
]
'
  1. 1.
    Change retailer.globalId to correct value
  2. 2.
    Check whether your BitSky port is 9099. You can read How to get BitSky Desktop Application Base URL
Copy link
On this page
post
Add Tasks to BitSky