# API: Get today's rate?

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?

2 Likes

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…

2 Likes

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

2 Likes

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!).

2 Likes

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?

1 Like

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

3 Likes

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!

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

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

Which is not the current rate but what the rate will be one \$akrasiaHorizon from now.

2 Likes

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!

4 Likes