KosmoKrator

other

Strava Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Strava KosmoKrator integration.

6 functions 5 read 1 write Bearer token auth

Lua Namespace

Agents call this integration through app.integrations.strava.*. Use lua_read_doc("integrations.strava") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Strava — Lua API Reference

list_activities

List recent activities for the authenticated Strava athlete. Supports pagination and date filtering.

Parameters

NameTypeRequiredDescription
pageintegernoPage number (default: 1)
per_pageintegernoActivities per page (default: 30, max: 200)
beforeintegernoUnix timestamp — return activities before this time
afterintegernoUnix timestamp — return activities after this time

Examples

List recent activities

local result = app.integrations.strava.list_activities({
  per_page = 5
})

for _, activity in ipairs(result) do
  print(activity.name .. " — " .. activity.type .. " — " .. activity.start_date)
end

Filter activities by date range

local result = app.integrations.strava.list_activities({
  after = 1704067200,   -- 2024-01-01
  before = 1706745600,  -- 2024-02-01
  per_page = 50
})

get_activity

Get detailed information about a specific Strava activity.

Parameters

NameTypeRequiredDescription
activity_idintegeryesThe ID of the activity to retrieve

Example

local result = app.integrations.strava.get_activity({
  activity_id = 1234567890
})

print(result.name)
print("Distance: " .. (result.distance / 1000) .. " km")
print("Moving time: " .. result.moving_time .. " seconds")
print("Elevation gain: " .. result.total_elevation_gain .. " m")

create_activity

Create a manual activity on Strava.

Parameters

NameTypeRequiredDescription
namestringyesName of the activity (e.g., “Morning Run”)
typestringyesActivity type: Run, Ride, Swim, Hike, Walk, Workout, WeightTraining, Yoga, etc.
start_date_localstringyesISO 8601 local start date/time (e.g., “2025-01-15T09:30:00”)
elapsed_timeintegeryesElapsed time in seconds
descriptionstringnoDescription of the activity
distancenumbernoDistance in meters
trainerintegernoSet to 1 if trainer/trainer ride
commuteintegernoSet to 1 if commute

Example

local result = app.integrations.strava.create_activity({
  name = "Morning Run",
  type = "Run",
  start_date_local = "2025-01-15T09:30:00",
  elapsed_time = 1800,
  distance = 5000,
  description = "Easy 5K run in the park"
})

print("Created activity: " .. result.id .. " — " .. result.name)

get_athlete

Get the authenticated athlete’s Strava profile.

Parameters

None.

Example

local result = app.integrations.strava.get_athlete({})

print(result.firstname .. " " .. result.lastname)
print("Followers: " .. result.follower_count)
print("Following: " .. result.friend_count)
print("City: " .. (result.city or "N/A"))
print("Country: " .. (result.country or "N/A"))

list_clubs

List clubs the authenticated athlete belongs to.

Parameters

NameTypeRequiredDescription
pageintegernoPage number (default: 1)
per_pageintegernoClubs per page (default: 30)

Example

local result = app.integrations.strava.list_clubs({
  per_page = 10
})

for _, club in ipairs(result) do
  print(club.name .. " — " .. club.sport_type .. " — " .. club.member_count .. " members")
end

get_current_user

Get the current authenticated user’s Strava profile. This is an alias for get_athlete.

Parameters

None.

Example

local result = app.integrations.strava.get_current_user({})

print("Logged in as: " .. result.firstname .. " " .. result.lastname)

Multi-Account Usage

If you have multiple Strava accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.strava.list_activities({})

-- Explicit default (portable across setups)
app.integrations.strava.default.list_activities({})

-- Named accounts
app.integrations.strava.personal.list_activities({})
app.integrations.strava.team.list_activities({})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# Strava — Lua API Reference

## list_activities

List recent activities for the authenticated Strava athlete. Supports pagination and date filtering.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number (default: 1) |
| `per_page` | integer | no | Activities per page (default: 30, max: 200) |
| `before` | integer | no | Unix timestamp — return activities before this time |
| `after` | integer | no | Unix timestamp — return activities after this time |

### Examples

#### List recent activities

```lua
local result = app.integrations.strava.list_activities({
  per_page = 5
})

for _, activity in ipairs(result) do
  print(activity.name .. " — " .. activity.type .. " — " .. activity.start_date)
end
```

#### Filter activities by date range

```lua
local result = app.integrations.strava.list_activities({
  after = 1704067200,   -- 2024-01-01
  before = 1706745600,  -- 2024-02-01
  per_page = 50
})
```

---

## get_activity

Get detailed information about a specific Strava activity.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `activity_id` | integer | yes | The ID of the activity to retrieve |

### Example

```lua
local result = app.integrations.strava.get_activity({
  activity_id = 1234567890
})

print(result.name)
print("Distance: " .. (result.distance / 1000) .. " km")
print("Moving time: " .. result.moving_time .. " seconds")
print("Elevation gain: " .. result.total_elevation_gain .. " m")
```

