diff --git a/README.md b/README.md index 0494d7d..0285dd6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ This client can be used in both JavaScript and TypeScript projects; and both in browser and Node environment. - Since using this client in browser would expose your API key to the public, it is more secure to use it in server-side applications. Using it in browser is only recommended for personal projects and @@ -75,12 +74,110 @@ npm i streaming-availability ### Via Script Tag from CDN ```html - + ``` This script creates a global variable at `window.streamingAvailability` where you can access to the module. +## Usage + +### Node + +```ts +import * as streamingAvailability from "streaming-availability"; + +const RAPID_API_KEY = ""; + +const client = new streamingAvailability.Client(new streamingAvailability.Configuration({ + apiKey: RAPID_API_KEY +})); + +// Start using the client +``` + +### Script Tag + +```html + + + + + Example + + + + + + +``` + +## Examples + +### Get The Godfather's Streaming Availability Info + +```ts +import * as streamingAvailability from "streaming-availability"; + +const RAPID_API_KEY = ""; + +const client = new streamingAvailability.Client(new streamingAvailability.Configuration({ + apiKey: RAPID_API_KEY +})); + +let show = await client.showsApi.getShow( + {id: "tt0068646", country: "us"} +); + +console.log(show.title); +console.log(show.overview); +show.streamingOptions["us"].forEach((streamingOption) => { + console.log(streamingOption.link); +}); +``` + +#### Via Script Tag + +```html + + + + + The Godfather + + + + + + +``` + +> Checkout [examples](https://github.com/movieofthenight/ts-streaming-availability/blob/main/examples) +folder for the rest of the examples. + ## Terms & Conditions and Attribution While the client libraries have MIT licenses, diff --git a/docs/assets/highlight.css b/docs/assets/highlight.css index 61ac331..66a2c77 100644 --- a/docs/assets/highlight.css +++ b/docs/assets/highlight.css @@ -13,6 +13,20 @@ --dark-hl-5: #9CDCFE; --light-hl-6: #0000FF; --dark-hl-6: #CE9178; + --light-hl-7: #AF00DB; + --dark-hl-7: #C586C0; + --light-hl-8: #0000FF; + --dark-hl-8: #569CD6; + --light-hl-9: #A31515; + --dark-hl-9: #CE9178; + --light-hl-10: #0070C1; + --dark-hl-10: #4FC1FF; + --light-hl-11: #795E26; + --dark-hl-11: #DCDCAA; + --light-hl-12: #008000; + --dark-hl-12: #6A9955; + --light-hl-13: #EE0000; + --dark-hl-13: #D7BA7D; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @@ -25,6 +39,13 @@ --hl-4: var(--light-hl-4); --hl-5: var(--light-hl-5); --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); + --hl-9: var(--light-hl-9); + --hl-10: var(--light-hl-10); + --hl-11: var(--light-hl-11); + --hl-12: var(--light-hl-12); + --hl-13: var(--light-hl-13); --code-background: var(--light-code-background); } } @@ -36,6 +57,13 @@ --hl-4: var(--dark-hl-4); --hl-5: var(--dark-hl-5); --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); + --hl-9: var(--dark-hl-9); + --hl-10: var(--dark-hl-10); + --hl-11: var(--dark-hl-11); + --hl-12: var(--dark-hl-12); + --hl-13: var(--dark-hl-13); --code-background: var(--dark-code-background); } } @@ -47,6 +75,13 @@ --hl-4: var(--light-hl-4); --hl-5: var(--light-hl-5); --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); + --hl-9: var(--light-hl-9); + --hl-10: var(--light-hl-10); + --hl-11: var(--light-hl-11); + --hl-12: var(--light-hl-12); + --hl-13: var(--light-hl-13); --code-background: var(--light-code-background); } @@ -58,6 +93,13 @@ --hl-4: var(--dark-hl-4); --hl-5: var(--dark-hl-5); --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); + --hl-9: var(--dark-hl-9); + --hl-10: var(--dark-hl-10); + --hl-11: var(--dark-hl-11); + --hl-12: var(--dark-hl-12); + --hl-13: var(--dark-hl-13); --code-background: var(--dark-code-background); } @@ -68,4 +110,11 @@ .hl-4 { color: var(--hl-4); } .hl-5 { color: var(--hl-5); } .hl-6 { color: var(--hl-6); } +.hl-7 { color: var(--hl-7); } +.hl-8 { color: var(--hl-8); } +.hl-9 { color: var(--hl-9); } +.hl-10 { color: var(--hl-10); } +.hl-11 { color: var(--hl-11); } +.hl-12 { color: var(--hl-12); } +.hl-13 { color: var(--hl-13); } pre, code { background: var(--code-background); } diff --git a/docs/index.html b/docs/index.html index a97185b..db9e284 100644 --- a/docs/index.html +++ b/docs/index.html @@ -54,10 +54,22 @@

