> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xquik.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Analyze & cache style

> Fetch and cache recent tweets from an X account for style analysis

<blockquote className="agent-llms-directive">
  For the complete documentation index, see <a href="/llms.txt">llms.txt</a>.
</blockquote>

<Callout icon="circle-check" color="#16a34a">
  **Free** - does not consume credits
</Callout>

<Info>
  This endpoint uses a two-tier system. If a cached style exists and is less than 7 days old, it returns cached data for free. If no cache exists or the cache is older than 7 days, it auto-refreshes from X (subscription required, consumes usage).
</Info>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://xquik.com/api/v1/styles \
    -H "x-api-key: xq_YOUR_KEY_HERE" \
    -H "Content-Type: application/json" \
    -d '{
      "username": "elonmusk"
    }' | jq
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://xquik.com/api/v1/styles", {
    method: "POST",
    headers: {
      "x-api-key": "xq_YOUR_KEY_HERE",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      username: "elonmusk",
    }),
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://xquik.com/api/v1/styles",
      headers={"x-api-key": "xq_YOUR_KEY_HERE"},
      json={"username": "elonmusk"},
  )
  data = response.json()
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      body, _ := json.Marshal(map[string]interface{}{
          "username": "elonmusk",
      })

      req, err := http.NewRequest("POST", "https://xquik.com/api/v1/styles", bytes.NewReader(body))
      if err != nil {
          panic(err)
      }
      req.Header.Set("x-api-key", "xq_YOUR_KEY_HERE")
      req.Header.Set("Content-Type", "application/json")

      resp, err := http.DefaultClient.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      var data map[string]interface{}
      if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
          panic(err)
      }
      fmt.Println(data)
  }
  ```
</CodeGroup>

## Headers

<ParamField header="x-api-key" type="string" required>
  Your API key. Session cookie authentication is also supported. Generate a key from the [dashboard](https://xquik.com/dashboard).
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be `application/json`.
</ParamField>

## Body

<ParamField body="username" type="string" required>
  X username to analyze. 1-15 characters, alphanumeric and underscores only.
</ParamField>

## Response

<Tabs>
  <Tab title="200 OK (cached)">
    Returns cached style data when a fresh cache exists (less than 7 days old). Same response shape as 201 Created.

    <ResponseField name="xUsername" type="string">Normalized X username (lowercase, no `@` prefix).</ResponseField>
    <ResponseField name="tweetCount" type="number">Number of tweets fetched and cached.</ResponseField>
    <ResponseField name="isOwnAccount" type="boolean">`true` if the user has set their [X identity](/api-reference/account/x-identity) to this account.</ResponseField>
    <ResponseField name="fetchedAt" type="string">ISO 8601 timestamp when tweets were fetched from X.</ResponseField>
    <ResponseField name="tweets" type="object[]">Array of cached tweets.</ResponseField>
  </Tab>

  <Tab title="201 Created">
    <ResponseField name="xUsername" type="string">Normalized X username (lowercase, no `@` prefix).</ResponseField>
    <ResponseField name="tweetCount" type="number">Number of tweets fetched and cached.</ResponseField>
    <ResponseField name="isOwnAccount" type="boolean">`true` if the user has set their [X identity](/api-reference/account/x-identity) to this account.</ResponseField>
    <ResponseField name="fetchedAt" type="string">ISO 8601 timestamp when tweets were fetched from X.</ResponseField>
    <ResponseField name="tweets" type="object[]">Array of cached tweets.</ResponseField>

    Each tweet object contains:

    * `id` (string) - Tweet ID
    * `text` (string) - Tweet text content
    * `authorUsername` (string) - Author's X username
    * `createdAt` (string) - ISO 8601 timestamp
    * `media` (object\[], optional) - Media objects attached to the tweet

    ```json theme={null}
    {
      "xUsername": "elonmusk",
      "tweetCount": 20,
      "isOwnAccount": false,
      "fetchedAt": "2026-02-24T10:30:00.000Z",
      "tweets": [
        {
          "id": "1893456789012345678",
          "text": "The future is now.",
          "authorUsername": "elonmusk",
          "createdAt": "2026-02-24T14:22:00.000Z"
        }
      ]
    }
    ```
  </Tab>

  <Tab title="400 Invalid Input">
    ```json theme={null}
    { "error": "invalid_input", "message": "Invalid or missing username" }
    ```

    Invalid or missing username. Provide a valid X username.
  </Tab>

  <Tab title="401 Unauthenticated">
    ```json theme={null}
    { "error": "unauthenticated", "message": "Missing or invalid API key" }
    ```

    Missing or invalid API key.
  </Tab>

  <Tab title="402 Subscription Required">
    Possible error codes:

    * `no_subscription` - No active subscription
    * `no_cached_style` - No cached style available and subscription required to fetch new data
    * `subscription_inactive` - Subscription is inactive or cancelled
    * `insufficient_credits` - Insufficient credits

    ```json theme={null}
    { "error": "no_subscription", "message": "No active subscription" }
    ```

    Subscribe from the [dashboard](https://xquik.com/dashboard).
  </Tab>

  <Tab title="429 Rate Limited">
    ```json theme={null}
    { "error": "rate_limit_exceeded", "message": "Too many requests. Try again later.", "retryAfter": 60 }
    ```

    Too many requests. Wait for the `Retry-After` header before retrying.
  </Tab>
</Tabs>

<Tip>
  If a cached style exists but your subscription has lapsed, the cached data is returned with a 200 response instead of a 402 error.
</Tip>

<Info>
  If a cached style already exists for this username, it will be replaced with fresh data.
</Info>

<Note>
  **Next steps:** [List Styles](/api-reference/styles/list) to see all cached styles, [Get Style](/api-reference/styles/get) to retrieve a specific style, or [Analyze Performance](/api-reference/styles/performance) to fetch engagement metrics for cached tweets.
</Note>
