Skip to content

Conversation

@mikehostetler
Copy link

@mikehostetler mikehostetler commented Feb 7, 2026

Human here, super excited to try this API. I work in Elixir, so took it on myself to whip up a generated API client this morning. Went really well and I'm already integrating it with my stack!

Thanks for doing this!


AI Summary

Adds an Elixir target to the XDK generator, producing a complete, publishable Elixir SDK for the X API v2.

The generated package is published on Hex: xdk_elixir

What's included

Generator (Rust)

  • xdk-gen/src/elixir/ — Generator module using the language! macro with Elixir-appropriate casing
  • xdk-build/src/elixir.rs — CLI module (generates + runs mix format)
  • xdk-gen/templates/elixir/ — 12 Jinja2 templates:
    • main_client.j2 — Core Xdk client module (Finch-based HTTP, auth, response handling)
    • client_class.j2 — Per-tag API modules (Users, Posts, Lists, etc.)
    • errors.j2 — Structured error types via Splode
    • query.j2 — Query parameter encoding with CSV list support
    • paginator.j2 — Cursor-based pagination via Stream.resource/3
    • streaming.j2 — NDJSON streaming for filtered/sample streams
    • test_structure.j2 / test_helper.j2 — Bypass-based test scaffolding
    • mix_exs.j2 — Full mix.exs with Hex metadata, dialyzer, credo, quality alias
    • Static templates: formatter, gitignore, readme

Generated SDK features

  • Full coverage of X API v2 endpoints (~20 modules, 100+ functions)
  • Bearer token (OAuth 2.0 App-Only) authentication
  • OAuth 1.0a user-context authentication via OAuther
  • Rate limit detection with retry-after calculation
  • Lazy pagination streams
  • NDJSON streaming support
  • mix quality alias (compile warnings-as-errors, format, credo --strict, dialyzer)

Testing

  • 443 unit tests (Bypass-based, auto-generated) — all pass
  • 33 integration tests against the live X API (bearer + OAuth 1.0a user-context)
  • mix quality passes clean (compile, format, credo, dialyzer)
  • mix docs generates with zero warnings

Usage

# Generate the Elixir SDK
cargo run -- elixir --latest true

# Or via Make
make elixir
make test-elixir

mikehostetler and others added 6 commits February 7, 2026 09:35
Adds Elixir/Req-based SDK generation support to the XDK generator.
This includes templates, codegen module, and build integration.
Testing will begin shortly — not ready for a PR.

Amp-Thread-ID: https://ampcode.com/threads/T-019c38bc-09ad-7772-aabf-6ad3cbde05cb
Co-authored-by: Amp <amp@ampcode.com>
- Remove supervision tree (application.j2) — library no longer owns OTP processes
- Remove unused Zoi dependency
- Restructure errors: add RateLimitError, DecodeError, TransportError with context
- Add Xdk.Query module for proper CSV list encoding in query params
- Generate request body params for POST/PUT/DELETE endpoints (json: body)
- Generate streaming functions using Finch.stream/5 for stream endpoints
- Add Xdk.Streaming module for NDJSON stream consumption
- Add Xdk.Paginator module for cursor-based pagination
- Improve auth: support {:bearer, _} and {:oauth2, _}, per-request override
- Fix typespecs: default to String.t() instead of any() for path params
- Add Bypass-based integration tests (auth, error handling, rate limits)
- Update .gitignore to exclude generated elixir output

Amp-Thread-ID: https://ampcode.com/threads/T-019c38d2-bcb5-7195-927a-2787451bdcb5
Co-authored-by: Amp <amp@ampcode.com>
- Add {:oauth1, credentials} auth type to client
- Sign requests with HMAC-SHA1 inside request/4 where method+URL are known
- Add oauther ~> 1.3 as dependency
- Add .env to gitignore template

Amp-Thread-ID: https://ampcode.com/threads/T-019c38ef-224f-775a-b955-714dfa4e5243
Co-authored-by: Amp <amp@ampcode.com>
- mix_exs.j2: add Hex metadata, dialyzer, credo, ex_doc, quality alias, rename to xdk_elixir
- errors.j2: add @moduledoc to all modules
- gitignore.j2: add PLT, coverage, editor entries
- Bump elixir version to 1.0.0 in xdk-config.toml

Amp-Thread-ID: https://ampcode.com/threads/T-019c390a-abe3-726d-a4a1-9cfc2522667b
Co-authored-by: Amp <amp@ampcode.com>
- streaming.j2: add @moduledoc (was hidden)
- errors.j2: use Exception.t() instead of Splode macro types, drop UnknownError from typedoc

Amp-Thread-ID: https://ampcode.com/threads/T-019c390a-abe3-726d-a4a1-9cfc2522667b
Co-authored-by: Amp <amp@ampcode.com>
@CLAassistant
Copy link

CLAassistant commented Feb 7, 2026

CLA assistant check
All committers have signed the CLA.

@mikehostetler mikehostetler marked this pull request as ready for review February 7, 2026 17:22
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.

2 participants