LAT LabAPI Open LAT Lab Get an API key

LAT Lab API

The adherence model, from your own programs.

Send a request, get numbers back. Find parameters that match a target adherence, simulate a whole population, or follow one person offer by offer.

A free account has 2 credits a day; one credit is one answered call. Need more? Ask for Pro access: support@twinai.net.

POST /api/simulate LAT model 200 OK

Start in three steps

1

Create a free account

Sign up with your email and confirm it with the 6 digit code we send you.

Create an account
2

Make an API key

Open API keys in your account and make a key. It is shown once, so keep it somewhere safe.

Open API keys
3

Send it with every request

Put the key in the x-api-key header. That is all the sign-in the API needs.

See the endpoints
curl -X POST https://latlab.twinai.net/api/calibrate \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "screening_interval": 3, "target_adherence": 0.65 }'

Endpoints

Three calls, all POST with a JSON body. The API runs the model with logistic growth and Hill decay for ages 45 to 74. Adherence values are fractions from 0 to 1; shares of people (pct_) are percentages.

POST/api/calibrate

Find parameters for a target

Looks up parameter sets whose overall adherence matches your target, in a large table of parameter sets computed in advance. Fast, and each result comes with its full set of outcomes. The answer always says whether your request was met: if nothing fits, met is false, warning says why, and closest lists the nearest sets.

FieldWhat it is
screening_interval requiredYears between screenings: 1, 2, 3, 5 or 10
target_adherence requiredOverall adherence you want, from 0 to 0.8
toleranceHow far from the target a result may be. Default 0.01
constraintsObject with max_never_screener and min_always_screener, in percent
sort_byadherence_distance (default), never_screener or always_screener
limitMost results to return. Default 20
curl -X POST https://latlab.twinai.net/api/calibrate \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "screening_interval": 3,
    "target_adherence": 0.65,
    "tolerance": 0.02,
    "limit": 5
  }'
Example answer
{
  "results": [
    {
      "parameters": { "P_0": 0.6, "P_max": 0.65, "r_g": 0.4, "L": 0.21, "K": 18, "n": 5 },
      "screening_interval": 3,
      "adherence": { "mean": 0.65, "std": 0.129, "median": 0.643,
                     "ci_lower": 0.639, "ci_upper": 0.661, "q1": 0.571, "q3": 0.75 },
      "subpopulations": { "pct_never_screener": 0, "pct_always_screener": 0.8,
                          "pct_early_adopter": 99, "pct_intermittent": 99.2 },
      "age_brackets": { "early": { "mean": 0.66, "std": 0.206 },
                        "middle": { "mean": 0.692, "std": 0.218 },
                        "late": { "mean": 0.673, "std": 0.22 } }
    }
  ],
  "query": { "screening_interval": 3, "target_adherence": 0.65, "tolerance": 0.02, "limit": 5 },
  "count": 1,
  "met": true,
  "computation_time_ms": 11
}
When nothing fits
{
  "results": [],
  "count": 0,
  "met": false,
  "warning": "No parameter set meets these constraints at this screening interval. ...",
  "closest": [
    { "parameters": { "P_0": 0.6, "P_max": 0.65, "r_g": 0.4, "L": 0.21, "K": 18, "n": 5 },
      "adherence": { "mean": 0.5, "...": "..." },
      "adherence_distance": 0.0 }
  ]
}
POST/api/simulate

Simulate a population

Runs the model for a population with the parameters you give and returns overall adherence, its spread, the groups and three age bands.

FieldWhat it is
parameters requiredObject with the six model parameters, see below
screening_interval requiredYears between screenings: 1, 2, 3, 5 or 10
population_sizePeople to simulate. Default 1,000, at most 10,000
seedAny text. The same seed gives the same result
Inside parameters
P_0Chance of attending the first offer. Above 0, below 1
P_maxHighest the chance can climb. Above P_0, at most 1
r_gGrowth rate. Above 0
LLowest the chance can fall. From 0, below P_0
KYears to fall halfway to the floor. Above 0
nHow sharply the fall sets in. Above 0
curl -X POST https://latlab.twinai.net/api/simulate \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "parameters": {
      "P_0": 0.12, "P_max": 0.85, "r_g": 0.3,
      "L": 0.05, "K": 8, "n": 2.5
    },
    "screening_interval": 3,
    "population_size": 1000
  }'
Example answer
{
  "parameters": { "P_0": 0.12, "P_max": 0.85, "r_g": 0.3, "L": 0.05, "K": 8, "n": 2.5 },
  "screening_interval": 3,
  "population_size": 1000,
  "adherence": { "mean": 0.308, "std": 0.251, "median": 0.25, "min": 0, "max": 1,
                 "ci_lower": 0.293, "ci_upper": 0.324, "q1": 0.077, "q3": 0.5 },
  "subpopulations": { "pct_never_screener": 10.4, "pct_always_screener": 0.4,
                      "pct_early_adopter": 47.2, "pct_intermittent": 89.2 },
  "age_brackets": { "early": { "mean": 0.194, "std": 0.215 },
                    "middle": { "mean": 0.35, "std": 0.326 },
                    "late": { "mean": 0.503, "std": 0.37 } },
  "computation_time_ms": 21
}
POST/api/trajectory

Follow one person

Returns one person's path, offer by offer: the age, the chance of attending, whether they attended, and whether the chance was growing or fading.

FieldWhat it is
parameters requiredThe same six parameters as for /api/simulate
screening_interval requiredYears between screenings: 1, 2, 3, 5 or 10
seedAny text. The same seed gives the same person
curl -X POST https://latlab.twinai.net/api/trajectory \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "parameters": {
      "P_0": 0.12, "P_max": 0.85, "r_g": 0.3,
      "L": 0.05, "K": 8, "n": 2.5
    },
    "screening_interval": 3,
    "seed": "patient_42"
  }'
Example answer
{
  "parameters": { "P_0": 0.12, "P_max": 0.85, "r_g": 0.3, "L": 0.05, "K": 8, "n": 2.5 },
  "screening_interval": 3,
  "trajectory": [
    { "age": 45, "probability": 0.12, "screened": false, "phase": "growth",
      "t_nc": 0, "anchor_p": 0.12, "anchor_age": 45 },
    { "age": 46, "probability": 0.1196, "screened": true, "phase": "decay",
      "t_nc": 1, "anchor_p": 0.12, "anchor_age": 45 }
  ],
  "summary": { "adherence_rate": 0.036, "screenings_completed": 1, "total_opportunities": 28 },
  "computation_time_ms": 0
}

Try it

Paste your key, choose a call and press Run. The key stays in this page and is not saved. Each run that gets a result uses one credit.

The answer appears here.

Answers and limits

StatusWhat it means
200The result, as JSON
400Something in the request is missing or out of range. The error field says what. It costs no credit
401No key, an unknown or revoked key, or the email of the key's account is not confirmed
429The credits of today are used up. They start again the next day (UTC)
Header of every answerWhat it tells you
X-RateLimit-LimitCredits your account has per day, or unlimited
X-RateLimit-RemainingCredits left today
X-RateLimit-ResetThe day the count belongs to (UTC)

Two addresses need no key: GET /api lists the endpoints, and GET /api/health answers { "status": "ok" }.

Questions: support@twinai.net