JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Gallery
Doc Explorer Pack [Tutorial]
Share
Explore
Gallery
Doc Explorer Pack [Tutorial]
Doc Explorer
Doc Tables
Column Data
Doc Pages
Doc Permissions
Working Code
Activity Detail
Date Controls
Goals
Untitled
Gear
Databases
DB Sync Activities
DB Achievements
DB Activities
DB Months
DB Types
Untitled
Controls for Months
Example Document
My Achievements
My Swims
My Runs
My Rides
Year Breakdown
Working Code
import
*
as
coda
from
"@codahq/packs-sdk"
;
export
const
pack = coda.newPack();
pack.setUserAuthentication({
type
: coda.
AuthenticationType
.
OAuth2
,
authorizationUrl:
"https://www.strava.com/oauth/authorize"
,
tokenUrl:
"https://www.strava.com/oauth/token"
,
scopes: [
"activity:read_all"
]
});
pack.addNetworkDomain(
"strava.com"
);
const
activitySchema = coda.makeObjectSchema({
properties: {
name:{
description:
"The name you gave the activity"
,
type
: coda.
ValueType
.
String
,
},
distance: {
description:
"How far you went!"
,
type
: coda.
ValueType
.
Number
},
moving_time: {
description:
"How long you were out minus stops/breaks"
,
type
: coda.
ValueType
.
Number
},
elapsed_time: {
description:
"How long you were actually out"
,
type
: coda.
ValueType
.
Number
},
total_elevation_gain: {
description:
"Total elevation gain"
,
type
: coda.
ValueType
.
Number
},
"type"
: {
description:
"The type of activity (run, ride, swim, etc)"
,
type
: coda.
ValueType
.
String
},
id: {
description:
"The ID of the activity, can be inputted into URL to locate"
,
type
: coda.
ValueType
.
Number
},
start_date: {
description:
"When the activity took place"
,
type
: coda.
ValueType
.
String
},
average_speed: {
description:
"How fast you went on average"
,
type
: coda.
ValueType
.
Number
},
max_speed: {
description:
"Your fastest recorded speed"
,
type
: coda.
ValueType
.
Number
}
},
primary:
"name"
,
id:
"id"
,
identity: {
name:
"Activity"
}
});
pack.addSyncTable({
name:
"Activities"
,
schema: activitySchema,
identityName:
"Activities"
,
formula: {
name:
"SyncActivities"
,
description:
"Sync all your Strava activities"
,
parameters: [],
execute:
async
function
([],context){
let
url =
"https://www.strava.com/api/v3/athlete/activities?per_page=100"
;
let
response =
await
context.fetcher.fetch({
method:
"GET"
,
url: url
});
let
items = response.body
return
{
result: items,
}
}
}
})
Gallery
Share
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.