Generate Elixir raw API modules from Bybit's official QuickStartWithPostman collections.
This project is a thin generated REST layer:
- clone or update
bybit-exchange/QuickStartWithPostman; - parse Postman collection files under
V5APIs; - generate Elixir modules under
lib/bybit/api/**; - build signed and unsigned Bybit REST requests;
- provide small IEx helpers for manual checks.
- Elixir
~> 1.19 - Mix
- Network access to GitHub and Bybit endpoints
mix deps.get
mix compilemix pull_repoThis clones or updates the upstream repository into lib/bybit_api_postman_repo.
Generate all Bybit V5 and Tax V3 modules:
mix generate_raw_api --allGenerate from one collection file:
BybitApiPostmanEx.generate_raw_api("lib/bybit_api_postman_repo/V5APIs/Open API V5.postman_collection.json")Generated modules are written under:
lib/bybit/api/
├── open_api_v5/
│ ├── market.ex
│ ├── order.ex
│ ├── account.ex
│ └── ...
└── tax_v3/
└── tax_v3.ex
Example raw calls:
client = Bybit.Client.new("api_key", "api_secret", :testnet)
Bybit.API.OpenApiV5.Market.get_bybit_server_time_v5(client)
Bybit.API.OpenApiV5.Market.get_tickers_v5(client, "linear", "BTC")
Bybit.API.OpenApiV5.Market.get_orderbook_v5(client, "linear", "BTCUSDT", "25")
Bybit.API.OpenApiV5.Account.get_wallet_balance_v5(client, "UNIFIED")
Bybit.API.OpenApiV5.Order.place_order_linear_market_order_create(client,
body: %{
category: "linear",
symbol: "BTCUSDT",
side: "Buy",
orderType: "Market",
qty: "0.001"
}
)For local manual testing, copy .env.example to .env and fill in credentials:
BYBIT_API_KEY=your_api_key
BYBIT_API_SECRET=your_api_secret
BYBIT_ENV=testnetSupported environment values are prod / prod_url and testnet / testnet_url.
Start IEx from the project directory:
iex -S mixThe .iex.exs file aliases BybitApiPostmanEx and Bybit.Example, then prints the common commands.
For manual testing, reduce log verbosity before calling signed endpoints so request signatures and API keys are not printed:
Logger.configure(level: :info)Public market examples:
Bybit.Example.server_time()
Bybit.Example.market_tickers("linear", "BTC")
Bybit.Example.orderbook("linear", "BTCUSDT", "25")Signed account example:
Bybit.Example.wallet_balance("UNIFIED")Testnet order example:
Bybit.Example.place_order(%{
category: "linear",
symbol: "BTCUSDT",
side: "Buy",
orderType: "Market",
qty: "0.001"
})The order example sends a real request to the configured environment. Use BYBIT_ENV=testnet unless you explicitly intend to trade on production.
The generated raw API functions call:
Bybit.RequestBuilderto build URLs, headers and BybitX-BAPI-*signatures;Bybit.REST.HTTPClientto execute requests throughReq.
For signed Bybit endpoints, the request builder signs:
- GET:
timestamp + api_key + recv_window + query_string; - non-GET:
timestamp + api_key + recv_window + raw_body.
mix test