@crawlora-org/sofascore 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -4
- package/package.json +1 -1
- package/src/index.js +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @crawlora-org/sofascore
|
|
2
2
|
|
|
3
3
|
JavaScript and TypeScript client for Crawlora's hosted SofaScore API.
|
|
4
|
-
It calls Crawlora
|
|
4
|
+
It calls [Crawlora](https://crawlora.net); it does not run a browser or scrape SofaScore locally. A Crawlora account and `CRAWLORA_API_KEY` are required, and API use is billed under your Crawlora account. Crawlora is independent from and not endorsed by SofaScore or its owners.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
@@ -9,14 +9,29 @@ It calls Crawlora's service; it does not run a browser or scrape SofaScore local
|
|
|
9
9
|
npm install @crawlora-org/sofascore
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
## Get an API key
|
|
13
|
+
|
|
14
|
+
Create an account at [crawlora.net](https://crawlora.net/signup), then open the [Crawlora console](https://crawlora.net/app) for API-key setup. Set your key in the shell before running the client:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
export CRAWLORA_API_KEY="your-crawlora-api-key"
|
|
18
|
+
```
|
|
19
|
+
|
|
12
20
|
## Use
|
|
13
21
|
|
|
22
|
+
Save this example as `example.mjs`, then run `node example.mjs` after installing the package and setting your API key.
|
|
23
|
+
|
|
14
24
|
```js
|
|
25
|
+
import process from "node:process";
|
|
15
26
|
import { SofascoreClient } from "@crawlora-org/sofascore";
|
|
16
27
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
const apiKey = process.env.CRAWLORA_API_KEY;
|
|
29
|
+
if (!apiKey) throw new Error("Set CRAWLORA_API_KEY before running this example.");
|
|
30
|
+
const client = new SofascoreClient({ apiKey });
|
|
31
|
+
const result1 = await client.search({ q: "Liverpool" });
|
|
32
|
+
console.log(result1);
|
|
33
|
+
const result2 = await client.liveEvents({ sport: "football" });
|
|
34
|
+
console.log(result2);
|
|
20
35
|
```
|
|
21
36
|
|
|
22
37
|
The client also exports `Client` as an alias for `SofascoreClient`. Operation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlora-org/sofascore",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Typed JavaScript client for the Crawlora SofaScore API",
|
|
5
5
|
"homepage": "https://github.com/Crawlora-org/crawlora-sofascore#readme",
|
|
6
6
|
"bugs": { "url": "https://github.com/Crawlora-org/crawlora-sofascore/issues" },
|
package/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
|
|
10
10
|
export class SofascoreClient extends CrawloraClient {
|
|
11
11
|
constructor(options = {}) {
|
|
12
|
-
super({ ...options, userAgent: options.userAgent ?? "crawlora-sofascore-js/0.1.
|
|
12
|
+
super({ ...options, userAgent: options.userAgent ?? "crawlora-sofascore-js/0.1.3" });
|
|
13
13
|
this["event"] = (...args) => this.request("sofascore-event", ...args);
|
|
14
14
|
this["eventH2h"] = (...args) => this.request("sofascore-event-h2h", ...args);
|
|
15
15
|
this["eventIncidents"] = (...args) => this.request("sofascore-event-incidents", ...args);
|
|
@@ -37,5 +37,5 @@ export {
|
|
|
37
37
|
CrawloraServerError
|
|
38
38
|
};
|
|
39
39
|
export { groups, operations, operationCount, OperationIds } from "./operations.js";
|
|
40
|
-
export const VERSION = "0.1.
|
|
40
|
+
export const VERSION = "0.1.3";
|
|
41
41
|
export default SofascoreClient;
|