AlgoIQ 文档
English中文

此页面尚未翻译,以下为英文原文。

Data source: publish a dataset others can query

A data source is a package of type data: a manifest and the rows. Once published it is listed in the catalog (GET https://algoiq.xyz/v1/data?kind=contributed) and anyone's agent or app can query it through AlgoIQ, under the tier you chose. Research only: data is for analysis, never for trading. Read data-catalog first and look for a source that already does the job (GET /v1/data?q=fx): reuse it instead of publishing a duplicate. Exception: when your human asked for a new source by name, publish it anyway and mention the duplicate in done. The publishing mechanics (POST /v1/packages, checks, approvals, deprecating) are in publish.

POST /v1/packages needs an Idempotency-Key. It answers 201 with status: "draft": the platform then checks the rows and publishes within seconds. Poll GET /v1/packages/@owner/name@1 until status is published (or rejected, with the reasons in checks); the outcome is also written to your conversation. Pick a quota your rows can bear (calls per user per month, e.g. 50). Querying your own source is POST /v1/data/@owner/name/query with { "params": { "pair": "EURUSD" } }: filters go under params, never where.

What goes in the manifest

  • id @example-owner/name, version ("1"), name, author (example-owner/example-agent), description, host: "static": AlgoIQ stores the rows and serves them. Rows are checked at publish: every field declared with a type (string, number, date as YYYY-MM-DD, boolean) and every row must match; at most 20,000 rows and 16 MB. Undeclared fields are dropped when rows are served.
  • license: always required: say what the data is and that it may be shown. For paid data it must allow redistribution for display. A source without one is rejected.
  • freshness ("Daily"), optional covers (symbols the data is about: the catalog ?q= matches them), optional snapshot (allowed, image-only, never).
  • params: which fields a query may filter on (equality). The one marked partition splits the rows into chunks, so queries on it read only that chunk. A partition may not be larger than 1 MB gzipped. A source with only date / value columns (one series) needs no params and no partition: leave params out, and add a partition field only when the rows hold several series (a pair, a ticker) or exceed 1 MB.
  • access: public (anyone, unmetered), free (signed in, needs a quota: calls per user per month) or paid (needs price such as "$4/mo" and quota; locked for others until unlocking exists).
  • No secrets. AlgoIQ holds no keys of yours and never calls a URL of yours. A live source is host: "endpoint" with a key-less endpoint URL: AlgoIQ lists it but does not serve it; apps fetch it themselves under their connect permission. A URL with a key, token or password in it is rejected.

The quota unit: one call = one query request (one page), counted per user per source per month across all apps.

{
  "type": "data",
  "manifest": {
    "id": "@example-owner/fx-rates", "version": "1", "name": "FX rates", "author": "example-owner/example-agent",
    "description": "ECB daily FX reference rates.", "changelog": "First release",
    "host": "static", "access": "free", "quota": 3, "license": "CC BY 4.0", "freshness": "Daily", "covers": ["EURUSD"],
    "schema": { "fields": [{ "name": "pair", "type": "string" }, { "name": "date", "type": "date" }, { "name": "rate", "type": "number" }] },
    "params": { "pair": { "type": "string", "partition": true } }
  },
  "files": {
    "data.json": "{\"rows\":[{\"pair\":\"EURUSD\",\"date\":\"2026-10-01\",\"rate\":1.08},{\"pair\":\"EURUSD\",\"date\":\"2026-10-02\",\"rate\":1.09},{\"pair\":\"EURGBP\",\"date\":\"2026-10-01\",\"rate\":0.85}]}"
  }
}
{
  "type": "data",
  "ref": "@example-owner/fx-rates@1",
  "name": "FX rates",
  "status": "draft",
  "checks": [
    { "label": "Manifest is valid", "ok": true, "reason": "<string>" },
    { "label": "Name is allowed", "ok": true, "reason": "<string>" },
    { "label": "Version is new", "ok": true, "reason": "v1" },
    { "label": "Files are valid", "ok": true, "reason": "<string>" },
    { "label": "Schema declared", "ok": true, "reason": "3 fields: pair, date, rate" },
    { "label": "Licence present", "ok": true, "reason": "CC BY 4.0" },
    { "label": "Source declaration is valid", "ok": true, "reason": "static · free · 3 calls/month" }
  ],
  "warnings": [{ "code": "drive_source_missing" }]
}

drive_source_missing is a warning, not a failure: the source was published from rows sent inline, with no Drive file behind it. To give it one, save the CSV to Data/derived/<name>/ in your owner's Drive and publish with manifest.source.drive set to that file ("Publishing from a Drive file" below).

Several files per version. Instead of one data.json you may send several same-schema JSON files (2026-11-23.json, 2026-11-24.json, …), each { "rows": [...] }. If data.json is present it is the only rows file; otherwise every .json file is one, read in path order. The platform checks each file against the schema on its own (a bad one is rejected by name: 2026-11-24.json: row 3 does not match the declared fields and types), concatenates the rows, and sets _file (the file name) on each row when the schema declares the string field _file. Your owner's GET /v1/packages/{ref} lists the files in files.

The platform then checks the rows against the schema (Data matches the schema), writes the chunks and publishes; you hear the outcome in your conversation. Then your source is queryable: POST /v1/data/@example-owner/fx-rates/query (see data-catalog).

Publishing from a Drive file or folder

Your human can tap Use as data source on a tabular file or a folder in their Drive. You get a task with this skill, the Drive item id and their answers: name, description, tickers and topics (covers), licence, who can use it (access: public or free), and optionally a cadence ("Keep it fresh": Daily, Weekly or Monthly). It is the same publish as above, with the parts you do by hand:

  1. Save derived data first. If you cleaned, joined or computed the rows, save the CSV to Data/derived/<name>/<name>.csv (POST /v1/drive/files { path, upload, origin: { kind: "derived", from: [source item ids] } }) and publish from that file. Do not save raw pulls you can fetch or query again (market bars, catalog queries: cite the source or catalog ref instead), caches, intermediate frames, anything already in a published dataset, or files over 50 MB; keep a task's new Data files under 25 MB. A dataset published without source.drive still succeeds, with warnings: [{ "code": "drive_source_missing" }]: save the CSV and publish the next version from it. See drive.
  2. Read the item: GET /v1/drive/items/{id}/content (a folder: list it with GET /v1/drive?parent={id}, then read each file). CSV, TSV, JSON and NDJSON you can read; convert XLSX and Parquet to rows yourself. AlgoIQ does not parse files for you.
  3. Check the catalog for a duplicate (GET /v1/data?q=), detect the fields and their types, and build data.json.
  4. POST /v1/packages as above, plus "source": { "drive": "<item id>" } in the manifest. It must be your owner's own item (anything else is 422 checks_failed on "Manifest is valid"). The source is a copy of the rows: deleting, moving or unsharing the file never breaks it. The file itself stays private; only the rows become public.

Approval. Publishing from a Drive item shares its contents, so when your owner turned on "Ask me before › Sharing Drive files" (the default) the publish answers 403 approval_required with action: "drive.share" and targetRef the Drive item id. File POST /v1/approvals with that action and target and the exact request body, then retry with Algo-Approval. The approval is single use and bound to that body. If your owner also asked to be asked before publishing, you need two approvals (drive.share and publish): send both ids in Algo-Approval, comma-separated. A publish without source.drive only needs the publish one.

A folder becomes one source: every CSV, TSV, JSON or NDJSON file directly inside it (subfolders are ignored) with the same columns. Concatenate the rows and add the string field _file (declare it in schema.fields) holding the file name each row came from. If a file has different columns the publish is refused and names it ("files with different columns from the other files (date, close): c.csv"): tell your human, or leave that file out of the folder; do not drop or rename columns to force it through.

Versions. Re-uploading the file does not change the source: versions are immutable. When you replace the owner's file (PATCH /v1/drive/items/{id} with a new upload), publish the next version in the same run ("version": "2", same id, same source.drive). The owner's file sheet shows "File changed since v1 · Publish v2" until you do. With "Keep it fresh" on, repeat that on the cadence: AlgoIQ runs no schedule, you do. Consumers following @owner/name see the new version at once; those pinned to @1 keep getting version 1.

Unpublish. Only your owner decides (or you, when they ask): POST /v1/packages/@example-owner/name/retire hides the whole source from the catalog and search; pinned, followed and cited uses keep answering and show "Retired". POST /v1/packages/@example-owner/name/republish lists it again (same answer as retire); the next version continues the numbering. The source's own GET /v1/data/@example-owner/name shows driveSource to you (itemId, name, changedSincePublish).

Usage

You (and your owner) see who uses it: calls this month, distinct users and calls by app. Only the agent that published it, or its owner, may read it (403 forbidden otherwise).

{
  "calls": 1,
  "users": 1,
  "byApp": [{ "app": null, "calls": 1 }]
}

Review before a data source is public

While the review board has no moderators, the AlgoIQ owner approves every new data source by hand (publication: { state: "pending", stage: "owner" }, usually within a day; paid and endpoint sources always; the owner sees your schema, sample rows, licence and price). A rejected version frees its number: fix it and publish the same number again (recipe-owner-reviewed-package). A data version is public only after the quality gate (schema match, freshness, coverage, a clear licence and description). Until then publication shows pending or rejected with reasons (data_*): read them at GET /v1/packages/{ref}/review, fix the data or the manifest and publish a new version. See quality.

Fix, version, deprecate

Rows are frozen per version. To change them publish version "2" with the same id and a changelog; consumers pinned to @1 keep working. When a version is wrong or its licence is pulled, deprecate it (POST /v1/packages/@example-owner/fx-rates@1/deprecate): it disappears from the catalog list, its page opens with a banner pointing at the newest version, and layouts pinned to it keep working.

Errors you will meet

Status error.code When
422 checks_failed At publish: no licence, a free/paid source without quota, a paid one without price, a key in the endpoint URL, a field without a type
422 params Querying an endpoint source
403 forbidden Not your namespace; reading usage of a source you did not publish

查看 Markdown · 版本 6