Skip to content

Commit d38c848

Browse files
committed
fix fastest_laps function error and race results error and update readme
1 parent 53b6af3 commit d38c848

17 files changed

+355
-61
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ src
22
__tests__
33
node_modules
44
junk
5+
readme
56
jest.config.jest
67
.prettierrc.json
78
.vscode

README.md

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,17 @@
11
# Formula1 API
22

3+
**Completely Updated and Adjusted according to the New Changes in Formula 1's Website ~ 2025!**
4+
35
![f1](https://logodownload.org/wp-content/uploads/2016/11/formula-1-logo-7.png)
46

57
The scraper scrapes this website: <https://www.formula1.com>
68

7-
**Completely Updated According to the F1 New Website Changes ~ 2025!**
8-
99
## Installation
1010

1111
```bash
1212
npm i f1-api-node
1313
```
1414

15-
## Accessing API through Docker
16-
17-
The docker image of the rest api can be found on [Docker Hub](https://hub.docker.com/repository/docker/katheyash/f1-api-node/general)
18-
19-
- ### Pull the Image and start the development in no time
20-
21-
#### 1. Pull from Docker Hub
22-
23-
```bash
24-
docker push katheyash/f1-api-node:tagname
25-
```
26-
27-
#### 2. Pull from Github Container Registry
28-
29-
```bash
30-
docker pull ghcr.io/yashkathe/f1-api-node:2
31-
```
32-
33-
- ### The default port is 80
34-
35-
```bash
36-
docker run -p 80:80 --name f1-api-node-test-1 katheyash/f1-api-node:1
37-
```
38-
39-
- ### If .env file exists
40-
41-
```bash
42-
docker run --env-file ./.env -p 3001:3001 --name f1-api-node-test-1 f1-api-node:1
43-
```
44-
4515
## Example snippet
4616

4717
The following function will print the current lineup of F1 drivers.
@@ -50,7 +20,7 @@ The following function will print the current lineup of F1 drivers.
5020
const f1Api = require('f1-api-node')
5121

5222
const myFunction = async () => {
53-
const driverLineup = await f1Api.getDriverData()
23+
const driverLineup = await f1Api.getDriverData() // replace this function
5424
console.log(driverLineup)
5525
}
5626

@@ -65,37 +35,49 @@ myFunction()
6535
|:------------|------------------|----------------------|------------------|
6636
| Fetch Constructors standings from points table | Yes - 1 | The year from which you want to extract points table for (1950 - current) | current year |
6737

38+
![const stnd](./readme/constructor_standing.png)
39+
6840
### **2. getDriverStandings**
6941

7042
| Description | Needs Paramter ? | Paramter Description | Default Argument |
7143
|:------------|------------------|----------------------|------------------|
7244
| Fetch F1 driver standings from points table | Yes - 1 | The year from which you want to extract points table for (1950 - current) | current year |
7345

46+
![driver stnd](./readme/constructor_standing.png)
47+
7448
### **3. getDriverLineup**
7549

7650
| Description | Needs Paramter ? | Paramter Description | Default Argument |
7751
|:------------|------------------|----------------------|------------------|
7852
| Fetch the current lineup of F1 drivers | No | - | - |
7953

54+
![driver lineup](./readme/driver_lineup.png)
55+
8056
### **4. getTeamLineup**
8157

8258
| Description | Needs Paramter ? | Paramter Description | Default Argument |
8359
|:------------|------------------|----------------------|------------------|
8460
| Fetch the current list of F1 teams | No | - | - |
8561

62+
![team lineup](./readme/team_lineup.png)
63+
8664
### **5. getWorldChampions**
8765

8866
| Description | Needs Paramter ? | Paramter Description | Default Argument |
8967
|:------------|------------------|----------------------|------------------|
9068
| Fetch all the world champions | No | - | - |
9169

92-
### **6. getRaceResults**
70+
![hall of fame](./readme/world_champion.png)
71+
72+
### **6. getRaceResults** - **[Does Not Work]**
9373

9474
| Description | Needs Paramter ? | Paramter Description | Default Argument |
9575
|:------------|------------------|----------------------|------------------|
9676
| Fetch race results of all the grand prix in a given year | Yes - 1 | The year from which you want to extract race results (1950 - current) | - |
9777

98-
### **7. getRaceSchedule**
78+
![race results](./readme/race_results.png)
79+
80+
### **7. getRaceSchedule** [DOES NOT WORK]
9981

10082
| Description | Needs Paramter ? | Paramter Description | Default Argument |
10183
|:------------|------------------|----------------------|------------------|
@@ -107,10 +89,42 @@ myFunction()
10789
|:------------|------------------|----------------------|------------------|
10890
| Fetch fastest laps for all races in a year | Yes - 1 | The year from which you want to extract fastest laps | current year |
10991

92+
![fastest lap](./readme/fastest_lap.png)
93+
11094
## Snapshots
11195

11296
If you want to have a look at the output from the given functions check [this](https://github.com/yashkathe/F1-API/tree/master/__tests__/__snapshots__).
11397

98+
## Accessing API through Docker
99+
100+
The docker image of the rest api can be found on [Docker Hub](https://hub.docker.com/repository/docker/katheyash/f1-api-node/general)
101+
102+
- ### Pull the Image and start the development in no time
103+
104+
#### 1. Pull from Docker Hub
105+
106+
```bash
107+
docker push katheyash/f1-api-node:tagname
108+
```
109+
110+
#### 2. Pull from Github Container Registry
111+
112+
```bash
113+
docker pull ghcr.io/yashkathe/f1-api-node:2
114+
```
115+
116+
- ### The default port is 80
117+
118+
```bash
119+
docker run -p 80:80 --name f1-api-node-test-1 katheyash/f1-api-node:1
120+
```
121+
122+
- ### If .env file exists
123+
124+
```bash
125+
docker run --env-file ./.env -p 3001:3001 --name f1-api-node-test-1 f1-api-node:1
126+
```
127+
114128
## Usage
115129

116130
WARNING: Abusing this library may result in an IP ban from the host website.

__tests__/__snapshots__/fastest-laps.test.ts.snap

Lines changed: 142 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,148 @@
33
exports[`fastest laps 1`] = `
44
[
55
{
6-
"car": "McLaren MercedesMcLaren Mercedes",
7-
"driver": "LandoLando NorrisNorris",
8-
"grandPrix": "AustraliaChina",
9-
"time": "1:22.1671:35.454",
6+
"car": "Red Bull Racing Honda RBPT",
7+
"driver": "Max Verstappen",
8+
"grandPrix": "Bahrain",
9+
"time": "1:32.608",
10+
},
11+
{
12+
"car": "Ferrari",
13+
"driver": "Charles Leclerc",
14+
"grandPrix": "Saudi Arabia",
15+
"time": "1:31.632",
16+
},
17+
{
18+
"car": "Ferrari",
19+
"driver": "Charles Leclerc",
20+
"grandPrix": "Australia",
21+
"time": "1:19.813",
22+
},
23+
{
24+
"car": "Red Bull Racing Honda RBPT",
25+
"driver": "Max Verstappen",
26+
"grandPrix": "Japan",
27+
"time": "1:33.706",
28+
},
29+
{
30+
"car": "Aston Martin Aramco Mercedes",
31+
"driver": "Fernando Alonso",
32+
"grandPrix": "China",
33+
"time": "1:37.810",
34+
},
35+
{
36+
"car": "McLaren Mercedes",
37+
"driver": "Oscar Piastri",
38+
"grandPrix": "Miami",
39+
"time": "1:30.634",
40+
},
41+
{
42+
"car": "Mercedes",
43+
"driver": "George Russell",
44+
"grandPrix": "Emilia-Romagna",
45+
"time": "1:18.589",
46+
},
47+
{
48+
"car": "Mercedes",
49+
"driver": "Lewis Hamilton",
50+
"grandPrix": "Monaco",
51+
"time": "1:14.165",
52+
},
53+
{
54+
"car": "Mercedes",
55+
"driver": "Lewis Hamilton",
56+
"grandPrix": "Canada",
57+
"time": "1:14.856",
58+
},
59+
{
60+
"car": "McLaren Mercedes",
61+
"driver": "Lando Norris",
62+
"grandPrix": "Spain",
63+
"time": "1:17.115",
64+
},
65+
{
66+
"car": "Aston Martin Aramco Mercedes",
67+
"driver": "Fernando Alonso",
68+
"grandPrix": "Austria",
69+
"time": "1:07.694",
70+
},
71+
{
72+
"car": "Ferrari",
73+
"driver": "Carlos Sainz",
74+
"grandPrix": "Great Britain",
75+
"time": "1:28.293",
76+
},
77+
{
78+
"car": "Mercedes",
79+
"driver": "George Russell",
80+
"grandPrix": "Hungary",
81+
"time": "1:20.305",
82+
},
83+
{
84+
"car": "Red Bull Racing Honda RBPT",
85+
"driver": "Sergio Perez",
86+
"grandPrix": "Belgium",
87+
"time": "1:44.701",
88+
},
89+
{
90+
"car": "McLaren Mercedes",
91+
"driver": "Lando Norris",
92+
"grandPrix": "Netherlands",
93+
"time": "1:13.817",
94+
},
95+
{
96+
"car": "McLaren Mercedes",
97+
"driver": "Lando Norris",
98+
"grandPrix": "Italy",
99+
"time": "1:21.432",
100+
},
101+
{
102+
"car": "McLaren Mercedes",
103+
"driver": "Lando Norris",
104+
"grandPrix": "Azerbaijan",
105+
"time": "1:45.255",
106+
},
107+
{
108+
"car": "RB Honda RBPT",
109+
"driver": "Daniel Ricciardo",
110+
"grandPrix": "Singapore",
111+
"time": "1:34.486",
112+
},
113+
{
114+
"car": "Alpine Renault",
115+
"driver": "Esteban Ocon",
116+
"grandPrix": "United States",
117+
"time": "1:37.330",
118+
},
119+
{
120+
"car": "Ferrari",
121+
"driver": "Charles Leclerc",
122+
"grandPrix": "Mexico",
123+
"time": "1:18.336",
124+
},
125+
{
126+
"car": "Red Bull Racing Honda RBPT",
127+
"driver": "Max Verstappen",
128+
"grandPrix": "Brazil",
129+
"time": "1:20.472",
130+
},
131+
{
132+
"car": "McLaren Mercedes",
133+
"driver": "Lando Norris",
134+
"grandPrix": "Las Vegas",
135+
"time": "1:34.876",
136+
},
137+
{
138+
"car": "McLaren Mercedes",
139+
"driver": "Lando Norris",
140+
"grandPrix": "Qatar",
141+
"time": "1:22.384",
142+
},
143+
{
144+
"car": "Haas Ferrari",
145+
"driver": "Kevin Magnussen",
146+
"grandPrix": "Abu Dhabi",
147+
"time": "1:25.637",
10148
},
11149
]
12150
`;

0 commit comments

Comments
 (0)