Skip to content

Add Xquik X/Twitter research tools#5784

Open
kriptoburak wants to merge 2 commits into
crewAIInc:mainfrom
kriptoburak:codex/add-xquik-crewai-tools
Open

Add Xquik X/Twitter research tools#5784
kriptoburak wants to merge 2 commits into
crewAIInc:mainfrom
kriptoburak:codex/add-xquik-crewai-tools

Conversation

@kriptoburak
Copy link
Copy Markdown

@kriptoburak kriptoburak commented May 12, 2026

Summary

  • Adds five Xquik REST API tools for public X/Twitter research workflows:
    • XquikSearchTweetsTool
    • XquikGetTweetTool
    • XquikGetUserTool
    • XquikGetUserTweetsTool
    • XquikGetTrendsTool
  • Exposes the tools from crewai_tools and crewai_tools.tools.
  • Adds offline mocked tests for request construction, authentication, validation, errors, and optional parameters.
  • Adds English, Portuguese, Korean, and Arabic docs pages plus docs navigation entries.

Duplicate and policy checks

  • Checked the target repository default branch for existing Xquik, x-twitter-scraper, Xquik-dev, xquik.com, and TweetClaw entries.
  • Checked open and closed target PRs and issues for the same names and URLs.
  • Followed the existing tool package pattern and the repository docs parity guidance.

Validation

  • uv run ruff check lib/
  • uv run ruff format --check lib/
  • cd lib/crewai-tools && uv run pytest tests/tools/xquik_tool_test.py -q
  • ruby -e 'require "json"; JSON.parse(File.read("docs/docs.json"))'
  • npx -y -p node@22 -p mintlify sh -c 'yes "" | mintlify broken-links || test $? -eq 141'
  • git diff --cached --check

Summary by CodeRabbit

  • New Features

    • Added Xquik Tools: search tweets, fetch tweets, view user profiles, browse user timelines, and discover regional trends.
  • Documentation

    • Added detailed Xquik docs and overview cards across locales (en, pt-BR, ko, ar), updated site index, README, and fixed a Python code-block closing line in examples.
  • Tests

    • Added tests covering tool behavior, input validation, HTTP interactions, and error handling.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 73f6527a-6378-4b99-8e07-a377176dab43

📥 Commits

Reviewing files that changed from the base of the PR and between 0f5c31d and fdda792.

📒 Files selected for processing (16)
  • docs/ar/tools/search-research/overview.mdx
  • docs/ar/tools/search-research/xquiktool.mdx
  • docs/docs.json
  • docs/en/tools/search-research/overview.mdx
  • docs/en/tools/search-research/xquiktool.mdx
  • docs/ko/tools/search-research/overview.mdx
  • docs/ko/tools/search-research/xquiktool.mdx
  • docs/pt-BR/tools/search-research/overview.mdx
  • docs/pt-BR/tools/search-research/xquiktool.mdx
  • lib/crewai-tools/README.md
  • lib/crewai-tools/src/crewai_tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/xquik_tool/README.md
  • lib/crewai-tools/src/crewai_tools/tools/xquik_tool/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/xquik_tool/xquik_tool.py
  • lib/crewai-tools/tests/tools/xquik_tool_test.py
✅ Files skipped from review due to trivial changes (7)
  • docs/en/tools/search-research/overview.mdx
  • docs/pt-BR/tools/search-research/overview.mdx
  • lib/crewai-tools/src/crewai_tools/tools/xquik_tool/init.py
  • lib/crewai-tools/src/crewai_tools/tools/xquik_tool/README.md
  • docs/ko/tools/search-research/overview.mdx
  • docs/en/tools/search-research/xquiktool.mdx
  • docs/docs.json
🚧 Files skipped from review as they are similar to previous changes (7)
  • lib/crewai-tools/README.md
  • docs/ar/tools/search-research/overview.mdx
  • lib/crewai-tools/src/crewai_tools/tools/init.py
  • lib/crewai-tools/src/crewai_tools/init.py
  • lib/crewai-tools/tests/tools/xquik_tool_test.py
  • docs/ko/tools/search-research/xquiktool.mdx
  • lib/crewai-tools/src/crewai_tools/tools/xquik_tool/xquik_tool.py

📝 Walkthrough

Walkthrough

Adds a new Xquik X/Twitter tools integration: five REST-backed tools, Pydantic schemas, a shared authenticated base client, package exports, tests, READMEs, localized MDX docs and overview cards, and updates docs manifest and repo README.

Changes

Xquik X/Twitter Tool Integration

