Author Topic: Using the API  (Read 142 times)

0 Members and 0 Guests are viewing this topic.

Offline K5MRE

  • Newbie
  • *
  • Posts: 21
  • Referrals: 0
Using the API
« on: May 08, 2019, 12:34:54 pm »
All of you are familiar with the Selfcare page.  However, I wanted to make sure you're also familiar with the API that selfcare uses in the event that you want to do something creative with it.

An example is the hotspot screen that EA7KDO is working on that allows you to disconnect an active talkgroup by pushing a button on the screen.  That works by leveraging the API.

Keep in mind that right now, the API is bound to your source IP address.

To get a list of all of your hotspots that have connected to TGIF from your current IP address, their connection status, and other information, use:

http://tgif.network:5040/api/sessions

To change talkgroups, use the following:

http://tgif.network:5040/api/sessions/update/{repeater_id}/{timeslot}/{talkgroup}

Replacing {repeater_id} {timeslot} and {talkgroup} with the appropriate timeslot and talkgroup.

NOTE:  For the API, timeslot 1 is '0' and timeslot 2 is '1'.

So if you wanted to, you could create a bookmark in your tool bar with a URL like:

http://tgif.network:5040/api/sessions/update/123123101/1/4000

... which would move Timeslot 2 on hotspot 123123101 to TG 4000 (no transmit).

If you get a 200 response, the call was made successfully.  If you get any other, such as a 404, something is wrong with your query or you're not coming from the right IP address.

K5MRE
« Last Edit: May 08, 2019, 12:36:52 pm by K5MRE »

Share on Facebook Share on Twitter


Offline WB3IHY

  • Newbie
  • *
  • Posts: 27
  • Referrals: 0
Re: Using the API
« Reply #1 on: May 08, 2019, 05:48:59 pm »
Heh.  I was wondering if/when this would actually be published.  Had all my favorite talkgroups (plus 4000 disconnect) bookmarked ever since I saw the code on Mitch's Github and figured out how it worked.

Kept it to myself too, since I wasn't sure if doing that was officially "allowed" outside use on Mitch's screens.

Commandment number one: Thou shalt not "hack" the API...LOL.

Offline K5MRE

  • Newbie
  • *
  • Posts: 21
  • Referrals: 0
Re: Using the API
« Reply #2 on: May 08, 2019, 07:31:39 pm »
Ha!  No worries at all.  Enjoy!

Offline KD4IIW

  • Newbie
  • *
  • Posts: 7
  • Referrals: 0
Re: Using the API
« Reply #3 on: September 26, 2019, 01:40:04 pm »
Is there a way to add an API to the pi-star software like the brandmeister network has created?