# Quickstart

Make your first video through the API: create a key, check what pays for it, send a link, and get back the finished video with its files.

This guide takes you from no key to a finished video. You need a 10xvid account.

## 1. Create an API key

Open the [API keys](/app/api-keys) page in the app and press **Create key**. Give it a name, and leave it unrestricted for now. The key is shown once: copy it and keep it on your server, for example in a `.env` file.

```bash
TENX_API_KEY=tenx_your_key_here
```

## 2. Make sure something pays for it

An API call is paid from your plan's credits first. With no plan, or with its credits spent, it is paid from the top up balance: open the API side of Subscription and press **Add funds**. See [API pricing](/docs/api/pricing).

## 3. Send a link

Make a format from a website or an App Store page. Ask for styles by their ids from [the styles](/docs/styles), or for none to get the site's own look.

cURL:

```bash
curl https://10xvid.com/api/v1/formats \
  -H "Authorization: Bearer $TENX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"link": "https://apps.apple.com/app/id1234567890", "styles": ["whiteboard"]}'
```

JavaScript:

```js
const res = await fetch('https://10xvid.com/api/v1/formats', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.TENX_API_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ link: 'https://apps.apple.com/app/id1234567890', styles: ['whiteboard'] }),
});
const format = await res.json();
console.log(format.id, format.status);
```

Python:

```python
import os
import requests

res = requests.post(
    "https://10xvid.com/api/v1/formats",
    headers={"Authorization": f"Bearer {os.environ['TENX_API_KEY']}"},
    json={"link": "https://apps.apple.com/app/id1234567890", "styles": ["whiteboard"]},
)
format = res.json()
print(format["id"], format["status"])
```

The answer comes at once, with the format's `id` and `"status": "reading"`.

## 4. Get the video

The site is read, the Format DNA is written and the video is made by itself. That takes a while. Ask for the format now and then until its videos are done, or add a [webhook](/docs/api/webhooks) so your server is told.

cURL:

```bash
curl https://10xvid.com/api/v1/formats/FORMAT_ID \
  -H "Authorization: Bearer $TENX_API_KEY"
```

JavaScript:

```js
async function videosOf(id) {
  for (;;) {
    const res = await fetch(`https://10xvid.com/api/v1/formats/${id}`, {
      headers: { Authorization: `Bearer ${process.env.TENX_API_KEY}` },
    });
    const format = await res.json();
    if (format.status === 'failed') throw new Error(format.error);
    const videos = format.videos ?? [];
    if (videos.length >= format.videos_expected && videos.every((v) => v.status !== 'making')) return videos;
    await new Promise((r) => setTimeout(r, 60_000));
  }
}
```

Python:

```python
import time

def videos_of(id):
    while True:
        res = requests.get(
            f"https://10xvid.com/api/v1/formats/{id}",
            headers={"Authorization": f"Bearer {os.environ['TENX_API_KEY']}"},
        )
        format = res.json()
        if format["status"] == "failed":
            raise RuntimeError(format["error"])
        videos = format.get("videos", [])
        if len(videos) >= format["videos_expected"] and all(v["status"] != "making" for v in videos):
            return videos
        time.sleep(60)
```

Each finished video has its `files`, one for each shape, with a `url` that works on its own for seven days.

```json
{
  "id": "MV40XXRN514AA9",
  "object": "video",
  "style": "whiteboard",
  "status": "done",
  "files": [
    {
      "video_id": "MV40XXRN514AA9-V1",
      "aspect": "9:16",
      "url": "https://10xvid.com/files/brands/.../final.mp4?dl=...",
      "duration": 15.04
    }
  ]
}
```

## Next steps

- [Webhooks](/docs/api/webhooks) Be told when each video is done, instead of asking.
- [Make more videos](/docs/api/reference/videos) More from the same format, in more shapes.
- [Restrict a key](/docs/api/authentication) Limit what a key may reach and spend.
- [Errors and limits](/docs/api/errors) What each refusal means and what to do.
