# API: Get today's rate?

**URL:** <https://forum.beeminder.com/t/api-get-todays-rate/5122>\
**Category:** Tech\
**Created:** [March 20, 2019, 4:32pm UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122 "2019-03-20T16:32:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![narthur](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/narthur/32/5113_2.png) [@narthur](https://forum.beeminder.com/u/narthur)\
**Post date:** [March 20, 2019, 4:32pm UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122/1 "2019-03-20T16:32:25Z")

</div>

I’m working on a script that I would like to exit prematurely if the current rate is not greater than zero, in order to respect breaks. I see that goals returned by the API have a `rate` attribute, but it’s defined as follows:

> The slope of the (final section of the) yellow brick road

I don’t think that’s what I want, since I want the current rate, regardless of what the road ends up doing.

How can I get today’s rate for a goal?

---

<div class="post-metadata">

**Author:** ![phi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/phi/32/2586_2.png) [@phi](https://forum.beeminder.com/u/phi)\
**Post date:** [March 20, 2019, 6:30pm UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122/2 "2019-03-20T18:30:23Z")

</div>

Oh I got an answer to that question!

> **but you won't like it ;)**
>
> Just fetch the SVG, extract the path of the YBR, look for the vertical line that marks today, take the path segment at the intersection…

---

<div class="post-metadata">

**Author:** ![narthur](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/narthur/32/5113_2.png) [@narthur](https://forum.beeminder.com/u/narthur)\
**Post date:** [March 20, 2019, 7:41pm UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122/3 "2019-03-20T19:41:26Z")

</div>

Haha! I like the creativity, but, wow… I wasn’t really planning on writing an SVG parser. 😜

---

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [March 20, 2019, 8:38pm UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122/4 "2019-03-20T20:38:17Z")

</div>

I think you need to get the `roadall` matrix and find the first row with date \> today. Does that make sense? Possibly the API should make a common thing like that easier so it’s very good that you’re asking things like this as they come up (and other people should chime in or click ❤ too!).

---

<div class="post-metadata">

**Author:** ![narthur](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/narthur/32/5113_2.png) [@narthur](https://forum.beeminder.com/u/narthur)\
**Post date:** [March 20, 2019, 9:26pm UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122/5 "2019-03-20T21:26:22Z")

</div>

Trying to understand.

> - `road` (array): Array of tuples that can be used to construct the Yellow Brick Road. This field is also known as the road matrix. Each tuple specifies 2 out of 3 of [`time` , `goal` , `rate`]. To construct the road, start with a known starting point (time, value) and then each row of the road matrix specifies 2 out of 3 of {t,v,r} which gives the segment ending at time t. You can walk forward filling in the missing 1-out-of-3 from the (time, value) in the previous row.

So I’d find the first segment with an ending time after now, and use the specified rate.

But sometimes rate isn’t specified, goal is. And I’m guessing goal is the bottom edge of the YBR at that particular moment? So, in that case, I’d have to do some sort of geometry to figure out what the rate is?

But if, for example, all the other points specify rate and not goal, then I’d have to calculate the entire YBR from the beginning in order to figure out the rate of the segment of interest, yes?

Or am I thinking about this wrong?

---

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [March 20, 2019, 9:47pm UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122/6 "2019-03-20T21:47:50Z")

</div>

Ah, sorry, you want `fullroad` – that is like `roadall` but with all the nulls filled in.

---

<div class="post-metadata">

**Author:** ![phi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/phi/32/2586_2.png) [@phi](https://forum.beeminder.com/u/phi)\
**Post date:** [March 20, 2019, 11:06pm UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122/7 "2019-03-20T23:06:29Z")

</div>

What about this so inconspicuously named attribute of the `goal` resource?

- `mathishard` (array of 3 numbers): The goaldate, goalval, and rate — all filled in. (The road dial specifies 2 out of 3 and you can check this if you want Beeminder to do the math for you on inferring the third one.)

Edit: Ah, right, akrasia horizon, nvm!

---

<div class="post-metadata">

**Author:** ![narthur](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/narthur/32/5113_2.png) [@narthur](https://forum.beeminder.com/u/narthur)\
**Post date:** [March 20, 2019, 11:56pm UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122/8 "2019-03-20T23:56:27Z")

</div>

I’m not catching the significance of the horizon. Care to share what you discovered?

---

<div class="post-metadata">

**Author:** ![phi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/phi/32/2586_2.png) [@phi](https://forum.beeminder.com/u/phi)\
**Post date:** [March 21, 2019, 12:05am UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122/9 "2019-03-21T00:05:02Z")

</div>

The `mathishard` (who came up with this name? 😛 ) attribute corresponds to this, right?

 ![image](https://us1.discourse-cdn.com/flex019/uploads/beeminder/original/2X/6/6b234ef9c6ff23ac015652cef8356d614c748b6b.jpeg)  
Which is not the _current_ rate but what the rate will be one $akrasiaHorizon from now.

---

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [March 21, 2019, 2:00am UTC](https://forum.beeminder.com/t/api-get-todays-rate/5122/10 "2019-03-21T02:00:38Z")

</div>

Affirmative. And “mathishard” sounds equally likely to have been me or @bee or @apb. I bet it was Andy. It’s pretty great, right? But oh my goodness does the API need a v2. So much cruft!
