# OpenAPI document and client libraries
URL: https://skedcast.com/developers/guides/openapi-3.1-social-media-api-sdk

The machine-readable contract for the /v1 API is an OpenAPI 3.1 document at https://skedcast.com/openapi.json. It covers every operation, the security schemes and the error model. SkedCast does not publish a language-specific package. Call the REST API from any language, or generate a typed client from this document.

## What's available
Resource | What it is | URL
OpenAPI 3.1 document | The contract for every /v1 operation | `https://skedcast.com/openapi.json`
REST API | JSON over HTTPS, from any language | `https://api.skedcast.com/v1`

## Generate a client from the document
Import the document into Postman or Insomnia to explore the API interactively, or point a standard OpenAPI code generator (openapi-generator, openapi-typescript, kiota) at it to produce a typed client in Python, Go, Java or any other supported language. The document declares the security schemes. Generators differ in how they use them, so check that your client sends `Authorization: Bearer <key>`.

## Generate a Python client with openapi-generator (as one example).
```bash
openapi-generator-cli generate \
  -i https://skedcast.com/openapi.json \
  -g python \
  -o ./skedcast-client
```

## A typed TypeScript client
openapi-typescript turns the document into types, and openapi-fetch uses them to type every call, including the required `Idempotency-Key` header.

## Install both tools and generate the types.
```bash
npm install openapi-fetch
npm install --save-dev openapi-typescript

npx openapi-typescript https://skedcast.com/openapi.json -o ./skedcast.d.ts
```

## Create a post with a typed client.
```ts
import createClient from "openapi-fetch";

import type { paths } from "./skedcast";

const client = createClient<paths>({
  baseUrl: "https://api.skedcast.com/v1",
  headers: { Authorization: `Bearer ${process.env.SKEDCAST_API_KEY ?? ""}` },
});

const { data, error } = await client.POST("/posts", {
  params: { header: { "Idempotency-Key": crypto.randomUUID() } },
  body: {
    clientId: "<clientId>",
    content: "Hello from a generated client",
    targets: { mode: "selection", accountIds: ["<accountId>"] },
    schedule: { type: "at", scheduledAt: "2030-01-15T15:00:00Z" },
  },
});

if (error !== undefined) {
  throw new Error(`SkedCast refused the post: ${JSON.stringify(error)}`);
}
console.log(data);
```

## FAQ
**Q: Does the OpenAPI document match the live API?**
A: It describes the same /v1 operations as the API reference at /developers/api-reference. Import it into Postman, Insomnia or a code generator for a client that matches the API. Regenerate the client when you want new fields.

**Q: Is there an official SDK for my language?**
A: SkedCast does not publish language-specific libraries. Call the REST API directly, or generate a typed client from the OpenAPI 3.1 document in any language the generator supports.
