Client quickstarts
Your first request from TypeScript, Python and Go, using the generated clients.
The TypeScript, Python and Go clients are generated from the OpenAPI 3.1 document by scripts/generate-clients.ts, and the committed tree is checked against the document on CI. The document itself is at clients/openapi.json, and a Postman collection is at clients/postman/collection.json.
Note
The generated clients have no auth scheme baked in, because the OpenAPI document declares none. Set the Authorization header yourself, exactly as these examples do.
TypeScript
@fikadesk/api-client is a thin wrapper over openapi-fetch with the generated paths types, so route names and parameters are checked at compile time. It is Apache-2.0.
import { createApiClient } from "@fikadesk/api-client";
const api = createApiClient({
baseUrl: "http://localhost:3000",
getAuthHeader: () => `Bearer ${process.env.FIKADESK_API_KEY}`,
});
const { data, error } = await api.GET("/api/conversations", {
params: { query: { per_page: 20 } },
});
if (error) throw new Error(error.errors.map((e) => e.message).join("; "));
console.log(data?.data);Python
The Python client lives under clients/python, package name fikadesk. It needs Python 3.10 or newer.
import fikadesk
configuration = fikadesk.Configuration(host="http://localhost:3000")
with fikadesk.ApiClient(configuration) as api_client:
api = fikadesk.DefaultApi(api_client)
result = api.list_conversations(
_headers={"Authorization": "Bearer fk_<key>"},
)
print(result)Go
The Go client lives under clients/go, module github.com/fikadesk/fikadesk-go.
package main
import (
"context"
"fmt"
openapi "github.com/fikadesk/fikadesk-go"
)
func main() {
cfg := openapi.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer fk_<key>")
client := openapi.NewAPIClient(cfg)
resp, _, err := client.DefaultAPI.ListConversations(context.Background()).Execute()
if err != nil {
panic(err)
}
fmt.Println(resp)
}Each operation builds a request object first, then .Execute() sends it. Route parameters become arguments to the builder, query parameters become builder methods, and the request body is passed to the builder before execution.