Platform
Resources
Pricing
Sign in
Contact us
Fred Snyder
Workspace
Fork
Public
Public API Explorations
By
Fred Snyder
Edited
Mar 17, 2023
Public API Explorations
TheSportsDB.com
Ergast Motor Racing Data
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// get the data based on the year selection
dataPerYear
=
fetch
(
`https://ergast.com/api/f1/${
year
}/status.json`
)
.
then
(
(
response
)
=>
response
.
json
(
)
)
.
then
(
(
el
)
=>
el
.
MRData
.
StatusTable
.
Status
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataPerYear
Filter
Columns
Sort
Slice
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
Insert cell
Insert cell
Insert cell
allYearsStatus
=
{
return
await
Promise
.
all
(
yearsArr
.
map
(
async
(
year
)
=>
{
const
response
=
await
fetch
(
`https://ergast.com/api/f1/${
year
}/status.json`
)
;
const
data
=
await
response
.
json
(
)
;
return
{
year
:
year
,
collision
:
parseInt
(
data
.
MRData
.
StatusTable
.
Status
.
filter
(
el
=>
el
.
status
===
"Collision"
)
.
map
(
el
=>
el
.
count
)
.
join
(
)
)
,
accident
:
parseInt
(
data
.
MRData
.
StatusTable
.
Status
.
filter
(
el
=>
el
.
status
===
"Accident"
)
.
map
(
el
=>
el
.
count
)
.
join
(
)
)
}
;
}
)
)
}
Insert cell
allYearsStatus
Filter
Columns
Sort
Slice
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
viewof
statSel
=
Inputs
.
select
(
[
"collision"
,
"accident"
]
,
{
label
:
"Select stat"
}
)
Insert cell
Plot
.
plot
(
{
marks
:
[
Plot
.
barY
(
allYearsStatus
,
{
x
:
"year"
,
y
:
statSel
,
fill
:
"year"
}
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dataPerYear
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
yearsArr
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
Cells
dataPerYear
File attachments
Databases
Filter
Column
Operator
Columns
Sort
Column
Direction
Descending
Ascending
Slice
From
Start
To
End
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
allYearsStatus
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
Cells
allYearsStatus
File attachments
Databases
Filter
Column
Operator
Columns
Sort
Column
Direction
Descending
Ascending
Slice
From
Start
To
End
statSel
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML