glupbit/client
HTTP client infrastructure with two-tier authentication.
PublicClient — quotation (market data) endpoints, no auth needed.
AuthClient — all endpoints including exchange (JWT required).
The Gleam type system statically prevents calling exchange endpoints
with a PublicClient.
Types
Authenticated client — can reach both Quotation and Exchange endpoints.
pub opaque type AuthClient
Public client — can only reach Quotation endpoints.
pub opaque type PublicClient
Values
pub fn auth_delete(
client: AuthClient,
path path: String,
query query: List(#(String, String)),
decoder decoder: decode.Decoder(a),
) -> Result(types.ApiResponse(a), types.ApiError)
Execute an authenticated DELETE request.
pub fn auth_get(
client: AuthClient,
path path: String,
query query: List(#(String, String)),
decoder decoder: decode.Decoder(a),
) -> Result(types.ApiResponse(a), types.ApiError)
Execute an authenticated GET request.
pub fn auth_post(
client: AuthClient,
path path: String,
body body: json.Json,
body_params params: List(#(String, String)),
decoder decoder: decode.Decoder(a),
) -> Result(types.ApiResponse(a), types.ApiError)
Execute an authenticated POST request with JSON body.
pub fn build_array_query(
key key: String,
values values: List(String),
) -> List(#(String, String))
Build key[]=v1&key[]=v2 style query parameters.
pub fn encode_query_string(
query: List(#(String, String)),
) -> String
Encode query parameters to a raw key=value&... string for hashing.
pub fn new_auth(
credentials credentials: auth.Credentials,
) -> AuthClient
Create an authenticated client.
pub fn new_auth_from_env() -> Result(AuthClient, String)
Create an authenticated client from environment variables.
pub fn parse_rate_limit_value(
value: String,
) -> option.Option(types.RateLimit)
Parse "group=market; min=573; sec=9" into a RateLimit.
pub fn public_get(
client: PublicClient,
path path: String,
query query: List(#(String, String)),
decoder decoder: decode.Decoder(a),
) -> Result(types.ApiResponse(a), types.ApiError)
Execute a public GET request (no auth).
pub fn public_get_auth(
client: AuthClient,
path path: String,
query query: List(#(String, String)),
decoder decoder: decode.Decoder(a),
) -> Result(types.ApiResponse(a), types.ApiError)
Execute a public GET using an AuthClient.
pub fn to_public(client: AuthClient) -> PublicClient
Downcast an AuthClient to a PublicClient for quotation calls.