8000 GitHub - KiVixx/ASKGROK: ASKGROK backend API that drives a logged-in Grok browser session for prompts and crypto sentiment research. · GitHub
[go: up one dir, main page]

Skip to content
KiVixxPublic

About

ASKGROK backend API that drives a logged-in Grok browser session for prompts and crypto sentiment research.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

ASKGROK

中文说明

ASKGROK is a small backend API that opens a real browser, lets the user log in to grok.com, sends prompts through the chat box, waits for the answer, and returns the response text from the backend.

Runtime Requirements

  • Node.js 20+
  • npm 10+
  • Playwright Chromium
  • Network access to https://grok.com
  • A Grok account
  • A headed browser environment for the initial login
  • macOS, Linux, and Windows should work in principle, but the current development environment is macOS on Apple Silicon

ASKGROK is not an official Grok API client. It uses Playwright to automate a real browser session. Headless or server-only environments may require extra browser display setup such as Xvfb.

Setup

npm install
npx playwright install chromium
npm start

By default the API listens on http://localhost:3000.

Environment Variables

Variable Default Description
PORT 3000 API server port.
HEADLESS false Run the browser headlessly. First login usually requires false.
GROK_PROFILE_DIR .askgrok-profile Persistent browser profile directory.
GROK_URL https://grok.com Grok web URL.

Login

Open a browser session for manual Grok login:

curl -X POST http://localhost:3000/login

A browser window will open at https://grok.com. Log in normally. ASKGROK stores the session in .askgrok-profile/, so you usually only need to do this once.

Ask

curl -X POST http://localhost:3000/ask \
  -H 'Content-Type: application/json' \
  -d '{"prompt":"Explain quantum computing in one paragraph."}'

Response:

{
  "response": "..."
}

API

GET /health

Returns server status.

POST /login

Launches or reuses a headed browser window and navigates to Grok for manual login.

POST /ask

Body:

{
  "prompt": "Your question",
  "timeoutMs": 120000
}

timeoutMs is optional. Requests are handled one at a time so Grok conversations do not overlap.

If a Grok browser session is already open, ASKGROK asks in the current session instead of navigating back to a new chat. It only opens or navigates to Grok when no usable Grok page exists.

POST /sentiment/crypto

Runs the structured ASKGROK crypto sentiment prompt and returns normalized JSON for the ETL pipeline. Grok can use web/search context freely, including X/Twitter, news, market commentary, forums, blogs, and price context.

Body:

{
  "startUtc": "2022-05-20T00:00:00Z",
  "endUtc": "2022-05-20T01:00:00Z",
  "assets": ["BTC", "ETH", "LUNA", "UST"],
  "timeoutMs": 180000,
  "includeRaw": false
}

Example:

curl -X POST http://localhost:3000/sentiment/crypto \
  -H 'Content-Type: application/json' \
  -d '{"startUtc":"2022-05-20T00:00:00Z","endUtc":"2022-05-20T01:00:00Z","assets":["BTC","ETH","LUNA","UST"],"timeoutMs":180000}'

POST /sentiment/x-crypto remains available as a backward-compatible alias.

Response:

{
  "sentiment": {
    "timestamp_utc": "2022-05-20T00:00:00.000Z",
    "window_end_utc": "2022-05-20T01:00:00.000Z",
    "source": "ASKGROK_WEB"
6656
,
    "data_scope": "web_research",
    "market": "crypto",
    "assets": ["BTC", "ETH", "LUNA", "UST"],
    "sentiment_score": -0.7,
    "sentiment_label": "fear",
    "confidence": 0.65,
    "social_volume_proxy": null,
    "bullish_intensity": 0.1,
    "bearish_intensity": 0.8,
    "fear_intensity": 0.85,
    "fomo_intensity": 0.05,
    "uncertainty_intensity": 0.75,
    "dominant_emotions": ["fear", "uncertainty"],
    "dominant_topics": ["Terra collapse", "Bitcoin drawdown"],
    "notable_terms": ["capitulation", "bear market"],
    "evidence_sources": ["X/Twitter", "market news", "price context"],
    "evidence_summary": "...",
    "sample_size_estimate": null,
    "limitations": "..."
  }
}

POST /close

Closes the browser context.

Notes

  • The browser runs in headed mode because login requires user interaction.
  • If Grok changes its web UI, selectors may need adjustment in src/grokClient.js.
  • Use this with your own account and follow Grok's terms and rate limits.

About

ASKGROK backend API that drives a logged-in Grok browser session for prompts and crypto sentiment research.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0