Requires Node version 18.0.0 or higher.

-

Via Script Tag from CDN

<script src="https://cdn.jsdelivr.net/gh/movieofthenight/ts-streaming-availability@v4.0.2/bundle.min.js"></script>
+

Via Script Tag from CDN

<script src="https://cdn.jsdelivr.net/gh/movieofthenight/ts-streaming-availability@v4.0.3/bundle.min.js"></script>
 

This script creates a global variable at window.streamingAvailability where you can access to the module.

+

Usage

Node

import * as streamingAvailability from "streaming-availability";

const RAPID_API_KEY = "<YOUR_RAPID_API_KEY>";

const client = new streamingAvailability.Client(new streamingAvailability.Configuration({
apiKey: RAPID_API_KEY
}));

// Start using the client +
+

Script Tag

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example</title>
</head>
<body style="white-space: pre-line">
<script src="https://cdn.jsdelivr.net/gh/movieofthenight/ts-streaming-availability@v4.0.3/bundle.min.js"></script>
<script type="module">
const RAPID_API_KEY = "<YOUR_RAPID_API_KEY>";

const client = new streamingAvailability.Client(new streamingAvailability.Configuration({
apiKey: RAPID_API_KEY
}));

// Start using the client
</script>
</body>
</html> +
+

Examples

Get The Godfather's Streaming Availability Info

import * as streamingAvailability from "streaming-availability";

const RAPID_API_KEY = "<YOUR_RAPID_API_KEY>";

const client = new streamingAvailability.Client(new streamingAvailability.Configuration({
apiKey: RAPID_API_KEY
}));

let show = await client.showsApi.getShow(
{id: "tt0068646", country: "us"}
);

console.log(show.title);
console.log(show.overview);
show.streamingOptions["us"].forEach((streamingOption) => {
console.log(streamingOption.link);
}); +
+

Via Script Tag

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>The Godfather</title>
</head>
<body style="white-space: pre-line">
<script src="https://cdn.jsdelivr.net/gh/movieofthenight/ts-streaming-availability@v4.0.3/bundle.min.js"></script>
<script type="module">
const RAPID_API_KEY = "<YOUR_RAPID_API_KEY>";

const client = new streamingAvailability.Client(new streamingAvailability.Configuration({
apiKey: RAPID_API_KEY
}));

let show = await client.showsApi.getShow(
{id: "tt0068646", country: "us"}
);
document.body.textContent = show.title + "\r\n";
document.body.textContent += show.overview + "\r\n";
show.streamingOptions["us"].forEach((streamingOption) => {
document.body.textContent += streamingOption.link + "\r\n";
});
</script>
</body>
</html> +
+
+

Checkout examples +folder for the rest of the examples.

+

Terms & Conditions and Attribution

While the client libraries have MIT licenses, the Streaming Availability API itself has further Terms & Conditions. @@ -462,4 +474,4 @@ South Africa -