Layer / File(s) Summary
Core client, helpers, and constants
lib/crewai-tools/src/crewai_tools/tools/xquik_tool/xquik_tool.py
Adds DEFAULT_XQUIK_BASE_URL, XQUIK_API_CONTRACT, helper functions (drop empty params, validate ranges, normalize path ids, require non-empty text, build error bodies).
Authenticated request base
lib/crewai-tools/src/crewai_tools/tools/xquik_tool/xquik_tool.py
Adds XquikToolBase(BaseTool) handling API key resolution (explicit or XQUIK_API_KEY), base URL/timeout normalization, headers (incl. x-api-key, xquik-api-contract), _get() with JSON parsing and structured error wrapping.
Input schemas
lib/crewai-tools/src/crewai_tools/tools/xquik_tool/xquik_tool.py
Adds Pydantic models: XquikSearchTweetsToolSchema, XquikGetTweetToolSchema, XquikGetUserToolSchema, XquikGetUserTweetsToolSchema, XquikGetTrendsToolSchema with field constraints and enums.
Tool implementations (behavior mapping -> endpoints)
lib/crewai-tools/src/crewai_tools/tools/xquik_tool/xquik_tool.py
Implements tool classes and _run methods for: search (/x/tweets/search), get tweet (/x/tweets/{id}), get user (/x/users/{user}), user tweets (/x/users/{user}/tweets with cursor and flags), trends (/x/trends). Normalizes inputs and delegates to XquikToolBase._get.
Package exports and wiring
lib/crewai-tools/src/crewai_tools/tools/xquik_tool/__init__.py, lib/crewai-tools/src/crewai_tools/tools/__init__.py, lib/crewai-tools/src/crewai_tools/__init__.py
Imports and re-exports the five Xquik* tool classes via __all__ at subpackage, tools package, and root package levels.
Tool README and repo README update
lib/crewai-tools/src/crewai_tools/tools/xquik_tool/README.md, lib/crewai-tools/README.md
Adds Xquik tools README (setup, API key, example) and updates the repo README's Available Tools list to include new Xquik tools.
Tests: behavior and error handling
lib/crewai-tools/tests/tools/xquik_tool_test.py
New pytest suite: autouse fixture sets XQUIK_API_KEY, helper _mock_response, tests for env/explicit instantiation, missing-key errors, request URL/headers/params (including encoding and stripped @), optional flag forwarding, validation (empty query, out-of-range), API non-2xx error wrapping and request exception wrapping.
Localized documentation and overview cards
docs/en/tools/search-research/xquiktool.mdx, docs/ar/.../xquiktool.mdx, docs/ko/.../xquiktool.mdx, docs/pt-BR/.../xquiktool.mdx, docs/*/tools/search-research/overview.mdx
Adds localized MDX pages describing the Xquik tools (frontmatter, installation, XQUIK_API_KEY, tool list, direct and Agent usage examples, parameter docs) and inserts Xquik overview cards into each locale's tools grid.
Docs manifest registration
docs/docs.json
Adds "*/tools/search-research/xquiktool" entries to locale-specific tool arrays (inserted after GitHub search tool entries).

Sequence Diagram

sequenceDiagram
  autonumber
  participant Agent as Agent (caller)
  participant Tool as XquikTool (in-process)
  participant Env as Env / Config
  participant Xquik as Xquik API (external)

  Agent->>Tool: Instantiate (api_key? / uses Env)
  Env-->>Tool: Provide XQUIK_API_KEY (if not explicit)
  Agent->>Tool: .run(args)
  Tool->>Xquik: HTTP GET /x/... with headers (x-api-key, xquik-api-contract) and query/path params
  Xquik-->>Tool: 200 + JSON OR non-2xx/error body
  Tool->>Agent: return JSON or raise RuntimeError (includes HTTP status and body)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • greysonlalonde
  • lorenzejay

Poem

🐇 I hop the feeds with eager cheer,
Five Xquik paws fetch tweets so near.
Keys and headers snugly dressed,
Tests and docs make work well-dressed.
A little rabbit clicks—now search, dear!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.70% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add Xquik X/Twitter research tools' directly and clearly describes the main change: adding five Xquik research tools (XquikSearchTweetsTool, XquikGetTweetTool, XquikGetUserTool, XquikGetUserTweetsTool, XquikGetTrendsTool) for X/Twitter data research to the CrewAI tools library.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
lib/crewai-tools/README.md (1)

29-29: ⚡ Quick win

Expand the API integrations list to include all new Xquik tools.

Only XquikSearchTweetsTool is listed, while this PR ships five Xquik tools. Updating this line improves discoverability.

