Skip to content

[T2.3] Build lib/airdrop/twitterapi.ts (lookupXUser) #1238

Description

@realproject7

Epic: #1229 · Spec: §3.2, §6.3 · Type: CODE · Estimate: 0.3 day · Depends on: T0.1

Scope

Create lib/airdrop/twitterapi.ts exporting:

```ts
export async function lookupXUser(username: string): Promise<{
display_name: string;
avatar_url: string;
follower_count: number;
x_user_id: string;
bio_snippet: string;
} | null>
```

  • Single twitterapi.io call: GET /v2/users/by/username/{username}
  • Cache: 5-min in-memory LRU keyed by username (covers retries/debouncing only, not cross-user dedup — cost is $0.0003/call, marginal gain)
  • Handle 404 → return null
  • Handle 5xx / network errors → throw (callers handle R16 graceful degradation)
  • Use process.env.TWITTERAPI_IO_KEY

Acceptance

  • Successful lookup returns shape above
  • 404 returns null
  • 5xx throws
  • LRU cache hit on second call within 5 min (verify via test)
  • No call made if cache hit

Dependencies

T0.1 (API key in env)

Metadata

Metadata

Assignees

No one assigned

    Labels

    airdropPLOT 10x Airdrop Campaign

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions