Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
yashkathe committed Dec 29, 2022
1 parent acbca4c commit ccf1253
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 49 deletions.
89 changes: 51 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,12 @@

The scraper scrapes this website: https://www.formula1.com

## Installation
# Installation
```bash
npm i f1-api-node
```
## Functions

- **getConstructorStandings**

Fetch Constructors standings from points table.
The function takes one argument: The year from which you want to extract points table for.
Default argument is the current year.

- **getDriverStandings**
Fetch F1 driver standings from points table.
The function takes one argument: The year from which you want to extract points table for.
Default argument is the current year.

- **getDriverData**
Fetch the current lineup of F1 drivers.
_No arguments_

- **getTeamsData**
Fetch the current list of F1 teams along with their information.
_No arguments_
# Example snippet

- **getWorldChampions**
Fetch all the world champions
_No arguments_

- **getRaceResults**
Fetch race results for all the grand prix in a given year.
The function takes one argument: The year from which you want to extract race results.

## Snapshots

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__).

## Example snippet

Example on how to use one of the given functions.
The following function will print the current lineup of F1 drivers.

```javascript
Expand All @@ -57,10 +23,57 @@ const myFunction = async () => {
myFunction()
```

## Usage
# Functions

### **1. getConstructorStandings**

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


### **2. getDriverStandings**

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


### **3. getDriverLineup**

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


### **4. getTeamLineup**
| Description | Needs Paramter ? | Paramter Description | Default Argument |
|:------------|------------------|----------------------|------------------|
| Fetch the current list of F1 teams | No | - | - |


### **5. getWorldChampions**
| Description | Needs Paramter ? | Paramter Description | Default Argument |
|:------------|------------------|----------------------|------------------|
| Fetch all the world champions | No | - | - |


### **6. getRaceResults**
| Description | Needs Paramter ? | Paramter Description | Default Argument |
|:------------|------------------|----------------------|------------------|
| 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) | - |


# Snapshots

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__).



# Usage
WARNING: Abusing this library may result in an IP ban from the host website.
Please use with caution and try to limit the rate and amount of your requests if you value your access to formula1.com

## Report Problems
# Report Problems

If you have any problems regarding this project, read the following [disclaimer](https://github.com/yashkathe/F1-API/blob/master/DISCLAIMER.md).
4 changes: 2 additions & 2 deletions __tests__/driver-lineup.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getDriverLineups } from "../src/server";
import { getDriverLineup } from "../src/server";

test("current driver lineup", async () => {
expect(await getDriverLineups()).toMatchSnapshot();
expect(await getDriverLineup()).toMatchSnapshot();
});
4 changes: 2 additions & 2 deletions __tests__/team-lineup.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getTeamLineups } from "../src/server";
import { getTeamLineup } from "../src/server";

test("current teams data", async () => {
expect(await getTeamLineups()).toMatchSnapshot();
expect(await getTeamLineup()).toMatchSnapshot();
});
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "f1-api-node",
"version": "0.3.1",
"version": "0.3.2",
"description": "A simple library written in typescript to fetch Formula-1 data",
"main": "dist/server.js",
"types": "dist/server.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/scraper/driver-lineup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { staticLinks } from "../endpoints/endpoints";

import { isDriver } from "../types/types";

export const getDriverLineups = async (): Promise<isDriver[]> => {
export const getDriverLineup = async (): Promise<isDriver[]> => {
try {
let drivers: isDriver[] = [];

Expand Down
2 changes: 1 addition & 1 deletion src/scraper/team-lineup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { staticLinks } from "../endpoints/endpoints";

import { isTeam } from "../types/types";

export const getTeamLineups = async (): Promise<isTeam[]> => {
export const getTeamLineup = async (): Promise<isTeam[]> => {
try {
let teams: isTeam[] = [];

Expand Down
4 changes: 2 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { getDriverLineups } from "./scraper/driver-lineup";
export { getTeamLineups } from "./scraper/team-lineup";
export { getDriverLineup } from "./scraper/driver-lineup";
export { getTeamLineup } from "./scraper/team-lineup";
export { getDriverStandings } from "./scraper/driver-standings";
export { getConstructorStandings } from "./scraper/constructors-standings";
export { getWorldChampions } from "./scraper/world-champions";
Expand Down

0 comments on commit ccf1253

Please sign in to comment.