{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-resources/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["tabs","tab"]},"type":"markdown"},"seo":{"title":"Generating an API Client","description":"Bookable is a TMS API gateway API — one integration to access real-time availability and manage bookings across venues on any table management system.","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"generating-an-api-client","__idx":0},"children":["Generating an API Client"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://openapi-generator.tech/"},"children":["OpenAPI Generator"]}," to scaffold a typed, ready-to-use client from the Bookable Bookings API spec. This removes the need to hand-write HTTP calls, models, or serialization logic."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":1},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["OpenAPI Generator requires ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Java 11+"]}," to run. Install it once, then use either the CLI wrapper or the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["npx"]}," approach — no permanent global install needed."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Check Java version\njava -version\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Install the CLI wrapper via npm (recommended for Node-based projects):"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npm install @openapitools/openapi-generator-cli --save-dev\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Or run it on-demand without installing:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npx @openapitools/openapi-generator-cli version\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"download-the-spec","__idx":2},"children":["Download the spec"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -O https://bookable.redocly.app/_spec/apis/BookingApi.yml\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Or reference it directly in the generate command using the URL — no local copy needed."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"generate-a-client","__idx":3},"children":["Generate a client"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Run ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["generate"]}," with the target language generator, the spec file, and an output directory."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"TypeScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npx @openapitools/openapi-generator-cli generate \\\n  -i BookingApi.yml \\\n  -g typescript-fetch \\\n  -o ./src/bookable-client \\\n  --additional-properties=supportsES6=true,npmName=bookable-client\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npx @openapitools/openapi-generator-cli generate \\\n  -i BookingApi.yml \\\n  -g python \\\n  -o ./bookable-client \\\n  --additional-properties=packageName=bookable_client\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Java","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npx @openapitools/openapi-generator-cli generate \\\n  -i BookingApi.yml \\\n  -g java \\\n  -o ./bookable-client \\\n  --additional-properties=groupId=com.example,artifactId=bookable-client,java8=true\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"C#","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npx @openapitools/openapi-generator-cli generate \\\n  -i BookingApi.yml \\\n  -g csharp \\\n  -o ./BookableClient \\\n  --additional-properties=packageName=BookableClient,targetFramework=net6.0\n","lang":"bash"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Replace ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["BookingApi.yml"]}," with the remote URL ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://bookable.redocly.app/_spec/apis/BookingApi.yml"]}," to always generate from the latest published spec."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"configure-the-generated-client","__idx":4},"children":["Configure the generated client"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The generated client defaults to the base URL defined in the spec. Override it at runtime and inject the OAuth token before making requests."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"TypeScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { Configuration, BookingsApi } from './src/bookable-client';\n\nconst config = new Configuration({\n  basePath: 'https://api-sandbox.bookabletech.com', // or https://api.bookabletech.com\n  accessToken: async () => {\n    // Return a valid Bearer token — fetch from your token store or refresh if needed\n    return myTokenStore.getAccessToken();\n  },\n});\n\nconst api = new BookingsApi(config);\n\nconst availability = await api.getAvailability({\n  operatorId: 'op_123',\n  date: '2026-06-15',\n  partySize: 2,\n});\n","lang":"typescript"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import bookable_client\nfrom bookable_client.api import bookings_api\n\nconfiguration = bookable_client.Configuration(\n    host=\"https://api-sandbox.bookabletech.com\"\n)\nconfiguration.access_token = my_token_store.get_access_token()\n\nwith bookable_client.ApiClient(configuration) as api_client:\n    api = bookings_api.BookingsApi(api_client)\n    availability = api.get_availability(operator_id=\"op_123\", date=\"2026-06-15\", party_size=2)\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Java","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"ApiClient client = new ApiClient();\nclient.setBasePath(\"https://api-sandbox.bookabletech.com\");\nclient.setAccessToken(myTokenStore.getAccessToken());\n\nBookingsApi api = new BookingsApi(client);\nAvailabilityResponse availability = api.getAvailability(\"op_123\", \"2026-06-15\", 2);\n","lang":"java"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"C#","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"var config = new Configuration\n{\n    BasePath = \"https://api-sandbox.bookabletech.com\",\n    AccessToken = myTokenStore.GetAccessToken(),\n};\n\nvar api = new BookingsApi(config);\nvar availability = await api.GetAvailabilityAsync(\"op_123\", \"2026-06-15\", 2);\n","lang":"csharp"},"children":[]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"token-management","__idx":5},"children":["Token management"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The generated client does not handle token refresh automatically. Use a wrapper or middleware to fetch a token via the OAuth client credentials flow before each request, or cache it and refresh when it is about to expire."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["See ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/getting-started/auth"},"children":["Authentication"]}," for the full token endpoint and request format."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"pinning-the-generator-version","__idx":6},"children":["Pinning the generator version"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To ensure reproducible builds, pin the generator version in your project config:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"// openapitools.json (created automatically on first run)\n{\n  \"$schema\": \"node_modules/@openapitools/openapi-generator-cli/config.schema.json\",\n  \"spaces\": 2,\n  \"generator-cli\": {\n    \"version\": \"7.10.0\"\n  }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Run ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["npx @openapitools/openapi-generator-cli version-manager list"]}," to see available versions."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"available-generators","__idx":7},"children":["Available generators"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["OpenAPI Generator supports 50+ languages and frameworks. Run the following to list all options:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npx @openapitools/openapi-generator-cli list\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Common choices for Bookable integrations:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Generator"},"children":["Generator"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Output"},"children":["Output"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["typescript-fetch"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["TypeScript with native fetch"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["typescript-axios"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["TypeScript with Axios"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["javascript"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Plain JavaScript (CommonJS)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["python"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Python (requests)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["java"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Java (OkHttp + Gson)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["csharp"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["C# (.NET)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["go"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Go"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ruby"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Ruby"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["php"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["PHP"]}]}]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"related","__idx":8},"children":["Related"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/getting-started/auth"},"children":["Authentication"]}," — OAuth 2.0 token flow and code examples"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/apis/production/bookingapi"},"children":["API Reference"]}," — full Bookings API spec"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/resources/postman-import"},"children":["Using Postman"]}," — test endpoints without code"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/getting-started/quickstart"},"children":["Quickstart"]}," — make your first booking"]}]}]},"headings":[{"value":"Generating an API Client","id":"generating-an-api-client","depth":1},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Download the spec","id":"download-the-spec","depth":2},{"value":"Generate a client","id":"generate-a-client","depth":2},{"value":"Configure the generated client","id":"configure-the-generated-client","depth":2},{"value":"Token management","id":"token-management","depth":2},{"value":"Pinning the generator version","id":"pinning-the-generator-version","depth":2},{"value":"Available generators","id":"available-generators","depth":2},{"value":"Related","id":"related","depth":2}],"frontmatter":{"seo":{"title":"Generating an API Client"}},"lastModified":"2026-03-06T16:24:08.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/resources/client-generation","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}