💡 Suggested update
-- **API Integrations**: `SerperApiTool`, `ExaSearchTool`, `XquikSearchTweetsTool`
+- **API Integrations**: `SerperApiTool`, `ExaSearchTool`, `XquikSearchTweetsTool`, `XquikGetTweetTool`, `XquikGetUserTool`, `XquikGetUserTweetsTool`, `XquikGetTrendsTool`
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/crewai-tools/README.md` at line 29, Update the README line that lists API
integrations to include all five Xquik tool class names (not just
XquikSearchTweetsTool); locate the entry in lib/crewai-tools/README.md where
"API Integrations" mentions `XquikSearchTweetsTool` and add the other four Xquik
tool symbols (use the exact exported class names as defined in the diff) so the
line enumerates all Xquik tools alongside `SerperApiTool` and `ExaSearchTool`,
preserving the same inline code formatting and comma-separated style.
lib/crewai-tools/tests/tools/xquik_tool_test.py (1)

87-95: ⚡ Quick win

Strengthen encoding assertions with non-safe identifiers.

Line 87 and Line 98 claim path encoding behavior, but current inputs ("123", "crew_ai") don’t require encoding. Add at least one case with reserved characters (e.g., spaces, /, ?, %) to verify actual percent-encoding and avoid false confidence in these tests.

Also applies to: 98-106

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/crewai-tools/tests/tools/xquik_tool_test.py` around lines 87 - 95, The
test test_get_tweet_encodes_tweet_id currently uses safe identifiers ("123") so
it doesn't verify URL percent-encoding; update this test (and the analogous one
around lines 98-106 that checks user id encoding) to include at least one case
with reserved characters (e.g., a tweet_id/user_id containing space, "/", "?",
"%") and assert the HTTP GET URL built by XquikGetTweetTool.run (and the user-id
test's tool) contains the percent-encoded form (and not the raw reserved
characters); locate the code that inspects mock_get.call_args.args[0] and add
assertions for the encoded substring (and/or absence of the raw substring) to
prove real percent-encoding is applied.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/crewai-tools/src/crewai_tools/tools/xquik_tool/xquik_tool.py`:
- Around line 183-186: The woeid Field is unbounded and can be 0/negative; add
input validation so callers get a clear error before the API call. Update the
woeid Field declaration(s) (the woeid in the model around the shown block and
the similar Field at the later block) to require a minimum of 1 (e.g.,
Field(..., ge=1, description=...)) or add a pydantic `@validator`("woeid") that
raises ValueError if value < 1, and include a clear message like "woeid must be
>= 1 (use 1 for worldwide)". Ensure both occurrences use the same validation
approach.
- Around line 30-35: The function _normalize_path_identifier currently allows
values like "@" because cleaned.lstrip("@") can become empty; update the
validation to reject identifiers that become empty after stripping leading "@"
by computing stripped = cleaned.lstrip("@") and raising ValueError(f"{name} is
required") if not stripped before calling quote, so the function returns
quote(stripped, safe="") only for non-empty identifiers.

---

Nitpick comments:
In `@lib/crewai-tools/README.md`:
- Line 29: Update the README line that lists API integrations to include all
five Xquik tool class names (not just XquikSearchTweetsTool); locate the entry
in lib/crewai-tools/README.md where "API Integrations" mentions
`XquikSearchTweetsTool` and add the other four Xquik tool symbols (use the exact
exported class names as defined in the diff) so the line enumerates all Xquik
tools alongside `SerperApiTool` and `ExaSearchTool`, preserving the same inline
code formatting and comma-separated style.

In `@lib/crewai-tools/tests/tools/xquik_tool_test.py`:
- Around line 87-95: The test test_get_tweet_encodes_tweet_id currently uses
safe identifiers ("123") so it doesn't verify URL percent-encoding; update this
test (and the analogous one around lines 98-106 that checks user id encoding) to
include at least one case with reserved characters (e.g., a tweet_id/user_id
containing space, "/", "?", "%") and assert the HTTP GET URL built by
XquikGetTweetTool.run (and the user-id test's tool) contains the percent-encoded
form (and not the raw reserved characters); locate the code that inspects
mock_get.call_args.args[0] and add assertions for the encoded substring (and/or
absence of the raw substring) to prove real percent-encoding is applied.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b7366df4-4d6d-45b9-9aa7-36644bf15b67

📥 Commits

Reviewing files that changed from the base of the PR and between 264da82 and 206a348.

📒 Files selected for processing (16)
  • docs/ar/tools/search-research/overview.mdx
  • docs/ar/tools/search-research/xquiktool.mdx
  • docs/docs.json
  • docs/en/tools/search-research/overview.mdx
  • docs/en/tools/search-research/xquiktool.mdx
  • docs/ko/tools/search-research/overview.mdx
  • docs/ko/tools/search-research/xquiktool.mdx
  • docs/pt-BR/tools/search-research/overview.mdx
  • docs/pt-BR/tools/search-research/xquiktool.mdx
  • lib/crewai-tools/README.md
  • lib/crewai-tools/src/crewai_tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/xquik_tool/README.md
  • lib/crewai-tools/src/crewai_tools/tools/xquik_tool/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/xquik_tool/xquik_tool.py
  • lib/crewai-tools/tests/tools/xquik_tool_test.py

Comment thread lib/crewai-tools/src/crewai_tools/tools/xquik_tool/xquik_tool.py
Comment thread lib/crewai-tools/src/crewai_tools/tools/xquik_tool/xquik_tool.py
@kriptoburak kriptoburak force-pushed the codex/add-xquik-crewai-tools branch from 0f5c31d to fdda792 Compare May 14, 2026 21:32
@kriptoburak
Copy link
Copy Markdown
Author

Maintenance update after the branch fell behind main.

I rebased the PR on current crewAIInc/crewAI main and force-pushed head fdda792f945ccf1cf2362224f965cca8eb141c32. GitHub still shows the same 16 changed files, CodeRabbit is green, and the review remains approved.

Focused local validation passed: Ruff format check, Ruff lint, Xquik tool pytest (11 passed), docs JSON parse, and Git diff whitespace check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant