# Process video with Go

Use the rendobar-go module to call Rendobar's FFmpeg API, Compose API and every other job type from Go. It waits for the output and verifies webhook signatures.

Official, built by Rendobar · v0.1.0 · MIT · The two newest Go releases

Page: https://rendobar.com/integrations/go-sdk/ · View on pkg.go.dev: https://pkg.go.dev/github.com/rendobar/rendobar-go · Read the docs: https://rendobar.com/docs/quickstart

```
go get github.com/rendobar/rendobar-go
```

- Type: Go SDK
- Built by: Rendobar
- Module: `github.com/rendobar/rendobar-go`
- Version: 0.1.0, MIT licence
- Runs on: The two newest Go releases
- Pricing: Free
- Category: Code

## Overview

rendobar-go makes every Rendobar job a call from Go: [FFmpeg commands](https://rendobar.com/ffmpeg/), [timeline videos](https://rendobar.com/compose/), captions and AI images. `Jobs.Run` submits a job and waits until it ends, following the job's own time limit from your plan. A retried submit never creates a second job, because each `Jobs.Create` call sends one idempotency key on every retry. Errors are `*rendobar.Error` with the code, status and the request id support asks for, and `Jobs.All` ranges over every job with Go's iterators. The `webhooks` package checks a delivery's signature with the standard library only.

## main.go

```go
rb := rendobar.New() // reads RENDOBAR_API_KEY

// Each input name is a file the command reads with -i.
job, err := rb.Jobs.Run(ctx, rendobar.CreateParams{
	Params: rendobar.FfmpegParams{Command: "ffmpeg -i source.mp4 -vf scale=1280:-2 out.mp4"},
	Inputs: map[string]rendobar.Input{"source.mp4": rendobar.URL("https://cdn.rendobar.com/assets/examples/sample.mp4")},
}, nil)
if err != nil {
	return err // a failed job is a *rendobar.JobFailedError
}
fmt.Println(job.Complete.Output.File.URL) // signed URL of out.mp4
```

## Set up

1. **Install.** Add the module and put a [new API key](https://app.rendobar.com/api-keys?create=1&name=SDK) in `RENDOBAR_API_KEY`.

```bash
go get github.com/rendobar/rendobar-go
```

2. **Create a client.** Make one client and reuse it across goroutines. It retries 429 and 5xx responses twice, honouring Retry-After.

```go
rb := rendobar.New()
```

3. **Run a job.** `Jobs.Run` returns the finished job. A failed job comes back as `*rendobar.JobFailedError` with the job attached.

```go
job, err := rb.Jobs.Run(ctx, rendobar.CreateParams{Params: rendobar.FfprobeParams{Command: url}}, nil)
```


## Reference

### Client

- rendobar.New(opts ...Option)
- WithAPIKey, WithBaseURL, WithTimeout, WithHTTPClient, WithMaxRetries, WithApp, WithDeprecationHandler

### Jobs

- Create, Get, List, All, Wait, Run, Cancel, Download, Types, Schema
- CreateParams{Type, Params, Inputs, IdempotencyKey, Label, Destinations}

### Errors

- *rendobar.Error: Code, StatusCode, RequestID, RetryAfter, Details
- *JobFailedError, *WaitTimeoutError, IsNotFound, IsRateLimited

### Webhooks

- webhooks.Verify(body, header, secret)
- webhooks.VerifyWith(body, header, secret, Options{Tolerance, Now})

## Questions

### Which Go versions does rendobar-go support?

The two newest Go releases, the same window Go itself supports. CI runs on both.

### How do I tell a missing job from other errors in Go?

Use `rendobar.IsNotFound(err)`, or `errors.As(err, &apiErr)` with a `*rendobar.Error` to read its code, status and request id.

### How do I verify a Rendobar webhook in Go?

Read the raw body and call `webhooks.Verify(body, r.Header, secret)`. It rejects deliveries older than 5 minutes and accepts the previous secret during a rotation.

## Resources

- [pkg.go.dev](https://pkg.go.dev/github.com/rendobar/rendobar-go): API reference and runnable examples.
- [GitHub](https://github.com/rendobar/rendobar-go): Source, issues and the conformance tests the SDK runs.
- [OpenAPI spec](https://api.rendobar.com/openapi.json): The OpenAPI 3.1 contract the SDK is generated from.

## More

- [FFmpeg recipes](https://rendobar.com/ffmpeg/recipes/)
- [The TypeScript SDK](https://rendobar.com/integrations/typescript-sdk/)