# API "start" Variable Changes Based On Day

**URL:** <https://forum.spinitron.com/t/api-start-variable-changes-based-on-day/454>\
**Category:** 🧩 API\
**Created:** [September 16, 2021, 12:32am UTC](https://forum.spinitron.com/t/api-start-variable-changes-based-on-day/454 "2021-09-16T00:32:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Calvin\_Williams](https://forum.spinitron.com/user_avatar/forum.spinitron.com/calvin_williams/32/215_2.png) [@Calvin\_Williams](https://forum.spinitron.com/u/Calvin_Williams)\
**Post date:** [September 16, 2021, 12:32am UTC](https://forum.spinitron.com/t/api-start-variable-changes-based-on-day/454/1 "2021-09-16T00:32:15Z")

</div>

Hey everyone, I have an interesting issue I’ve come across with the API. For shows that have multiple time slots, depending on when the API call happens, it returns the the upcoming start time. So if there’s a show that airs Mondays at 6pm and again Fridays at 11am, given that today is Wednesday, the start time would show Friday at 11am. Is there a way to grab a specific air time from the API? Is there something other than “start” that returns a day and time? Thanks!

---

<div class="post-metadata">

**Author:** ![tom](https://forum.spinitron.com/user_avatar/forum.spinitron.com/tom/32/343_2.png) [@tom](https://forum.spinitron.com/u/tom)\
**Post date:** [September 16, 2021, 3:06pm UTC](https://forum.spinitron.com/t/api-start-variable-changes-based-on-day/454/2 "2021-09-16T15:06:58Z")

</div>

Hi Calvin. Good question! The API for the schedule is complex because scheduled shows can have complicated repetitions.

`GET /shows` behaves in two different ways:

1. Get all the _shows_ after a given {start} datetime.

2. Get all the _occurrences_ of all the shows up to a given {end} datetime.

So to get all the occurrences of a show you have to specify an {end} datetime in the query. For example

```
curl "https://spinitron.com/api/show?start=monday&end=monday+1week&count=200" -H "Authorization: Bearer YourAPIkey"

```

We use [PHP’s datetime parser](https://www.php.net/manual/en/datetime.formats.php) that is very flexible and can understand compound and relative expressions like in this example.

I copied below the [documentation](https://spinitron.github.io/v2api/#/Show/get_shows) of the endpoint (correcting all the spelling errors `:-/`).

**Note** : API responses have a default page length of 20 items. You can increase it with the `count` query parameter, as in the example. API responses have a `_links` object with URLs to pages includes the `next` page if there is one.

* * *

#### Documentation of `GET /shows`

**Terminology** : Spinitron defines a _show_ as a radio program. A show can have one or more _schedules_, each of which may specify either an _occurrence_ or a _repetition_, which represents a set of occurrences. Thus scheduled shows have occurrences that, for example, may be displayed in a calendar.

In the response, `items` is an array of objects representing occurrences of scheduled shows.

You may optionally filter `items` to a datetime _range_ by including in the request {start} and/or {end} parameters, both of which must be no more than one hour in the past.

`items` can include occurrences that begin _or_ end within the filter range. A show that goes on air before {start} appears in `items` if it ends _after_ but not _at_ {start}. An occurrence starting at or before {end} is included.

If the request omits the {start} parameter, the server sets its value to the current time so that the filter range’s start is always defined. If the request specifies {end} then the requested range is _bounded_, otherwise it is _unbounded_.

For a bounded request, `items` includes _every_ occurrence of all shows occurring in the range. The only difference between objects in `items` representing a given show will be the `start` field value.

For an unbounded request, `items` includes _only one_ occurrence per show, specifically, the next occurrence after {start} of all shows occurring after {start}.

Use an unbounded request to get a straight list all shows. Use a bounded request to get a calendar/agenda of shows expanded into occurrences by their schedules and repetitions.

Objects in `items` are ordered first by `datetime` and then by `id`.

---

<div class="post-metadata">

**Author:** ![Calvin\_Williams](https://forum.spinitron.com/user_avatar/forum.spinitron.com/calvin_williams/32/215_2.png) [@Calvin\_Williams](https://forum.spinitron.com/u/Calvin_Williams)\
**Post date:** [October 7, 2021, 1:47am UTC](https://forum.spinitron.com/t/api-start-variable-changes-based-on-day/454/3 "2021-10-07T01:47:57Z")

</div>

Thank you for your reply, tom! So I’ve taken some time to tinker around with the shows call, and I’ve gotten as far as making bounded requests, then filtering by show ID. I find myself having the same problem as before where I can’t specifically call a specific show occurrence. I may have worked out a workaround involving passing a variable from a Wordpress page. Still figuring things out, but you did give me some tools to work with for this as well as something else I was trying to figure out, so a million thanks to you!

---

<div class="post-metadata">

**Author:** ![tom](https://forum.spinitron.com/user_avatar/forum.spinitron.com/tom/32/343_2.png) [@tom](https://forum.spinitron.com/u/tom)\
**Post date:** [October 8, 2021, 11:05pm UTC](https://forum.spinitron.com/t/api-start-variable-changes-based-on-day/454/4 "2021-10-08T23:05:10Z")

</div>

Glad to be of help, Calvin.

If, hypothetically, the API provided a way to call a specific show occurrence, how would you identify the occurrence in the request?