\ No newline at end of file +
\ No newline at end of file diff --git a/examples/netflix-popular-action-movies/README.md b/examples/netflix-popular-action-movies/README.md new file mode 100644 index 0000000..5b660e8 --- /dev/null +++ b/examples/netflix-popular-action-movies/README.md @@ -0,0 +1,12 @@ +# Netflix Popular Action Movies + +This example shows how to get the most popular action movies from Netflix. + +## How to Run + +Update `RAPID_API_KEY` constant with your own API key. Then: + +```shell + npm install + npm start +``` diff --git a/examples/netflix-popular-action-movies/index.js b/examples/netflix-popular-action-movies/index.js new file mode 100644 index 0000000..94e30df --- /dev/null +++ b/examples/netflix-popular-action-movies/index.js @@ -0,0 +1,25 @@ +import * as streamingAvailability from "streaming-availability"; + +const RAPID_API_KEY = ""; + +const client = new streamingAvailability.Client(new streamingAvailability.Configuration({ + apiKey: RAPID_API_KEY +})); + +let searchResult = await client.showsApi.searchShowsByFilters(({ + country: "us", + catalogs: ["netflix"], + genres: ["action"], + showType: streamingAvailability.ShowType.Movie, + orderBy: "popularity_1year", +})) + +searchResult.shows.forEach((show) => { + console.log(show.title); + console.log(show.overview); + show.streamingOptions["us"].forEach((streamingOption) => { + if(streamingOption.service.id === "netflix") { + console.log(streamingOption.link); + } + }); +}); diff --git a/examples/netflix-popular-action-movies/index.ts b/examples/netflix-popular-action-movies/index.ts new file mode 100644 index 0000000..a796477 --- /dev/null +++ b/examples/netflix-popular-action-movies/index.ts @@ -0,0 +1,25 @@ +import * as streamingAvailability from "streaming-availability"; + +const RAPID_API_KEY = ""; + +const client = new streamingAvailability.Client(new streamingAvailability.Configuration({ + apiKey: RAPID_API_KEY +})); + +let searchResult = await client.showsApi.searchShowsByFilters(({ + country: "us", + catalogs: ["netflix"], + genres: ["action"], + showType: streamingAvailability.ShowType.Movie, + orderBy: "popularity_1year", +})) + +searchResult.shows.forEach((show) => { + console.log(show.title); + console.log(show.overview); + show.streamingOptions["us"].forEach((streamingOption) => { + if(streamingOption.service.id === "netflix") { + console.log(streamingOption.link); + } + }); +}); diff --git a/examples/netflix-popular-action-movies/package.json b/examples/netflix-popular-action-movies/package.json new file mode 100644 index 0000000..818d97e --- /dev/null +++ b/examples/netflix-popular-action-movies/package.json @@ -0,0 +1,19 @@ +{ + "name": "netflix-popular-action-movies", + "version": "1.0.0", + "description": "Get the most popular action movies on Netflix", + "main": "index.js", + "scripts": { + "start": "tsc && node index.js" + }, + "keywords": [], + "author": "Movie of the Night", + "license": "MIT", + "devDependencies": { + "typescript": "^5.4.5" + }, + "dependencies": { + "streaming-availability": "4.x" + }, + "type": "module" +} diff --git a/examples/netflix-popular-action-movies/tsconfig.json b/examples/netflix-popular-action-movies/tsconfig.json new file mode 100644 index 0000000..4d283fe --- /dev/null +++ b/examples/netflix-popular-action-movies/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "es2022", + "module": "node16", + "moduleResolution": "node16", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } +} diff --git a/examples/the-godfather/package-lock.json b/examples/the-godfather/package-lock.json deleted file mode 100644 index 2a69f09..0000000 --- a/examples/the-godfather/package-lock.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "client-test", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "client-test", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "streaming-availability": "^4.0.1" - }, - "devDependencies": { - "typescript": "^5.4.5" - } - }, - "node_modules/streaming-availability": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/streaming-availability/-/streaming-availability-4.0.1.tgz", - "integrity": "sha512-OEHeq5anXEO5kk2k4VOYMZVUt7TfESdgnzzKu0doiSH7o5Wo8BI+uA1Dc/0zESfiNq01kPRQm7JgsbUNCzZbtA==", - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - } - } -} diff --git a/examples/the-godfather/package.json b/examples/the-godfather/package.json index c96643d..2465ea5 100644 --- a/examples/the-godfather/package.json +++ b/examples/the-godfather/package.json @@ -13,7 +13,7 @@ "typescript": "^5.4.5" }, "dependencies": { - "streaming-availability": "^4.0.1" + "streaming-availability": "4.x" }, "type": "module" } diff --git a/package-lock.json b/package-lock.json index a8d05a3..e46a8ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "streaming-availability", - "version": "v4.0.2", + "version": "v4.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "streaming-availability", - "version": "v4.0.2", + "version": "v4.0.3", "license": "MIT", "devDependencies": { "@types/node": "^20.12.7", diff --git a/package.json b/package.json index 2641bcc..d30e297 100644 --- a/package.json +++ b/package.json @@ -45,5 +45,5 @@ "test": "ts-node test/test.ts" }, "typings": "./dist/index.d.ts", - "version": "v4.0.2" + "version": "v4.0.3" }