# screenshot › animated

## Table of Contents

- [CLI Microlink API example](#cli-microlink-api-example)
  - [cURL Microlink API example](#curl-microlink-api-example)
  - [JavaScript Microlink API example](#javascript-microlink-api-example)
  - [Python Microlink API example](#python-microlink-api-example)
  - [Ruby Microlink API example](#ruby-microlink-api-example)
  - [PHP Microlink API example](#php-microlink-api-example)
  - [Golang Microlink API example](#golang-microlink-api-example)
- [Options](#options)
  - [CLI Microlink API example](#cli-microlink-api-example-1)
  - [cURL Microlink API example](#curl-microlink-api-example-1)
  - [JavaScript Microlink API example](#javascript-microlink-api-example-1)
  - [Python Microlink API example](#python-microlink-api-example-1)
  - [Ruby Microlink API example](#ruby-microlink-api-example-1)
  - [PHP Microlink API example](#php-microlink-api-example-1)
  - [Golang Microlink API example](#golang-microlink-api-example-1)

---

Type:

\<boolean\> \| \<object\>

\
Default: false

It records a short video of the target [url](https://microlink.io/docs/api/parameters/url) instead of a static [screenshot](https://microlink.io/docs/api/parameters/screenshot), capturing animations, transitions and any live content as it plays.

The following examples show how to use the Microlink API with CLI, cURL, JavaScript, Python, Ruby, PHP & Golang, targeting 'https://threejs.org/examples/webgl_animation_skinning_blending' URL with 'screenshot' API parameter:

### CLI Microlink API example

```bash
microlink https://threejs.org/examples/webgl_animation_skinning_blending&screenshot.animated
```

### cURL Microlink API example

```bash
curl -G "https://api.microlink.io" \
  -d "url=https://threejs.org/examples/webgl_animation_skinning_blending" \
  -d "screenshot.animated=true"
```

### JavaScript Microlink API example

```javascript
import createClient from 'microlink.io'

const microlink = createClient()

const data = await microlink.screenshot('https://threejs.org/examples/webgl_animation_skinning_blending', {
  animated: true
})
```

### Python Microlink API example

```python
import requests

url = "https://api.microlink.io/"

querystring = {
    "url": "https://threejs.org/examples/webgl_animation_skinning_blending",
    "screenshot.animated": "true"
}

response = requests.get(url, params=querystring)

print(response.json())
```

### Ruby Microlink API example

```ruby
require 'uri'
require 'net/http'

base_url = "https://api.microlink.io/"

params = {
  url: "https://threejs.org/examples/webgl_animation_skinning_blending",
  screenshot.animated: "true"
}

uri = URI(base_url)
uri.query = URI.encode_www_form(params)

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri)
response = http.request(request)

puts response.body
```

### PHP Microlink API example

```php
<?php

$baseUrl = "https://api.microlink.io/";

$params = [
    "url" => "https://threejs.org/examples/webgl_animation_skinning_blending",
    "screenshot.animated" => "true"
];

$query = http_build_query($params);
$url = $baseUrl . '?' . $query;

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET"
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #: " . $err;
} else {
    echo $response;
}
```

### Golang Microlink API example

```
package main

import (
    "fmt"
    "net/http"
    "net/url"
    "io"
)

func main() {
    baseURL := "https://api.microlink.io"

    u, err := url.Parse(baseURL)
    if err != nil {
        panic(err)
    }
    q := u.Query()
    q.Set("url", "https://threejs.org/examples/webgl_animation_skinning_blending")
    q.Set("screenshot.animated", "true")
    u.RawQuery = q.Encode()

    req, err := http.NewRequest("GET", u.String(), nil)
    if err != nil {
        panic(err)
    }

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, err := io.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }

    fmt.Println(string(body))
}
```

```javascript
importcreateClientfrom'microlink.io'

constmicrolink=createClient()

constdata=awaitmicrolink.screenshot('https://threejs.org/examples/webgl_animation_skinning_blending',{

animated:true

})
```

When it's enabled, the `screenshot` data field includes an `animated` object pointing to the generated video:

```json
{

"data":{

"screenshot":{

"size_pretty":"619 kB",

"size":618992,

"type":"png",

"url":"https://iad.microlink.io/2ov-NQjphkr40lNPhXkT0jrVDuFvuEt1DNa9csiaWFJcVb4NrTmMYXmA3FKIcXoR7xjHTr_etfTdKzHl3Bp-RA.png",

"width":2560,

"height":1600,

"animated":{

"duration":5000,

"duration_pretty":"5s",

"fps":60,

"size_pretty":"135 kB",

"size":134930,

"type":"mp4",

"codec":"avc1.640028",

"backend":"screencast",

"url":"https://iad.microlink.io/bM7LYSDXoIZumb0MddoxP1NZCfmbSNNA9dJcjIdkpMoDPR1psJFGPi_q1TiYh5qIqtC-T2_0T5Tn4pkAjfZo8A.mp4",

"width":1280,

"height":800

}

}

},

"status":"success"

}
```

## Options

Pass an object to tune the recording:

| Field      | Type       | Default | Description                                                          |
| ---------- | ---------- | ------- | -------------------------------------------------------------------- |
| `duration` | `<number>` | `5000`  | Recording length in milliseconds (also accepts `'5s'`). Max `10000`. |
| `fps`      | `<number>` | `30`    | Frames per second. Max `60`.                                         |
| `type`     | `<string>` | `'mp4'` | Video container: `'mp4'` (H.264) or `'webm'` (VP9).                  |

The following examples show how to use the Microlink API with CLI, cURL, JavaScript, Python, Ruby, PHP & Golang, targeting 'https://threejs.org/examples/webgl_animation_skinning_blending' URL with 'screenshot' API parameter:

### CLI Microlink API example

```bash
microlink https://threejs.org/examples/webgl_animation_skinning_blending&screenshot.animated.duration=8s&screenshot.animated.fps=30
```

### cURL Microlink API example

```bash
curl -G "https://api.microlink.io" \
  -d "url=https://threejs.org/examples/webgl_animation_skinning_blending" \
  -d "screenshot.animated.duration=8s" \
  -d "screenshot.animated.fps=30"
```

### JavaScript Microlink API example

```javascript
import createClient from 'microlink.io'

const microlink = createClient()

const data = await microlink.screenshot('https://threejs.org/examples/webgl_animation_skinning_blending', {
  animated: {
    duration: "8s",
    fps: 30
  }
})
```

### Python Microlink API example

```python
import requests

url = "https://api.microlink.io/"

querystring = {
    "url": "https://threejs.org/examples/webgl_animation_skinning_blending",
    "screenshot.animated.duration": "8s",
    "screenshot.animated.fps": "30"
}

response = requests.get(url, params=querystring)

print(response.json())
```

### Ruby Microlink API example

```ruby
require 'uri'
require 'net/http'

base_url = "https://api.microlink.io/"

params = {
  url: "https://threejs.org/examples/webgl_animation_skinning_blending",
  screenshot.animated.duration: "8s",
  screenshot.animated.fps: "30"
}

uri = URI(base_url)
uri.query = URI.encode_www_form(params)

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri)
response = http.request(request)

puts response.body
```

### PHP Microlink API example

```php
<?php

$baseUrl = "https://api.microlink.io/";

$params = [
    "url" => "https://threejs.org/examples/webgl_animation_skinning_blending",
    "screenshot.animated.duration" => "8s",
    "screenshot.animated.fps" => "30"
];

$query = http_build_query($params);
$url = $baseUrl . '?' . $query;

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET"
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #: " . $err;
} else {
    echo $response;
}
```

### Golang Microlink API example

```
package main

import (
    "fmt"
    "net/http"
    "net/url"
    "io"
)

func main() {
    baseURL := "https://api.microlink.io"

    u, err := url.Parse(baseURL)
    if err != nil {
        panic(err)
    }
    q := u.Query()
    q.Set("url", "https://threejs.org/examples/webgl_animation_skinning_blending")
    q.Set("screenshot.animated.duration", "8s")
    q.Set("screenshot.animated.fps", "30")
    u.RawQuery = q.Encode()

    req, err := http.NewRequest("GET", u.String(), nil)
    if err != nil {
        panic(err)
    }

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, err := io.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }

    fmt.Println(string(body))
}
```

```javascript
importcreateClientfrom'microlink.io'

constmicrolink=createClient()

constdata=awaitmicrolink.screenshot('https://threejs.org/examples/webgl_animation_skinning_blending',{

animated:{

duration:"8s",

fps:30

}

})
```

The recording starts at navigation, so the first moments capture the page loading before the content settles.

Like a regular screenshot, it can be combined with [embed](https://microlink.io/docs/api/parameters/embed) to serve the video directly from the API (the response body is the `video/mp4` itself), so you can drop the request URL straight into a `<video>` tag:

```html
<video

autoplay

loop

muted

playsinline

src="https://api.microlink.io/?url=https://threejs.org/examples/webgl_animation_skinning_blending&meta=false&screenshot.animated=true&embed=screenshot.animated.url"

></video>
```