# I Don't Know how to use Get Clips Helix Api

**URL:** <https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371>\
**Category:** API\
**Created:** [March 8, 2020, 4:19pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371 "2020-03-08T16:19:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 4:19pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/1 "2020-03-08T16:19:00Z")

</div>

![api](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/0223f744a47165e67dbe5d64e24a2d125b3b6121.png)

Hello , I Would like to Get Some Help on How to use this Twitch Api  
To Get Last 7 days Top Clips For a Special Broadcaster as shown in the example .  
It Dosen’t Return anything for me , & i’m not sure if i made a mistake in the Date Format for the proprieties Started\_at & ended\_at . in my example i did ?started\_at=2020-03-01?ended\_at=2020-03-08  
to get clips between 1 MARS 2020 & 8 MARS 2020 .  
Thanks for your help \<3 🙂

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 8, 2020, 4:20pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/2 "2020-03-08T16:20:04Z")

</div>

Your URL is wrong.

It should be

> clips?broadcaster\_id=foo&started\_at=date&ended\_at=anotehrdate

Query string arguments need to be `&` separated in the URL

---

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 4:27pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/3 "2020-03-08T16:27:21Z")

</div>

IT WORKED But i still have a problem with the Date Format ! i don’t know how to convert this date : 2020-03-01 to RFC3339

 ![api2](https://d2opxh93rbxzdn.cloudfront.net/original/2X/6/681b2595be301279bc2a8bc8aee4eaa556d092b7.png)

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 8, 2020, 4:30pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/4 "2020-03-08T16:30:22Z")

</div>

> &started\_at=2020-03-01T00:00:00Z&ended\_at=2020-03-08T00:00:00Z

---

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 4:39pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/5 "2020-03-08T16:39:02Z")

</div>

Thank Youuu 😃 iT Worked 🙂 , is there any easy way to use this format in php because in my php script i should be using variables . is there any way to use Varibale like $date.time.now & convert it to this format ?? & substract 7 days from it in the second variable .

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 8, 2020, 4:41pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/6 "2020-03-08T16:41:01Z")

</div>

[https://www.php.net/manual/en/class.datetime.php](https://www.php.net/manual/en/class.datetime.php)

Suggests

> Y-m-d\TH:i:sP

So

> $date = date(‘Y-m-d\TH:i:sP’, time());

---

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 4:46pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/7 "2020-03-08T16:46:19Z")

</div>

![api3](https://d2opxh93rbxzdn.cloudfront.net/original/2X/7/760b3f9c6d1cf815b7dcf3588975d015a7d43d40.png)

It Worked . Is It Possible to make another Date Variable and Substract 7 days from it ?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 8, 2020, 4:49pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/8 "2020-03-08T16:49:06Z")

</div>

[https://www.php.net/strtotime](https://www.php.net/strtotime)

> $one\_week = strtotime(‘-1 week’):

---

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 4:58pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/9 "2020-03-08T16:58:46Z")

</div>

![api4](https://d2opxh93rbxzdn.cloudfront.net/original/2X/1/16920ddfb7c1dc12833f09c1937eb2710d94593d.png)  
 ![api5](https://d2opxh93rbxzdn.cloudfront.net/original/2X/f/f963e8b6fbd2c49037d9cc03b4f4880b6427a01f.png)

I think i have a problem with First date i should add some more “” i guess , and also the Format Need to be like this 2020-03-08T17:56:03Z i don’t know how to add that letter in the End

---

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 5:01pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/10 "2020-03-08T17:01:09Z")

</div>

eventough i added the P $date = date(“Y-m-d\TH:i:sP”, time()); in the format it give me this !!  
 ![api6](https://d2opxh93rbxzdn.cloudfront.net/original/2X/5/5a25dc02f9eafc2b582249e49b7e6bc5a7a0df91.png)

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 8, 2020, 5:16pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/11 "2020-03-08T17:16:18Z")

</div>

`Z` means you are in UTC  
`+01:00` means you are in a timezone +1 of UTC

So `+01:00` is correct

The P of the timezone in the format means “append the timezone offset”

> _P_ Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3)

[https://php.net/date](https://php.net/date)

---

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 5:20pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/12 "2020-03-08T17:20:42Z")

</div>

![api7](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/01995965e7f7c9785d1390ac9f55f2bf5d5bdd99.png)  
 ![api8](https://d2opxh93rbxzdn.cloudfront.net/original/2X/b/b68d4a7b590d52de394484bd408c1fddba98ba3a.png)  
I’m Not Sure why i’m still getting an error if the Date Format is Correct

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 8, 2020, 5:23pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/13 "2020-03-08T17:23:20Z")

