Latest Legacy

List Media

This API lets you fetch a list of media associated with a given auth_id.

API Endpoint

GET https://api.plivo.com/v1/Account/{auth_id}/Media/

Arguments

limit integer

Denotes the number of results per page. The maximum number of results that can be fetched is 20. Defaults to 20.

offset integer

Denotes the number of value items by which the results should be offset. Defaults to 0. Read more about offset-based pagination.

Returns

Returns a JSON response containing the list of media_files uploaded or associated with the given user.

Response

HTTP Status Code: 200

{
    "api_id": "<api_id>",
    "meta": {
        "limit": 20,
        "next": "/v1/Account/<auth_id>/Media?offset=20&limit=20",
        "offset": 0,
        "previous": "/v1/Account/<auth_id>/Media?offset=0&limit=20"
        "total_count": 44
    },
    "objects": [
        {
            "content_type": "image/jpeg",
            "file_name": "sample2.jpg",
            "media_id": "<media_id>",
            "size": 113730,
            "upload_time": "2020-02-17T05:46:54.481186Z",
            "media_url": "https://media.plivo.com/Account/<auth_id>/Media/<media_id>"
        },
        .
        .
        .
        .
       {
            "content_type": "application/pdf",
            "file_name": "pdf_sample.pdf",
            "media_id": "<media_id>",
            "size": 309500,
            "upload_time": "2020-02-17T08:32:41.924866Z",
            "media_url": "https://media.plivo.com/Account/<auth_id>/Media/<media_id>"
        }
    ]
}

Example Request

1
2
3
4
import plivo
client = plivo.RestClient("<auth_id>", "<auth_token>")
response = client.media.list()
print(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
require 'rubygems'
require 'plivo'

include Plivo
include Plivo::Exceptions

api = RestClient.new("<auth_id>","<auth_token>")
begin
 response = api.media.list()
 puts response
 rescue PlivoRESTError => e
  puts 'Exception: ' + e.message
end
1
2
3
4
5
6
7
8
9
10
let plivo = require('plivo');

let client = new plivo.Client('<auth_id>', '<auth_token>');
client.media.list().then(
  function (media) {
    console.log("\n============ response ===========\n", media)
  }
).catch(function (response) {
  console.log("\n============ Error :: ===========\n", response);
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
require 'vendor/autoload.php';
use Plivo\RestClient;

$client = new RestClient("<auth_id>","<auth_token>");
$client->client->setTimeout(40);

//List all media
try {
    $response = $client->media->list();
     print_r($response);
 }
 catch (PlivoRestException $ex) {
     print_r($ex);
 }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.plivo.api;
import java.io.IOException;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.base.ListResponse;
import com.plivo.api.models.media.Media;

public class Test {
  public static void main(String[] args) {
    Plivo.init("<auth_id>", "<auth_token>");
    try {
      ListResponse<Media> p = Media.lister().list();
      System.out.println(p);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (PlivoRestException e) {
      e.printStackTrace();
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using Plivo;
using Plivo.Exception;

namespace SdkTestDotnet
{
    class Program
    {
        static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            try
            {
                var response = api.Media.List();
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}
1
2
curl -i --user auth_id:auth_token \
  https://api.plivo.com/v1/Account/{auth_id}/Media/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package main

import (
	"fmt"

	plivo "github.com/plivo/plivo-go/v7"
)

func main() {

	// MAIN ACCOUNT
	client, err := plivo.NewClient("<auth_id>",
		"<auth_token>",
		&plivo.ClientOptions{})
	if err != nil {
		panic(err)
	}

	// list all media in account
	listResp, err := client.Media.List(plivo.MediaListParams{Limit: 20, Offset: 0})
	if err != nil {
		panic(err)
	}
	fmt.Printf("Response: %#v\n", listResp)
}