Channels HTTP API

If your customizable remote has physical number buttons you’re hoping to be able to take advantage of, another idea that worked for me, was assigning those number keys to my top 10 favorite channels.

Instead of remembering my 10 favorite channel number assignments and having to type them in manually, I use the 0-9 buttons as sort of a “speed dial” instead.

2 Likes

Sorry. I find the Clapper to be pretty gawd-awful, so it won't be making it to my project list. But I will tell you how I would do it.

Rather than a Pi, I would use a Shelly Uni. It's a lot cheaper and is purpose built. I've used them for hard wired motion, door, and moisture sensors as well as garage door openers. You can use them to automate just about anything that produces voltage when triggered. Once you have it reliably detecting your claps, you can go wild with Home Assistant automatons.

1 Like

Why would an Android TV device respond to a toggle_record POST with a "not found", even though it is tuned to a channel via the API and can be stopped via the API as well?

1 Like

Does it appear as an option in the api help output?

What is the "api help output"? I don't see that documented.

Curl /api shows it

Welcome to the Channels API

With this API, you can query Channels' status as well as control it.

## Info

Check out the current status of the player or fetch the favorite channels.

GET /api/status - Player's current status
GET /api/favorite_channels - List of favorite channels

## Controls

Control the playback of Channels. All control responses return the player's current status.

POST /api/toggle_mute - Toggle mute on and off
POST /api/toggle_cc - Toggle captions on and off
POST /api/toggle_pip - Toggle Picture in Picture on and off
POST /api/channel_up - Change the channel
POST /api/channel_down - Change the channel
POST /api/previous_channel - Jump to the previous channel
POST /api/toggle_pause - Pause or resume playback based on current playing state
POST /api/pause - Pause playback
POST /api/resume - Resume playback
POST /api/stop - Stop playback
POST /api/seek/{seconds} - Seek in timeline by seconds
POST /api/seek_forward - Seek ahead duration in settings
POST /api/seek_backward - Seek back duration in settings
POST /api/skip_forward - Skip to the next chapter mark
POST /api/skip_backward - Skip to the previous chapter mark
POST /api/play/channel/{channel_number} - Play a channel
POST /api/play/recording/{recording_id} - Play a recording
POST /api/navigate/{section_name} - Change to a section of the app by providing its name. EX, Guide, Library, Live TV
POST /api/notify - Present a notification while playing video - example payload: {"title":"Arrived home", "message":"Jon has arrived home"}

So, no toggle_record? Is this a version issue?, platform issue? has toggle_record been removed from the API?

1 Like

Okay it wasn't added to android then. I'll take a look today.

Try this build:

1 Like

Updated to the most recent Beta and now a toggle_record returns : "BAD REQUEST: Syntax error. HTTP verb Post unhandled"

But, this is possibly because I can't start a recording now play/channel/# returns a "status:stopped"

Can you try again with the latest beta

Now all requests get a "curl: (7) Failed to connect to 192.168.183.158 port 57000: Connection refused" response. I've checked the url and it is correct. This brings up a question. I noticed that I had the beta program and the regular program both running the last time I tested (this last time, I uninstalled the play store version and ran only the beta). How would these two programs, both attempting to use port 57000 resolve the conflict?

1 Like

You probably need to restart the beta then because it would have failed to grab the port while the stable was using it

1 Like

Ok, getting closer. Now, I can get a status with a complete listing of api options. "play/channel/#" works, but there doesn't seem to be a way to stop the program from playing. Also, "toggle_record" works to start a recording, but does not toggle the recording off. Other than /status, I haven't tested other options yet.

1 Like

/api/stop is supposed to stop the player

Toggling record off shows a confirmation dialog on screen.

1 Like

@tmm1

I noticed there were some recent API changes and just discovered this thread

This morning i noticed that the HTTP API on my system is hosed.

I had set up a bunch of ios shortcuts accessing the channels http api about a year ago. They have been working flawlessly.

For some reason this morning im getting a “could not connect to the server” no matter what i do, including using a browser, curl, etc

Has the syntax changed, port number, etc.?
Ive tried loading the latest stable build on the server
9.11.0707

I also reinstalled channels from scratch and went back to the stable build with the install but ran into the same issue.

so for now Im back on 9.11.0707 and using the latest test flight beta

Ive also rebooted my server, router, apple tv, etc.

Any help would be appreciated..

I also tried using curl get status and got connection refused? channels dvr app was open on apple tv...

Screen Shot 2022-09-12 at 9.44.36 AM

The /api/status endpoint uses the GET verb. Since that is the default, remove the -X POST from your command.

For the endpoints and their respective verbs, see the API listing.

1 Like

thanks for suggestion. i already noticed that and retried using a couple of commands while the apple tv app is open. still getting connection refused using curl and “could not connect to the server” using known previously working iOS shortcuts. never had to use curl before, just trying to get more info for debugging this issue

Screen Shot 2022-09-12 at 12.52.25 PM

Can you force stop and restart the android app

Im using TVOS.
Force restart was one of the first things i tried this morning with no success.

I just did another force restart and shortcuts working again!
Curl commands as well.

Something Very Strange going on here…
But im very happy all my shortcuts work with the API again.

Ill poke you if i see this strange behavior again, and of course let me know if you need my assistance if anyone else starts seeing the API interface getting hosed…