### Install Agent Skills via CLI Source: https://github.com/thinkcol/fasta-skills/blob/master/README.md Use these commands to add FASTA skills to your project. Global installation or targeting specific agents is supported via flags. ```bash # Install all skills npx skills add ThinkCol/fasta-skills # Install a specific skill npx skills add ThinkCol/fasta-skills --skill fasta-adhocsearch-api npx skills add ThinkCol/fasta-skills --skill open-lenx-api ``` -------------------------------- ### Search via cURL Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/fasta-adhocsearch-api/SKILL.md Example request using cURL with environment variable placeholders. ```bash curl -X POST "${ADHOCSEARCH_ENDPOINT:-https://adhocsearch.fasta.ai}/search" \ -H "Content-Type: application/json" \ -H "x-api-key: $ADHOCSEARCH_API_KEY" \ -H "x-user-id: $ADHOCSEARCH_USER_ID" \ -d '{ "query": "climate change", "from": 1711929600, "to": 1714521600, "size": 10 }' ``` -------------------------------- ### Get Task Data using curl Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Example using curl to retrieve task data within a specified date range and size. Ensure to set `LENX_ENDPOINT`, `LENX_API_KEY`, and `LENX_USER_ID` environment variables. ```bash curl -s "${LENX_ENDPOINT:-https://open.lenx.ai}/api/v1/tasks/42/data?from=1711929600&to=1714521600&size=10" \ -H "x-api-key: $LENX_API_KEY" \ -H "x-user-id: $LENX_USER_ID" ``` -------------------------------- ### Search via Python Requests Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/fasta-adhocsearch-api/SKILL.md Example request using the Python requests library. ```python import os, requests endpoint = os.getenv("ADHOCSEARCH_ENDPOINT", "https://adhocsearch.fasta.ai") resp = requests.post( f"{endpoint}/search", headers={ "Content-Type": "application/json", "x-api-key": os.environ["ADHOCSEARCH_API_KEY"], "x-user-id": os.environ["ADHOCSEARCH_USER_ID"], }, json={ "keywords": ["election", "vote"], "from": 1711929600, "to": 1714521600, "size": 50, }, ) data = resp.json()["data"] ``` -------------------------------- ### Get Tasks Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md List all tasks accessible to the authenticated user, with pagination. ```APIDOC ## GET /api/v1/tasks ### Description List all tasks accessible to the authenticated user, with pagination. ### Method GET ### Endpoint `{endpoint}/api/v1/tasks` ### Parameters #### Query Parameters - **page** (number) - Optional - Page number (default: 1) - **size** (number) - Optional - Results per page, max 20 (default: 10) ### Response #### Success Response (200 OK) Cached 5 minutes. Returns: ```json { "data": [ { "task_id": 123, "task_name": "My Task", "task_type": 0, "indus_id": null, "labels": [], "lang_abbr": "en", "status": 1, "created_at": "2025-01-15T10:30:00.000Z", "updated_at": "2025-03-20T14:00:00.000Z" } ], "pagination": { "page": 1, "size": 10, "total": 42, "totalPages": 5 } } ``` Each item contains: `task_id`, `task_name`, `task_type`, `indus_id`, `labels`, `lang_abbr`, `status`, `created_at`, `updated_at`. Results are sorted by `updated_at` descending. #### Errors - **400** — Invalid query parameters - **401** — Invalid API key or user ID - **500** — Unexpected error ``` -------------------------------- ### GET /api/v1/tasks Source: https://context7.com/thinkcol/fasta-skills/llms.txt List all accessible monitoring tasks with pagination support. ```APIDOC ## GET /api/v1/tasks ### Description List all accessible monitoring tasks. Results are sorted by updated_at descending. ### Method GET ### Endpoint /api/v1/tasks ### Parameters #### Query Parameters - **page** (integer) - Required - Page number. - **size** (integer) - Required - Number of items per page (max 20). ### Response #### Success Response (200) - **data** (array) - List of task objects. - **pagination** (object) - Pagination metadata including page, size, total, and totalPages. ``` -------------------------------- ### GET /api/v1/tasks Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Lists tasks with pagination support. ```APIDOC ## GET /api/v1/tasks ### Description Retrieves a paginated list of tasks, sorted by updated_at descending. ### Method GET ### Endpoint /api/v1/tasks ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number to retrieve. - **size** (integer) - Optional - The number of items per page (max 20). ``` -------------------------------- ### Get Task Info Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Retrieve metadata and search configuration for a specific monitoring task. ```APIDOC ## GET /api/v1/tasks/{task_id} ### Description Retrieve metadata and search configuration for a specific task. ### Method GET ### Endpoint `{endpoint}/api/v1/tasks/{task_id}` ### Parameters #### Path Parameters - **task_id** (number) - Required - monitoring task ID ### Response #### Success Response (200 OK) Cached 5 minutes. Returns `{ "data": { ... } }` with fields: `task_id`, `task_name`, `owner_ac_id`, `task_type`, `indus_id`, `labels`, `lang_abbr`, `status`, `region`, `created_at`, `updated_at`, `search_query` (object or null with: `lang_abbr`, `region`, `list_medium`, `list_author_id`, `query_layer`, `query_string`, `cron`, `exclude_channel_links`, `updated_at`) #### Errors - **400** — Invalid request - **401** — Invalid API key or user ID - **403** — User does not have permission to access this task - **404** — Task not found ``` -------------------------------- ### Validate query_layer Structures Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/references/QUERY_LAYER.md Examples of valid and invalid JSON structures for the query_layer. ```json { "in": ["a", "b"] } { "in": [["a", "b"], ["c"]] } ``` ```json { "in": ["a", ["b"]] } ``` -------------------------------- ### GET /api/v1/tasks/{taskId} Source: https://context7.com/thinkcol/fasta-skills/llms.txt Retrieve detailed metadata and search configuration for a specific monitoring task. ```APIDOC ## GET /api/v1/tasks/{taskId} ### Description Retrieve detailed metadata and search configuration for a specific monitoring task. Response is cached for 5 minutes. ### Method GET ### Endpoint /api/v1/tasks/{taskId} ### Parameters #### Path Parameters - **taskId** (integer) - Required - The unique identifier of the task. ### Response #### Success Response (200) - **data** (object) - Task details including task_id, task_name, owner_ac_id, task_type, indus_id, labels, lang_abbr, status, region, created_at, updated_at, and search_query. ``` -------------------------------- ### GET /api/v1/tasks/{id}/data Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Retrieves data for a specific task with pagination. ```APIDOC ## GET /api/v1/tasks/{id}/data ### Description Retrieves data associated with a specific task within a defined time range. ### Method GET ### Endpoint /api/v1/tasks/{id}/data ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the task. #### Query Parameters - **from** (integer) - Required - Start Unix timestamp. - **to** (integer) - Required - End Unix timestamp. - **size** (integer) - Required - Number of records to return. - **search_after** (string) - Optional - Cursor for pagination. ### Response #### Success Response (200) - **data** (array) - List of task data records. ``` -------------------------------- ### Get Task Data Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Fetch monitoring data for a specific task within a given date range. ```APIDOC ## GET /api/v1/tasks/{task_id}/data ### Description Fetch monitoring data for a specific task within a given date range. ### Method GET ### Endpoint `{endpoint}/api/v1/tasks/{task_id}/data` ### Parameters #### Path Parameters - **task_id** (number) - Required - monitoring task ID #### Query Parameters - **from** (number) - Required - Start of date range (Unix timestamp, seconds) - **to** (number) - Required - End of date range (Unix timestamp, seconds) - **size** (number) - Required - Results to return (1–1000) - **search_after** (number) - Optional - Pagination cursor — `unix_timestamp` of last result from previous page **Pagination:** Results are sorted by `unix_timestamp` descending. Pass the last item's `unix_timestamp` as `search_after` to get the next page. Repeat until fewer results than `size` are returned. ### Response #### Success Response (200 OK) Cached 5 minutes. Returns `{ "data": [...] }` where each item contains: `id`, `hash`, `country`, `lang_abbr`, `medium`, `channel`, `channel_link`, `site`, `thread_link`, `post_link`, `thread_title`, `post_message`, `post_timestamp` (ISO 8601), `unix_timestamp`, `author_name`, `author_id`, `author_image`, `author_link`, `is_comment`, `comment_order`, `comment_count`, `share_count`, `view_count`, `reaction_count`, `reaction_like`, `reaction_dislike`, `reaction_love`, `reaction_wow`, `reaction_haha`, `reaction_sad`, `reaction_angry`, `sentiment_score` #### Errors - **400** — `{ "message": "Invalid request body", "error": "..." }` - **401** — Invalid API key or user ID - **403** — `{ "message": "Forbidden", "error": "User does not have permission to access this task" } ``` -------------------------------- ### GET /api/v1/tasks/{task_id}/data Source: https://context7.com/thinkcol/fasta-skills/llms.txt Retrieve monitoring data for a specific task within a date range, supporting pagination via search_after. ```APIDOC ## GET /api/v1/tasks/{task_id}/data ### Description Retrieve monitoring data (social media posts) for a specific task within a date range. Supports pagination for large datasets using `search_after` with the last result's `unix_timestamp`. ### Method GET ### Endpoint /api/v1/tasks/{task_id}/data ### Parameters #### Path Parameters - **task_id** (integer) - Required - The ID of the task to retrieve data for. #### Query Parameters - **from** (integer) - Required - Start unix timestamp. - **to** (integer) - Required - End unix timestamp. - **size** (integer) - Optional - Number of results to return (max 1000). - **search_after** (integer) - Optional - The unix_timestamp of the last result from the previous page. ``` -------------------------------- ### Create Monitoring Task Source: https://context7.com/thinkcol/fasta-skills/llms.txt Initializes a new monitoring task using a POST request with a defined search query configuration. ```bash # Create a live monitoring task for brand mentions curl -s -X POST "${LENX_ENDPOINT:-https://open.lenx.ai}/api/v1/tasks" \ -H "x-api-key: $LENX_API_KEY" \ -H "x-user-id: $LENX_USER_ID" \ -H "Content-Type: application/json" \ -d '{ "task_type": "live", "task_name": "Brand Monitoring - ACME Corp", "language": "en", "search_query": { "query_layer": [ { "in": [["acme corp", "acme corporation"], ["product", "service"]], "ex": ["job listing", "careers"] } ], "region": "USA", "list_medium": ["News", "Social", "Facebook"] } }' # Response (201 Created): # { # "data": { # "task_id": 456, # "task_name": "Brand Monitoring - ACME Corp", # "task_type": 0, # "language": "en", # "status": 1, # "created_at": "2025-01-15T10:30:00.000Z" # } # } ``` -------------------------------- ### Implement Simple OR Logic Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/references/QUERY_LAYER.md Matches posts mentioning either Tesla or BYD. ```json [{ "in": ["tesla", "byd"] }] ``` -------------------------------- ### List Monitoring Tasks with Lenx Open API Source: https://context7.com/thinkcol/fasta-skills/llms.txt Retrieve a paginated list of monitoring tasks using cURL. ```bash # List first page of tasks curl -s "${LENX_ENDPOINT:-https://open.lenx.ai}/api/v1/tasks?page=1&size=10" \ -H "x-api-key: $LENX_API_KEY" \ -H "x-user-id: $LENX_USER_ID" ``` -------------------------------- ### Paginate Keyword Searches with Python Source: https://context7.com/thinkcol/fasta-skills/llms.txt Execute any-match keyword searches and retrieve subsequent pages using the search_after parameter. ```python import os import requests endpoint = os.getenv("ADHOCSEARCH_ENDPOINT", "https://adhocsearch.fasta.ai") headers = { "Content-Type": "application/json", "x-api-key": os.environ["ADHOCSEARCH_API_KEY"], "x-user-id": os.environ["ADHOCSEARCH_USER_ID"], } # First page - search for posts containing "election" OR "vote" resp = requests.post( f"{endpoint}/search", headers=headers, json={ "keywords": ["election", "vote"], "from": 1711929600, "to": 1714521600, "size": 100, }, ) data = resp.json()["data"] print(f"Found {len(data)} posts") # Paginate to get more results if len(data) == 100: last_timestamp = data[-1]["unix_timestamp"] resp = requests.post( f"{endpoint}/search", headers=headers, json={ "keywords": ["election", "vote"], "from": 1711929600, "to": 1714521600, "size": 100, "search_after": last_timestamp, }, ) more_data = resp.json()["data"] data.extend(more_data) ``` -------------------------------- ### Implement Multiple Top-Level Alternatives Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/references/QUERY_LAYER.md Matches either an EV topic or a solar topic using multiple EQLayer objects. ```json [ { "in": [["ev", "electric vehicle"], ["battery"]] }, { "in": [["solar", "photovoltaic"], ["panel"]] } ] ``` -------------------------------- ### Create Task API Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Create a new monitoring task with a search query configuration. ```APIDOC ## POST /api/v1/tasks ### Description Create a new monitoring task with a search query configuration. ### Method POST ### Endpoint {endpoint}/api/v1/tasks ### Parameters #### Request Body - **task_type** (string) - Required - "live" or "adhoc" - **task_name** (string) - Required - 1–50 characters - **language** (string) - Required - "zh-t", "zh-s", or "en" - **date_range** (object) - Conditional - Required for `adhoc` tasks, forbidden for `live` tasks - **from** (number) - Required - Start timestamp (Unix milliseconds, positive) - **to** (number) - Required - End timestamp (Unix milliseconds, must be > `from`) - **search_query** (object) - Required - Search configuration - **query_layer** (EQLayer[]) - Required - At least 1 entry. Each entry has optional `in` and `ex` arrays (see `query_layer` summary below) - **region** (string) - Optional - "Hong Kong", "China", "Taiwan", or "USA" - **list_medium** (string[]) - Optional - At least 1 when provided. Values: "Facebook", "Instagram", "Social", "News", "Forum", "Blog", "Videos" ### Request Example ```json { "task_type": "adhoc", "task_name": "Example Task", "language": "en", "date_range": { "from": 1711929600000, "to": 1714521600000 }, "search_query": { "query_layer": [ { "in": ["term1", "term2"] } ], "region": "USA", "list_medium": ["News"] } } ``` ### Response #### Success Response (201 Created) - **task_id** (number) - The ID of the created task - **task_name** (string) - The name of the task - **task_type** (number) - The type of the task (0 for live, 1 for adhoc) - **language** (string) - The language of the task - **status** (number) - The status of the task - **created_at** (string) - The creation timestamp #### Response Example ```json { "data": { "task_id": 123, "task_name": "New Task", "task_type": 0, "language": "en", "status": 1, "created_at": "2025-01-15T10:30:00.000Z" } } ``` ### Errors - **400**: Invalid request body (validation failed, or `query_layer` could not be converted — `INVALID_QUERY_LAYER`) - **401**: Missing `x-user-id` header - **403**: User does not have an associated account - **404**: User not found - **422**: Adhoc tasks are not supported yet - **500**: Unexpected error ``` -------------------------------- ### Create Task Response (201 Created) Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Successful response after creating a task. ```json { "data": { "task_id": 123, "task_name": "New Task", "task_type": 0, "language": "en", "status": 1, "created_at": "2025-01-15T10:30:00.000Z" } } ``` -------------------------------- ### POST /api/v1/tasks Source: https://context7.com/thinkcol/fasta-skills/llms.txt Create a new live or ad-hoc monitoring task with a search query configuration. ```APIDOC ## POST /api/v1/tasks ### Description Create a new live or ad-hoc monitoring task with a search query configuration. Live tasks run continuously while ad-hoc tasks require a date range. ### Method POST ### Endpoint /api/v1/tasks ### Request Body - **task_type** (string) - Required - 'live' or 'ad-hoc'. - **task_name** (string) - Required - Name of the task. - **language** (string) - Optional - Language code (e.g., 'en'). - **search_query** (object) - Required - Configuration containing `query_layer`, `region`, and `list_medium`. ### Response #### Success Response (201) - **task_id** (integer) - The ID of the created task. - **task_name** (string) - Name of the task. - **status** (integer) - Current status of the task. ``` -------------------------------- ### Implement Lenx Open API Client in TypeScript Source: https://context7.com/thinkcol/fasta-skills/llms.txt Defines interfaces for post data and configuration, and provides a client class for managing tasks and fetching paginated data. Requires environment variables for endpoint, API key, and user ID. ```typescript interface LenxPost { id: string; hash: string; medium: string; post_message: string; post_timestamp: string; unix_timestamp: number; author_name: string; sentiment_score: number | null; reaction_count: number | null; } interface LenxConfig { endpoint: string; apiKey: string; userId: string; } class LenxClient { constructor(private config: LenxConfig) {} private get headers() { return { "x-api-key": this.config.apiKey, "x-user-id": this.config.userId, "Content-Type": "application/json", }; } async createTask(name: string, queryLayer: object[], mediums: string[]) { const res = await fetch(`${this.config.endpoint}/api/v1/tasks`, { method: "POST", headers: this.headers, body: JSON.stringify({ task_type: "live", task_name: name, language: "en", search_query: { query_layer: queryLayer, list_medium: mediums }, }), }); if (!res.ok) throw new Error(`Create failed: ${res.status}`); return res.json(); } async getTaskData(taskId: number, from: number, to: number): Promise { const allPosts: LenxPost[] = []; let searchAfter: number | undefined; while (true) { const params = new URLSearchParams({ from: from.toString(), to: to.toString(), size: "1000", ...(searchAfter && { search_after: searchAfter.toString() }), }); const res = await fetch( `${this.config.endpoint}/api/v1/tasks/${taskId}/data?${params}`, { headers: this.headers } ); if (!res.ok) throw new Error(`Fetch failed: ${res.status}`); const { data } = await res.json(); allPosts.push(...data); if (data.length < 1000) break; searchAfter = data[data.length - 1].unix_timestamp; } return allPosts; } } // Usage const client = new LenxClient({ endpoint: process.env.LENX_ENDPOINT ?? "https://open.lenx.ai", apiKey: process.env.LENX_API_KEY!, userId: process.env.LENX_USER_ID!, }); const posts = await client.getTaskData(42, 1711929600, 1714521600); console.log(`Retrieved ${posts.length} posts`); ``` -------------------------------- ### List Tasks using curl Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Use this `curl` command to list tasks, with support for pagination using `page` and `size` query parameters. Authentication headers and endpoint environment variables are required. ```bash curl -s "${LENX_ENDPOINT:-https://open.lenx.ai}/api/v1/tasks?page=1&size=10" \ -H "x-api-key: $LENX_API_KEY" \ -H "x-user-id: $LENX_USER_ID" ``` -------------------------------- ### POST /api/v1/tasks Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Creates a new task with specific configuration. ```APIDOC ## POST /api/v1/tasks ### Description Creates a new task with the provided configuration, including task type, name, language, and search query parameters. ### Method POST ### Endpoint /api/v1/tasks ### Request Body - **task_type** (string) - Required - The type of task (e.g., "live"). - **task_name** (string) - Required - The name of the task. - **language** (string) - Required - The language code. - **search_query** (object) - Required - The search configuration object. ### Request Example { "task_type": "live", "task_name": "Brand Monitoring", "language": "en", "search_query": { "query_layer": [ { "in": [["acme corp", "acme corporation"]], "ex": ["job listing"] } ], "region": "USA", "list_medium": ["News", "Social"] } } ``` -------------------------------- ### Implement Include with Exclusions Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/references/QUERY_LAYER.md Matches Apple content while excluding fruit-related results. ```json [{ "in": ["apple"], "ex": ["fruit", "recipe"] }] ``` -------------------------------- ### Create Task using curl Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Use this `curl` command to create a new task. It requires specifying the task type, name, language, and search query parameters. Ensure environment variables for endpoint and authentication are set. ```bash curl -s -X POST "${LENX_ENDPOINT:-https://open.lenx.ai}/api/v1/tasks" \ -H "x-api-key: $LENX_API_KEY" \ -H "x-user-id: $LENX_USER_ID" \ -H "Content-Type: application/json" \ -d '{ "task_type": "live", "task_name": "Brand Monitoring", "language": "en", "search_query": { "query_layer": [ { "in": [["acme corp", "acme corporation"]], "ex": ["job listing"] } ], "region": "USA", "list_medium": ["News", "Social"] } }' ``` -------------------------------- ### Create Task API Endpoint Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Use POST to create a new monitoring task. Requires `task_type`, `task_name`, `language`, and `search_query`. `date_range` is conditional based on `task_type`. ```http POST {endpoint}/api/v1/tasks ``` -------------------------------- ### Retrieve Task Data with Pagination Source: https://context7.com/thinkcol/fasta-skills/llms.txt Fetches monitoring data for a specific task using a loop to handle pagination via the search_after parameter. ```python import os import requests endpoint = os.getenv("LENX_ENDPOINT", "https://open.lenx.ai") task_id = 42 all_posts = [] search_after = None while True: params = {"from": 1711929600, "to": 1714521600, "size": 1000} if search_after is not None: params["search_after"] = search_after resp = requests.get( f"{endpoint}/api/v1/tasks/{task_id}/data", headers={ "x-api-key": os.environ["LENX_API_KEY"], "x-user-id": os.environ["LENX_USER_ID"], }, params=params, ) resp.raise_for_status() page = resp.json()["data"] all_posts.extend(page) if len(page) < 1000: break search_after = page[-1]["unix_timestamp"] print(f"Retrieved {len(all_posts)} total posts") # Each post contains: id, hash, country, lang_abbr, medium, channel, post_message, # post_timestamp, unix_timestamp, author_name, sentiment_score, reaction_count, etc. ``` -------------------------------- ### Paginate Task Data using Python Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md This Python script demonstrates how to retrieve task data with pagination. It uses the `requests` library and iterates through results until all data is fetched. Ensure `LENX_ENDPOINT` and `LENX_API_KEY`, `LENX_USER_ID` environment variables are set. ```python import os, requests endpoint = os.getenv("LENX_ENDPOINT", "https://open.lenx.ai") task_id = 42 all_posts, search_after = [], None while True: params = {"from": 1711929600, "to": 1714521600, "size": 1000} if search_after is not None: params["search_after"] = search_after resp = requests.get( f"{endpoint}/api/v1/tasks/{task_id}/data", headers={"x-api-key": os.environ["LENX_API_KEY"], "x-user-id": os.environ["LENX_USER_ID"]}, params=params, ) resp.raise_for_status() page = resp.json()["data"] all_posts.extend(page) if len(page) < 1000: break search_after = page[-1]["unix_timestamp"] ``` -------------------------------- ### Implement Grouped AND/OR Logic Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/references/QUERY_LAYER.md Matches posts mentioning (EV or electric vehicle) AND (battery or charging). ```json [{ "in": [["ev", "electric vehicle"], ["battery", "charging"]] }] ``` -------------------------------- ### Retrieve Task Metadata Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Use this endpoint to fetch configuration and metadata for a specific monitoring task. ```http GET {endpoint}/api/v1/tasks/{task_id} ``` -------------------------------- ### Implement Complex Include and Exclude Groups Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/references/QUERY_LAYER.md Matches AI agents or copilots with automation context, while excluding job-related terms. ```json [ { "in": [["ai agent", "copilot"], ["automation", "workflow"]], "ex": [["job", "jobs", "hiring"]] } ] ``` -------------------------------- ### Perform a search request with TypeScript Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/fasta-adhocsearch-api/SKILL.md Uses the fetch API to send a POST request to the AdhocSearch endpoint. Requires environment variables for API key and user ID. ```typescript const endpoint = process.env.ADHOCSEARCH_ENDPOINT ?? "https://adhocsearch.fasta.ai"; const res = await fetch(`${endpoint}/search`, { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": process.env.ADHOCSEARCH_API_KEY!, "x-user-id": process.env.ADHOCSEARCH_USER_ID!, }, body: JSON.stringify({ query: "artificial intelligence", from: 1711929600, to: 1714521600, size: 25, }), }); const { data } = await res.json(); ``` -------------------------------- ### List Accessible Tasks Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Retrieve a paginated list of all tasks available to the authenticated user. ```http GET {endpoint}/api/v1/tasks ``` ```json { "data": [ { "task_id": 123, "task_name": "My Task", "task_type": 0, "indus_id": null, "labels": [], "lang_abbr": "en", "status": 1, "created_at": "2025-01-15T10:30:00.000Z", "updated_at": "2025-03-20T14:00:00.000Z" } ], "pagination": { "page": 1, "size": 10, "total": 42, "totalPages": 5 } } ``` -------------------------------- ### Update Task Response (200 OK) Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Successful response after updating a task. ```json { "data": { "task_id": 123, "updated": true } } ``` -------------------------------- ### Retrieve Task Information with TypeScript Source: https://context7.com/thinkcol/fasta-skills/llms.txt Fetch detailed metadata for a specific monitoring task using the Fetch API. ```typescript const endpoint = process.env.LENX_ENDPOINT ?? "https://open.lenx.ai"; const taskId = 42; const res = await fetch(`${endpoint}/api/v1/tasks/${taskId}`, { headers: { "x-api-key": process.env.LENX_API_KEY!, "x-user-id": process.env.LENX_USER_ID!, }, }); const { data } = await res.json(); // data contains: task_id, task_name, owner_ac_id, task_type, indus_id, labels, // lang_abbr, status, region, created_at, updated_at, search_query console.log(`Task: ${data.task_name}, Status: ${data.status}`); console.log(`Search query:`, data.search_query); ``` -------------------------------- ### PATCH Request with query_layer Configuration Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/references/QUERY_LAYER.md Use this JSON structure to define search parameters including language, media sources, and specific inclusion/exclusion layers. Note that modifying query_layer will automatically trigger a regeneration of the query_string. ```json { "search_query": { "lang_abbr": ["en"], "list_medium": ["facebook", "news"], "query_layer": [ { "in": [["tesla", "byd"], ["battery", "charging"]], "ex": ["stock", "share price"] } ], "exclude_channel_links": true } } ``` -------------------------------- ### Fetch Task Monitoring Data Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Retrieve monitoring data for a specific task within a defined date range using Unix timestamps. ```http GET {endpoint}/api/v1/tasks/{task_id}/data ``` -------------------------------- ### POST /search Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/fasta-adhocsearch-api/SKILL.md Executes a search query against the FASTA AdHocSearch service to retrieve social media posts based on specified criteria. ```APIDOC ## POST {endpoint}/search ### Description Searches social media posts based on a query or keywords within a specified date range and country. ### Method POST ### Endpoint {endpoint}/search ### Parameters #### Request Body - **from** (number) - Required - Start of date range (Unix timestamp, seconds) - **to** (number) - Required - End of date range (Unix timestamp, seconds) - **size** (number) - Required - Number of results to return (1–1000) - **query** (string) - Optional - Phrase search (max 50 chars). Mutually exclusive with keywords. - **keywords** (string[]) - Optional - Keyword search, any-match (max 20 items, each max 50 chars). Mutually exclusive with query. - **search_after** (number) - Optional - Cursor for pagination (unix_timestamp of the last result from the previous page) - **country** (string) - Optional - Filter by country code ### Request Example { "query": "climate change", "from": 1711929600, "to": 1714521600, "size": 10 } ### Response #### Success Response (200) - **data** (array) - List of post objects containing metadata, content, and engagement metrics. #### Response Example { "data": [ { "hash": "string", "post_message": "string", "unix_timestamp": 1234567890 } ] } ``` -------------------------------- ### Define Complex Search Logic Source: https://context7.com/thinkcol/fasta-skills/llms.txt Demonstrates the JSON structure for query layers, supporting OR, AND-of-OR, and exclusion logic. ```json // Simple OR: Match posts containing "tesla" OR "byd" [{ "in": ["tesla", "byd"] }] // Result: (tesla) OR (byd) // Grouped AND/OR: Match (EV or electric vehicle) AND (battery or charging) [{ "in": [["ev", "electric vehicle"], ["battery", "charging"]] }] // Result: ((ev) OR (electric vehicle)) AND ((battery) OR (charging)) // Include with exclusions: Apple content excluding fruit results [{ "in": ["apple"], "ex": ["fruit", "recipe", "pie"] }] // Result: ((apple)) AND NOT ((fruit) OR (recipe) OR (pie)) // Multiple alternatives: Match EV topic OR solar topic [ { "in": [["ev", "electric vehicle"], ["battery"]] }, { "in": [["solar", "photovoltaic"], ["panel"]] } ] // Result: (EV AND battery) OR (solar AND panel) // Complex grouped query: AI agents with automation, excluding job ads [ { "in": [["ai agent", "copilot"], ["automation", "workflow"]], "ex": [["job", "jobs", "hiring"]] } ] // Result: ((ai agent) OR (copilot)) AND ((automation) OR (workflow)) AND NOT ((job) OR (jobs) OR (hiring)) ``` -------------------------------- ### Delete Task Response (200 OK) Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Successful response after deleting a task. ```json { "data": { "task_id": 123, "deleted": true } } ``` -------------------------------- ### API Endpoint Definition Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/fasta-adhocsearch-api/SKILL.md The base endpoint for performing search requests. ```text POST {endpoint}/search ``` -------------------------------- ### Update Task Configuration Source: https://context7.com/thinkcol/fasta-skills/llms.txt Modifies an existing task's name or search query parameters using a PATCH request. ```bash # Update task search query to monitor EV industry curl -s -X PATCH "${LENX_ENDPOINT:-https://open.lenx.ai}/api/v1/tasks/42" \ -H "x-api-key: $LENX_API_KEY" \ -H "x-user-id: $LENX_USER_ID" \ -H "Content-Type: application/json" \ -d '{ "task_name": "EV Industry Monitor", "search_query": { "lang_abbr": ["en"], "list_medium": ["facebook", "news", "forum"], "query_layer": [ { "in": [["tesla", "byd", "rivian"], ["battery", "charging", "ev"]], "ex": ["stock price", "share price", "investor"] } ], "exclude_channel_links": true } }' # Response (200 OK): # { "data": { "task_id": 42, "updated": true } } ``` -------------------------------- ### Search Social Media Posts with FASTA AdHocSearch Source: https://context7.com/thinkcol/fasta-skills/llms.txt Perform an ad-hoc search for posts using a query string and date range via cURL. ```bash # Search for posts containing "climate change" in the last 30 days curl -X POST "${ADHOCSEARCH_ENDPOINT:-https://adhocsearch.fasta.ai}/search" \ -H "Content-Type: application/json" \ -H "x-api-key: $ADHOCSEARCH_API_KEY" \ -H "x-user-id: $ADHOCSEARCH_USER_ID" \ -d '{ "query": "climate change", "from": 1711929600, "to": 1714521600, "size": 10 }' ``` -------------------------------- ### PATCH /api/v1/tasks/{task_id} Source: https://context7.com/thinkcol/fasta-skills/llms.txt Update a task's name or search configuration. ```APIDOC ## PATCH /api/v1/tasks/{task_id} ### Description Update a task's name or search configuration. The `query_layer` provides structured search logic. ### Method PATCH ### Endpoint /api/v1/tasks/{task_id} ### Parameters #### Path Parameters - **task_id** (integer) - Required - The ID of the task to update. ### Request Body - **task_name** (string) - Optional - New name for the task. - **search_query** (object) - Optional - Updated search configuration. ``` -------------------------------- ### POST /search Source: https://context7.com/thinkcol/fasta-skills/llms.txt Search for social media posts using query phrases or keywords within a specific date range. ```APIDOC ## POST /search ### Description Enables searching social media posts by query phrases or keywords within a specified date range. Supports filtering by country and returns post data including engagement metrics. ### Method POST ### Endpoint /search ### Parameters #### Request Body - **query** (string) - Optional - The search phrase. - **keywords** (array) - Optional - List of keywords for any-match search. - **from** (integer) - Required - Start timestamp. - **to** (integer) - Required - End timestamp. - **size** (integer) - Required - Number of results to return. - **search_after** (integer) - Optional - Unix timestamp of the last result for pagination. ### Request Example { "query": "climate change", "from": 1711929600, "to": 1714521600, "size": 10 } ### Response #### Success Response (200) - **data** (array) - List of post objects containing hash, country, lang_abbr, medium, channel, post_message, post_timestamp, unix_timestamp, author_name, reaction_count, share_count, and comment_count. ``` -------------------------------- ### Update Task API Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Update an existing task with partial updates. ```APIDOC ## PATCH /api/v1/tasks/{task_id} ### Description Update an existing task with partial updates. At least one of `task_name` or `search_query` must be provided. ### Method PATCH ### Endpoint {endpoint}/api/v1/tasks/{task_id} ### Parameters #### Path Parameters - **task_id** (number) - Required - The ID of the task to update #### Request Body - **task_name** (string) - Optional - 1–50 characters - **search_query** (object) - Optional - Search query configuration - **lang_abbr** (string | null) - Optional - **region** (string | null) - Optional - **list_medium** (string[]) - Optional - **list_author_id** (string[]) - Optional - **query_layer** (EQLayer[] | null) - Optional - Structured search logic. Pass `null` to clear. > **Validation:** At least one of `task_name` or `search_query` must be provided. If `search_query` is provided, it must contain at least one field. Sending an empty body is invalid. ### Request Example ```json { "task_name": "Updated Task Name", "search_query": { "list_medium": ["News", "Blog"] } } ``` ### Response #### Success Response (200 OK) - **task_id** (number) - The ID of the updated task - **updated** (boolean) - Indicates if the task was updated #### Response Example ```json { "data": { "task_id": 123, "updated": true } } ``` ### Errors - **400**: Invalid request body (validation failed, or `query_layer` could not be converted — `INVALID_QUERY_LAYER`) - **401**: Missing `x-user-id` header - **403**: User does not have permission to access this task - **404**: Task not found or Search query not found for this task - **500**: Unexpected error ``` -------------------------------- ### Delete Monitoring Task Source: https://context7.com/thinkcol/fasta-skills/llms.txt Performs a soft-delete on a task, restricted to the task owner. ```bash # Delete a monitoring task curl -s -X DELETE "${LENX_ENDPOINT:-https://open.lenx.ai}/api/v1/tasks/42" \ -H "x-api-key: $LENX_API_KEY" \ -H "x-user-id: $LENX_USER_ID" # Response (200 OK): # { "data": { "task_id": 42, "deleted": true } } # Error responses: # 403: User is not the task owner ``` -------------------------------- ### PATCH /api/v1/tasks/{task_id} Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/references/QUERY_LAYER.md Updates a monitoring task by providing a new query_layer structure. The backend will regenerate the internal query_string based on this input. ```APIDOC ## PATCH /api/v1/tasks/{task_id} ### Description Updates the search logic for a specific monitoring task using the query_layer structure. ### Method PATCH ### Endpoint /api/v1/tasks/{task_id} ### Parameters #### Path Parameters - **task_id** (string) - Required - The unique identifier of the task to update. #### Request Body - **query_layer** (array) - Required - An array of EQLayer objects defining the search logic. Each EQLayer contains 'in' (terms to include) and 'ex' (terms to exclude) fields, which accept either string[] or string[][] types. ### Request Example { "query_layer": [ { "in": [["ai agent", "copilot"], ["automation", "workflow"]], "ex": [["job", "jobs", "hiring"]] } ] } ### Response #### Success Response (200) - **status** (string) - Confirmation of the update. #### Response Example { "status": "success" } ``` -------------------------------- ### Update Task API Endpoint Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Use PATCH to partially update an existing task. All fields in the body are optional, but at least one of `task_name` or `search_query` must be provided. ```http PATCH {endpoint}/api/v1/tasks/{task_id} ``` -------------------------------- ### Update Task Name using curl Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Use this `curl` command to update the name of an existing task. Ensure `LENX_ENDPOINT` and `LENX_API_KEY`, `LENX_USER_ID` environment variables are set. ```bash curl -s -X PATCH "${LENX_ENDPOINT:-https://open.lenx.ai}/api/v1/tasks/42" \ -H "x-api-key: $LENX_API_KEY" \ -H "x-user-id: $LENX_USER_ID" \ -H "Content-Type: application/json" \ -d '{"task_name": "New Task Name"}' ``` -------------------------------- ### API Response Schema Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/fasta-adhocsearch-api/SKILL.md The structure of the JSON response returned by the API. ```json { "data": [ { "hash": "string", "country": "string", "lang_abbr": "string", "medium": "string", "channel": "string", "channel_link": "string", "site": "string", "thread_link": "string", "post_link": "string", "thread_title": "string", "post_message": "string", "post_timestamp": "ISO 8601 datetime", "unix_timestamp": 1234567890, "author_name": "string", "author_id": "string | null", "author_image": "string | null", "author_link": "string | null", "is_comment": false, "comment_order": "number | null", "comment_count": "number | null", "share_count": "number | null", "view_count": "number | null", "reaction_count": "number | null", "reaction_like": "number | null", "reaction_dislike": "number | null", "reaction_love": "number | null", "reaction_wow": "number | null", "reaction_haha": "number | null", "reaction_angry": "number | null" } ] } ``` -------------------------------- ### DELETE /api/v1/tasks/{task_id} Source: https://context7.com/thinkcol/fasta-skills/llms.txt Soft-delete a monitoring task. ```APIDOC ## DELETE /api/v1/tasks/{task_id} ### Description Soft-delete a monitoring task. Only the task owner can perform deletion. ### Method DELETE ### Endpoint /api/v1/tasks/{task_id} ### Parameters #### Path Parameters - **task_id** (integer) - Required - The ID of the task to delete. ### Response #### Success Response (200) - **task_id** (integer) - The ID of the deleted task. - **deleted** (boolean) - Confirmation of deletion. ``` -------------------------------- ### Delete Task using curl Source: https://github.com/thinkcol/fasta-skills/blob/master/skills/open-lenx-api/SKILL.md Use this `curl` command to perform a soft delete on a task. This operation requires the task ID and authentication headers. Ensure environment variables for endpoint and authentication are set. ```bash curl -s -X DELETE "${LENX_ENDPOINT:-https://open.lenx.ai}/api/v1/tasks/42" \ -H "x-api-key: $LENX_API_KEY" \ -H "x-user-id: $LENX_USER_ID" ```