# Box art url is null

**URL:** <https://discuss.dev.twitch.com/t/box-art-url-is-null/23678>\
**Category:** API\
**Created:** [January 6, 2020, 7:51pm UTC](https://discuss.dev.twitch.com/t/box-art-url-is-null/23678 "2020-01-06T19:51:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Is0](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/is0/32/7620_2.png) [@Is0](https://discuss.dev.twitch.com/u/Is0)\
**Post date:** [January 6, 2020, 7:51pm UTC](https://discuss.dev.twitch.com/t/box-art-url-is-null/23678/1 "2020-01-06T19:51:54Z")

</div>

Hey, I have this response from new twitch api:

{ “data”: [{ “id”: “493057”, “name”: “PLAYERUNKNOWN’S BATTLEGROUNDS”, “box\_art\_url”: “[https://static-cdn.jtvnw.net/ttv-boxart/PLAYERUNKNOWN’S%20BATTLEGROUNDS-{width}x{height}.jpg](https://static-cdn.jtvnw.net/ttv-boxart/PLAYERUNKNOWN%27S%20BATTLEGROUNDS-%7Bwidth%7Dx%7Bheight%7D.jpg)” }] }

​Parsing box art url as a string return a null. For me response indicates that it is a string but in docs is written that is an object. If it is indeed an object how it should look as a pojo?

---

<div class="post-metadata">

**Author:** ![Dist](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://discuss.dev.twitch.com/u/Dist)\
**Post date:** [January 6, 2020, 8:06pm UTC](https://discuss.dev.twitch.com/t/box-art-url-is-null/23678/2 "2020-01-06T20:06:55Z")

</div>

`box_art_url` is a string, the only reason I can think that the docs say it’s an Object is because it’s a template. It may just be a mistake though.

Just treat it as a string and replace the `{width}` and `{height}` with the dimensions you wish to use.

---

<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:** [January 6, 2020, 8:09pm UTC](https://discuss.dev.twitch.com/t/box-art-url-is-null/23678/3 "2020-01-06T20:09:28Z")

</div>

The docs

> **[Reference](https://dev.twitch.tv/docs/api/reference/)**
>
> Twitch Developer tools and services to integrate Twitch into your development or create interactive experience on twitch.tv.

Match the API output OP has provided

You should JSON parse the response, and the extract `resp->data[0]->box_art_url` and then substritute/string replace `{width}` and `{height}` for number for the dimension of image you need.

So

`https://static-cdn.jtvnw.net/ttv-boxart/PLAYERUNKNOWN%27S%20BATTLEGROUNDS-{width}x{height}.jpg`

becomes

`https://static-cdn.jtvnw.net/ttv-boxart/PLAYERUNKNOWN%27S%20BATTLEGROUNDS-200x300.jpg`

---

<div class="post-metadata">

**Author:** ![Ikai\_Yanasaki](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/ikai_yanasaki/32/7661_2.png) [@Ikai\_Yanasaki](https://discuss.dev.twitch.com/u/Ikai_Yanasaki)\
**Post date:** [January 26, 2020, 4:15pm UTC](https://discuss.dev.twitch.com/t/box-art-url-is-null/23678/4 "2020-01-26T16:15:53Z")

</div>

can i pass % to the width and height? Or does it have to be in px fixed size?

I’m trying to use it as a background image on a div, what’s the best way if at all possible? Do i have to iterate through the whole array and modify each box\_art\_url and set the width and height? geez i don’t know who designs twitch’s API 😕

---

<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:** [January 26, 2020, 8:03pm UTC](https://discuss.dev.twitch.com/t/box-art-url-is-null/23678/5 "2020-01-26T20:03:05Z")

</div>

> [@Ikai\_Yanasaki](#):
>
> Or does it have to be in px fixed size?

PX

> [@Ikai\_Yanasaki](#):
>
> I’m trying to use it as a background image on a div, what’s the best way if at all possible? Do i have to iterate through the whole array and modify each box\_art\_url and set the width and height? geez i don’t know who designs twitch’s API 😕

It lets you pick the size of image you want, rather than have the size dictated by Twitch.

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [February 25, 2020, 8:03pm UTC](https://discuss.dev.twitch.com/t/box-art-url-is-null/23678/6 "2020-02-25T20:03:10Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