---

## create_activity

Create a manual activity on Strava.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Name of the activity (e.g., "Morning Run") |
| `type` | string | yes | Activity type: Run, Ride, Swim, Hike, Walk, Workout, WeightTraining, Yoga, etc. |
| `start_date_local` | string | yes | ISO 8601 local start date/time (e.g., "2025-01-15T09:30:00") |
| `elapsed_time` | integer | yes | Elapsed time in seconds |
| `description` | string | no | Description of the activity |
| `distance` | number | no | Distance in meters |
| `trainer` | integer | no | Set to 1 if trainer/trainer ride |
| `commute` | integer | no | Set to 1 if commute |

### Example

```lua
local result = app.integrations.strava.create_activity({
  name = "Morning Run",
  type = "Run",
  start_date_local = "2025-01-15T09:30:00",
  elapsed_time = 1800,
  distance = 5000,
  description = "Easy 5K run in the park"
})

print("Created activity: " .. result.id .. " — " .. result.name)
```

---

## get_athlete

Get the authenticated athlete's Strava profile.

### Parameters

None.

### Example

```lua
local result = app.integrations.strava.get_athlete({})

print(result.firstname .. " " .. result.lastname)
print("Followers: " .. result.follower_count)
print("Following: " .. result.friend_count)
print("City: " .. (result.city or "N/A"))
print("Country: " .. (result.country or "N/A"))
```

---

## list_clubs

List clubs the authenticated athlete belongs to.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number (default: 1) |
| `per_page` | integer | no | Clubs per page (default: 30) |

### Example

```lua
local result = app.integrations.strava.list_clubs({
  per_page = 10
})

for _, club in ipairs(result) do
  print(club.name .. " — " .. club.sport_type .. " — " .. club.member_count .. " members")
end
```

---

## get_current_user

Get the current authenticated user's Strava profile. This is an alias for `get_athlete`.

### Parameters

None.

### Example

```lua
local result = app.integrations.strava.get_current_user({})

print("Logged in as: " .. result.firstname .. " " .. result.lastname)
```

---

## Multi-Account Usage

If you have multiple Strava accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.strava.list_activities({})

-- Explicit default (portable across setups)
app.integrations.strava.default.list_activities({})

-- Named accounts
app.integrations.strava.personal.list_activities({})
app.integrations.strava.team.list_activities({})
```

All functions are identical across accounts — only the credentials differ.

Metadata-Derived Lua Example

local result = app.integrations.strava.strava_create_activity({
  name = "example_name",
  type = "example_type",
  start_date_local = "example_start_date_local",
  elapsed_time = 1,
  description = "example_description",
  distance = 1,
  trainer = 1,
  commute = 1
})
print(result)

Functions

strava_create_activity

Create a manual activity on Strava. Requires a name, activity type, start date, and elapsed time in seconds.

Operation
Write write
Full name
strava.strava_create_activity
ParameterTypeRequiredDescription
name string yes Name of the activity (e.g., "Morning Run").
type string yes Activity type: Run, Ride, Swim, Hike, Walk, Workout, WeightTraining, Yoga, etc.
start_date_local string yes ISO 8601 local start date and time (e.g., "2025-01-15T09:30:00").
elapsed_time integer yes Elapsed time in seconds.
description string no Description of the activity.
distance number no Distance in meters.
trainer integer no Set to 1 if this is a trainer/trainer ride activity.
commute integer no Set to 1 if this is a commute activity.

strava_get_activity

Get detailed information about a specific Strava activity, including distance, pace, elevation, and splits.

Operation
Read read
Full name
strava.strava_get_activity
ParameterTypeRequiredDescription
activity_id integer yes The ID of the activity to retrieve.

strava_get_athlete

Get the authenticated athlete's Strava profile — name, location, follower/following counts, and stats.

Operation
Read read
Full name
strava.strava_get_athlete
ParameterTypeRequiredDescription
No parameters.

strava_get_current_user

Get the current authenticated user's Strava profile. This is an alias for strava_get_athlete — returns name, location, follower/following counts, and stats.

Operation
Read read
Full name
strava.strava_get_current_user
ParameterTypeRequiredDescription
No parameters.

strava_list_activities

List recent activities for the authenticated Strava athlete. Supports pagination and date filtering with before/after Unix timestamps.

Operation
Read read
Full name
strava.strava_list_activities
ParameterTypeRequiredDescription
page integer no Page number (default: 1).
per_page integer no Number of activities per page (default: 30, max: 200).
before integer no Unix timestamp — return activities before this time.
after integer no Unix timestamp — return activities after this time.

strava_list_clubs

List clubs the authenticated Strava athlete belongs to. Returns club names, member counts, and sport types.

Operation
Read read
Full name
strava.strava_list_clubs
ParameterTypeRequiredDescription
page integer no Page number (default: 1).
per_page integer no Number of clubs per page (default: 30).