</div>

You are not URLencoding your parameters

[https://www.php.net/urlencode](https://www.php.net/urlencode)

---

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 5:26pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/14 "2020-03-08T17:26:44Z")

</div>

![encode](https://d2opxh93rbxzdn.cloudfront.net/original/2X/6/642602468088ad3996d2df7b37b544b2f6b6bb69.png)  
 ![data](https://d2opxh93rbxzdn.cloudfront.net/original/2X/5/56d5f0ca589a2917deb304564e62b7f3b2c852d4.png)  
I Tried This but i still i think i messed up with the dates

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 8, 2020, 5:28pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/15 "2020-03-08T17:28:43Z")

</div>

Please stop using screenshots for your code, makes it difficult for me to copy/paste/fix

You can just paste code into the forums, using the relevant formatting functions

> $date1 = urlencode(date(‘Y-m-d\TH:i:sP’), time());  
> $date2 = urlencode(date(‘Y-m-d\TH:i:sP’, strtotime(‘-1 week’));

---

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 5:39pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/16 "2020-03-08T17:39:55Z")

</div>

![null](https://d2opxh93rbxzdn.cloudfront.net/original/2X/d/d97efc847447863d9190aadb4faa67e69e173468.png)

Am Sorry ,  
It Still returning Null For me

```
<?php

$date1 = date("Y-m-d\TH:i:sP", time());
$date2 = date("Y-m-d\TH:i:sP", strtotime("-7 days"));
   $date3 = urldecode($date1);
   $date4 = urldecode($date2);
echo $date1;
echo "<br>";
echo $date2;
echo "<br>";
echo $date3;
echo "<br>";
echo $date4;
echo "<br>";

$ch = curl_init('https://api.twitch.tv/helix/clips?broadcaster_id=157527726&started_at=' . $date4 . ' &ended_at= '.$date3);

```

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 8, 2020, 5:40pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/17 "2020-03-08T17:40:57Z")

</div>

You need to `urlencode`. You have `urldecode`d

```
$date3 = urlencode($date1);
$date4 = urlencode($date2);
```

---

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 5:43pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/18 "2020-03-08T17:43:32Z")

</div>

![null](https://d2opxh93rbxzdn.cloudfront.net/original/2X/8/86267020dfb954a2f41db30f35695097351978fc.png)  
I Changed it , but still NULL

```
$date1 = date("Y-m-d\TH:i:sP", time());
$date2 = date("Y-m-d\TH:i:sP", strtotime("-7 days"));
$date3 = urlencode($date1);
$date4 = urlencode($date2);
echo $date1;
echo "<br>";
echo $date2;
echo "<br>";
echo $date3;
echo "<br>";
echo $date4;
echo "<br>";

$ch = curl_init('https://api.twitch.tv/helix/clips?broadcaster_id=157527726&started_at=' . $date3 . ' &ended_at= '.$date4);

```

---

<div class="post-metadata">

**Author:** ![Amininano](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/amininano/32/7891_2.png) [@Amininano](https://discuss.dev.twitch.com/u/Amininano)\
**Post date:** [March 8, 2020, 5:48pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/19 "2020-03-08T17:48:41Z")

</div>

When i Tried to use the Encoded Date Format in the Api , It Actually Worked

```
$ch = curl_init('https://api.twitch.tv/helix/clips?broadcaster_id=157527726&started_at=2020-03-01T18%3A42%3A52%2B01%3A00&ended_at=2020-03-08T18%3A42%3A52%2B01%3A00');

```

 ![var](https://d2opxh93rbxzdn.cloudfront.net/original/2X/4/4c2a1d19497485e028af7c8548f41edb18096cc5.png)  
However It’s Not working when using Variables like this :

```
$ch = curl_init('https://api.twitch.tv/helix/clips?broadcaster_id=157527726&started_at=' . $date3 . ' &ended_at= '.$date4);

```

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 8, 2020, 5:54pm UTC](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371/20 "2020-03-08T17:54:30Z")

</div>

![image](https://d2opxh93rbxzdn.cloudfront.net/original/2X/4/4e19cee0cca3fe5158662206fcec0236233bd0ca.png)

You have a space before the & of ended\_at and after the = of ended\_at=

Additionally your dates are back to front

> start\_at=now&end\_at=sevendays\_ago

So no results

[Next page](https://discuss.dev.twitch.com/t/i-dont-know-how-to-use-get-clips-helix-api/24371.md?page=2)
