├── .prettierrc.json
├── .dockerignore
├── .husky
└── pre-commit
├── public
├── robots.txt
├── favicon.ico
├── logo192.png
├── logo512.png
├── manifest.json
└── index.html
├── src
├── index.css
├── setupTests.js
├── App.test.js
├── reportWebVitals.js
├── index.js
├── components
│ ├── apiInfo.js
│ ├── contributorInfo.js
│ ├── header.js
│ └── content.js
├── App.css
├── cards
│ ├── boredAPI.js
│ ├── randomAdvice.js
│ ├── chuckNorrisJoke.js
│ ├── tronalddump.jsx
│ ├── RandomKanyeQuote.jsx
│ ├── randomFoodPics.js
│ ├── RandomDogimage.js
│ ├── RandomDuckAPI.js
│ ├── quoteClearAPI.js
│ ├── randomGotQuotes.js
│ ├── starWarsAPI.js
│ ├── randomPoemsAPI.jsx
│ ├── RandomCatimages.js
│ ├── RandomBriyaniPics.js
│ ├── randomDadJoke.js
│ ├── randomCarImage.js
│ ├── UsaCovidCases.jsx
│ ├── randomFoxImage.js
│ ├── randomCatFacts.jsx
│ ├── coffeApi.jsx
│ ├── PageVisits.jsx
│ ├── randomDadJokes.jsx
│ ├── randomGeekJokes.jsx
│ ├── randomDogfacts.js
│ ├── ZipCodeDetailsAPI.js
│ ├── covidApi.js
│ ├── randomJokeApi.jsx
│ ├── NasaApi.js
│ ├── MemesApi.js
│ ├── randomAnime.js
│ ├── randomQuotes.js
│ ├── SpacexcrewAPI.jsx
│ ├── HistoryOfTheDay.jsx
│ ├── BeerApi.js
│ ├── breadPuns.js
│ ├── PublicApiApi.js
│ ├── GenderGuess.js
│ ├── randomCreditCard.jsx
│ ├── robohash.js
│ ├── RandomAnimeSeries.js
│ ├── RandomValorantWeapon.js
│ ├── foaasapi.js
│ ├── GetIcon.js
│ ├── RandomMovieQuote.jsx
│ ├── ricknmortyApi.js
│ ├── randomPlaceholderImage.js
│ ├── bookDetails.js
│ ├── PasswordGenerator.jsx
│ ├── dogWithAnimeQuotes.js
│ ├── url-shortener.jsx
│ ├── MusicPlayer.js
│ ├── githubUser.js
│ ├── giphyapi.js
│ ├── Sunshinetime.js
│ ├── RandomAdage.jsx
│ ├── SimpleAdd.jsx
│ ├── EvaluateMath.jsx
│ ├── HaikuSyllableCounter.jsx
│ ├── imageCompressionAPI.jsx
│ ├── Dungeons.jsx
│ ├── publicholiday.js
│ ├── weatherApi.js
│ ├── weatherApi2.jsx
│ ├── TrendingRepositories.js
│ ├── pokeAPI.js
│ ├── cryptoDetails.js
│ ├── RandomProfile.js
│ ├── Movies.js
│ ├── fakeStoreAPI.js
│ └── ageCalculator.js
├── github.svg
├── logo.svg
└── App.js
├── craco.config.js
├── Dockerfile
├── tailwind.config.js
├── .gitignore
├── .prettierignore
├── .github
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ └── ci.yml
├── LICENSE.md
├── CONTRIBUTING.md
├── package.json
├── CODE_OF_CONDUCT.md
└── README.md
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | **/node_modules
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | npx lint-staged
5 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vedangj044/just-calling-random-api/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vedangj044/just-calling-random-api/HEAD/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vedangj044/just-calling-random-api/HEAD/public/logo512.png
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | /* ./src/index.css */
2 | @tailwind base;
3 | @tailwind components;
4 | @tailwind utilities;
5 |
--------------------------------------------------------------------------------
/craco.config.js:
--------------------------------------------------------------------------------
1 | // craco.config.js
2 | module.exports = {
3 | style: {
4 | postcss: {
5 | plugins: [require("tailwindcss"), require("autoprefixer")],
6 | },
7 | },
8 | };
9 |
--------------------------------------------------------------------------------
/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import "@testing-library/jest-dom";
6 |
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from "@testing-library/react";
2 | import App from "./App";
3 |
4 | test("renders learn react link", () => {
5 | render( );
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:12-alpine as builder
2 |
3 | WORKDIR /app
4 |
5 | COPY . .
6 |
7 | RUN sed -i "s/https:\/\/vedangj044.github.io\/just-calling-random-api/\./g" package.json
8 |
9 | RUN npm install
10 |
11 | RUN npm run build
12 |
13 |
14 | FROM nginx:1.17.1-alpine
15 |
16 | COPY --from=builder /app/build/ /usr/share/nginx/html
--------------------------------------------------------------------------------
/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = (onPerfEntry) => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/tailwind.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | purge: ["./src/**/*.{js,jsx,ts,tsx}", "./public/index.html"],
3 | darkMode: false, // or 'media' or 'class'
4 | theme: {
5 | fontFamily: {
6 | body: ["Montserrat", "sans-serif"],
7 | },
8 | extend: {},
9 | },
10 | variants: {
11 | extend: {
12 | backgroundColor: ["active"],
13 | opacity: ["disabled"],
14 | },
15 | },
16 | plugins: [],
17 | };
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 | .idea/
21 | .env
22 | npm-debug.log*
23 | yarn-debug.log*
24 | yarn-error.log*
25 |
26 | README.old.md
27 | .vscode
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 | .idea/
21 | .env
22 | npm-debug.log*
23 | yarn-debug.log*
24 | yarn-error.log*
25 |
26 | README.old.md
27 | .vscode
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import "./index.css";
4 | import App from "./App";
5 | import reportWebVitals from "./reportWebVitals";
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById("root")
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Description
2 |
3 | Please include the details of the API used in this PR.
4 |
5 | ## Screenshot
6 |
7 | Optional
8 |
9 |
10 | Checklist
11 |
12 | - [ ] API used in this PR was not used in just-calling-random-api before.
13 | - [ ] API used in this PR is Public or I have permission to use it.
14 | - [ ] My contribution is working.
15 | - [ ] My contribution doesn't expose any API keys.
16 | - [ ] My changes don't generate any new warnings.
17 | - [ ] My changes don't affect any work done by other developers.
18 |
19 | To tick a box, replace `[ ]` with `[x]`.
20 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/src/components/apiInfo.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | export default function ApiInfo(props) {
4 | return (
5 |
6 |
7 |
12 |
{props.apiName}
13 |
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/src/components/contributorInfo.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | export default function ContributorInfo(props) {
4 | return (
5 |
6 |
7 |
12 |
{props.username}
13 |
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/components/header.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import github from "../github.svg";
3 |
4 | export default function Header(props) {
5 | return (
6 |
25 | );
26 | }
27 |
--------------------------------------------------------------------------------
/src/cards/boredAPI.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function RandomActivity(props) {
6 | const [response, setResponse] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://www.boredapi.com/api/activity")
10 | .then((res) => res.json())
11 | .then((data) => setResponse(data.activity));
12 | }, []);
13 |
14 | return (
15 |
16 |
Random Activity
17 |
{response}
18 |
19 |
23 |
24 |
25 | );
26 | }
27 |
--------------------------------------------------------------------------------
/src/cards/randomAdvice.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function RandomAdvice(props) {
6 | const [response, setResponse] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://api.adviceslip.com/advice")
10 | .then((resp) => resp.json())
11 | .then((data) => setResponse(data.slip.advice));
12 | }, []);
13 |
14 | return (
15 |
16 |
Random Advice API
17 |
{response}
18 |
19 |
23 |
24 |
25 | );
26 | }
27 |
--------------------------------------------------------------------------------
/src/cards/chuckNorrisJoke.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function ChuckNorrisJoke() {
6 | const [response, setResponse] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://api.chucknorris.io/jokes/random")
10 | .then((resp) => resp.json())
11 | .then((data) => setResponse(data.value));
12 | }, []);
13 |
14 | return (
15 |
16 |
Random Chuck Norris Joke API
17 |
{response}
18 |
19 |
23 |
24 |
25 | );
26 | }
27 |
--------------------------------------------------------------------------------
/src/cards/tronalddump.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function TronaldDump(props) {
6 | const [Quote, setQuote] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://api.tronalddump.io/random/quote")
10 | .then((res) => res.json())
11 | .then((data) => setQuote(data.value));
12 | }, []);
13 |
14 | return (
15 |
16 |
17 |
Tronald Dump
18 |
{Quote}
19 |
23 |
24 |
25 |
26 | );
27 | }
28 |
--------------------------------------------------------------------------------
/src/cards/RandomKanyeQuote.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function RandomKanyeQuote(props) {
6 | const [kanyeQuote, setKanyeQuote] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://api.kanye.rest")
10 | .then((res) => res.json())
11 | .then((data) => setKanyeQuote(data.quote));
12 | }, []);
13 | return (
14 |
15 |
16 |
Random Kanye West Quotes
17 |
{kanyeQuote}
18 |
22 |
23 |
24 |
25 | );
26 | }
27 |
--------------------------------------------------------------------------------
/src/cards/randomFoodPics.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import ApiInfo from "../components/apiInfo";
3 | import ContributorInfo from "../components/contributorInfo";
4 |
5 | export default function RandomFoodPicApi() {
6 | const [foodImg, setImg] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://foodish-api.herokuapp.com/api/")
10 | .then((res) => res.json())
11 | .then((data) => setImg(data.image));
12 | }, []);
13 |
14 | return (
15 |
16 |
Random Food Pic API
17 |
18 |
19 |
23 |
27 |
28 | );
29 | }
30 |
--------------------------------------------------------------------------------
/src/cards/RandomDogimage.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function RandomDogimage(props) {
6 | const [dogImage, setdogImage] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://dog.ceo/api/breeds/image/random")
10 | .then((res) => res.json())
11 | .then((data) => setdogImage(data.message));
12 | }, []);
13 | return (
14 |
15 |
16 |
Random Dog images
17 |
18 |
19 |
23 |
24 |
25 |
26 | );
27 | }
28 |
--------------------------------------------------------------------------------
/src/cards/RandomDuckAPI.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ApiInfo from "../components/apiInfo";
3 | import ContributorInfo from "../components/contributorInfo";
4 |
5 | const RandomDuckApi = () => {
6 | const [img, setImg] = useState("");
7 | useEffect(() => {
8 | fetch("https://random-d.uk/api/v2/random")
9 | .then((res) => res.json())
10 | .then((res) => {
11 | setImg(res.url);
12 | })
13 | .catch((err) => {
14 | console.log("error:", err);
15 | });
16 | }, []);
17 | return (
18 |
19 |
Random Duck API
20 |
21 |
25 |
26 |
27 | );
28 | };
29 |
30 | export default RandomDuckApi;
31 |
--------------------------------------------------------------------------------
/src/cards/quoteClearAPI.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import ApiInfo from "../components/apiInfo";
3 | import ContributorInfo from "../components/contributorInfo";
4 |
5 | const QuoteClearAPI = () => {
6 | const [quote, setQuote] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://quoteclear.web.app/api/random")
10 | .then((res) => res.json())
11 | .then((data) => {
12 | //console.log(data)
13 | setQuote(data.text);
14 | });
15 | }, []);
16 | // console.log(quote)
17 | return (
18 |
19 |
Quote Clear API
20 |
{quote}
21 |
22 |
26 |
30 |
31 | );
32 | };
33 |
34 | export default QuoteClearAPI;
35 |
--------------------------------------------------------------------------------
/src/cards/randomGotQuotes.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function RandomGotQuotes(props) {
6 | const [response, setResponse] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://game-of-thrones-quotes.herokuapp.com/v1/random")
10 | .then((resp) => resp.json())
11 | .then((data) => setResponse(data.sentence));
12 | }, []);
13 |
14 | return (
15 |
16 |
17 | Game Of Thrones Quotes
18 |
19 |
{response}
20 |
21 |
25 |
29 |
30 | );
31 | }
32 |
--------------------------------------------------------------------------------
/src/cards/starWarsAPI.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function StarWarsAPI(props) {
6 | const [response, setResponse] = useState("");
7 |
8 | useEffect(() => {
9 | fetch(
10 | `https://swapi.dev/api/people/${Math.floor(
11 | Math.random() * 50
12 | )}?format=json`
13 | )
14 | .then((resp) => resp.json())
15 | .then((data) => setResponse(data.name));
16 | }, []);
17 |
18 | return (
19 |
20 |
The Star Wars API
21 |
22 | Random Star Wars character: {response}
23 |
24 |
25 |
29 |
30 |
31 | );
32 | }
33 |
--------------------------------------------------------------------------------
/src/cards/randomPoemsAPI.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const Poemist = () => {
7 | const [randomPoem, setrandomPoem] = useState("");
8 | useEffect(() => {
9 | axios.get("https://www.poemist.com/api/v1/randompoems").then((res) => {
10 | setrandomPoem(res.data.title);
11 | });
12 | }, []);
13 | return (
14 |
15 |
16 |
Random Poems
17 |
{randomPoem}
18 |
19 |
23 |
27 |
28 |
29 | );
30 | };
31 |
32 | export default Poemist;
33 |
--------------------------------------------------------------------------------
/src/github.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Vedang Joshi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/cards/RandomCatimages.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function RandomCatimages(props) {
6 | const [catImage, setcatImage] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://aws.random.cat/meow")
10 | .then((res) => res.json())
11 | .then((data) => setcatImage(data.file))
12 | .catch((err) => {
13 | console.log("error:", err);
14 | });
15 | }, []);
16 | return (
17 |
18 |
19 |
Random Cat images
20 |
21 |
22 |
26 |
30 |
31 |
32 | );
33 | }
34 |
--------------------------------------------------------------------------------
/src/cards/RandomBriyaniPics.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const RandomBriyaniPics = () => {
7 | const [Pics, setPics] = useState("");
8 | useEffect(() => {
9 | axios.get("https://biriyani.anoram.com/get").then((res) => {
10 | setPics(res.data.image);
11 | });
12 | }, []);
13 |
14 | return (
15 |
16 |
17 |
Random Briyani Pics
18 |
19 |
23 |
27 |
28 |
29 | );
30 | };
31 |
32 | export default RandomBriyaniPics;
33 |
--------------------------------------------------------------------------------
/src/cards/randomDadJoke.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function RandomDadJoke(props) {
6 | const [response, setResponse] = useState("");
7 |
8 | useEffect(() => {
9 | fetch("https://icanhazdadjoke.com/", {
10 | headers: {
11 | Accept: "application/json",
12 | },
13 | })
14 | .then((resp) => resp.json())
15 | .then((data) => setResponse(data.joke))
16 | .catch((err) => {
17 | console.log("error:", err);
18 | });
19 | }, []);
20 |
21 | return (
22 |
23 |
Random Dad Joke API
24 |
{response}
25 |
26 |
30 |
34 |
35 | );
36 | }
37 |
--------------------------------------------------------------------------------
/src/cards/randomCarImage.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 |
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 | import axios from "axios";
6 |
7 | const BASE_URL = "https://forza-api.tk/";
8 |
9 | const RandomCarImage = () => {
10 | const [data, setData] = useState({ image: "" });
11 | const fetchData = async () => {
12 | const response = await axios.get(BASE_URL);
13 | if (response.status !== 200) {
14 | throw new Error("Fetching err");
15 | }
16 | setData(response?.data);
17 | };
18 |
19 | useEffect(() => {
20 | fetchData();
21 | }, []);
22 |
23 | return (
24 |
25 |
Random Car Image
26 |
27 |
28 |
32 |
33 |
34 | );
35 | };
36 |
37 | export default RandomCarImage;
38 |
--------------------------------------------------------------------------------
/src/cards/UsaCovidCases.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const CovidUsaCases = () => {
7 | const [Cases, setCases] = useState("");
8 | useEffect(() => {
9 | axios.get("https://disease.sh/v3/covid-19/countries/usa").then((res) => {
10 | setCases(res.data.cases);
11 | });
12 | }, []);
13 |
14 | return (
15 |
16 |
17 |
Covid Usa Cases
18 |
USA Covid Cases: {Cases}
19 |
20 |
24 |
28 |
29 |
30 | );
31 | };
32 |
33 | export default CovidUsaCases;
34 |
--------------------------------------------------------------------------------
/src/cards/randomFoxImage.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 |
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 | import axios from "axios";
6 |
7 | const BASE_URL = "https://randomfox.ca/floof/";
8 |
9 | const RandomFoxImage = () => {
10 | const [data, setData] = useState({ image: "", link: "" });
11 | const fetchData = async () => {
12 | const response = await axios.get(BASE_URL);
13 | if (response.status !== 200) {
14 | throw new Error("Fetching err");
15 | }
16 | setData(response?.data);
17 | };
18 |
19 | useEffect(() => {
20 | fetchData();
21 | }, []);
22 |
23 | return (
24 |
25 |
Random Fox Image
26 |
27 |
28 |
32 |
33 |
34 | );
35 | };
36 |
37 | export default RandomFoxImage;
38 |
--------------------------------------------------------------------------------
/src/cards/randomCatFacts.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const RandomCatFacts = () => {
7 | const [catFact, setCatFact] = useState("");
8 | useEffect(() => {
9 | axios.get("https://meowfacts.herokuapp.com/").then((res) => {
10 | // console.log(res.data);
11 | setCatFact(res.data.data[0]);
12 | });
13 | }, []);
14 | // console.log(catFact);
15 | return (
16 |
17 |
18 |
19 | Random Cat Facts
20 |
21 |
{catFact}
22 |
23 |
27 |
31 |
32 |
33 | );
34 | };
35 |
36 | export default RandomCatFacts;
37 |
--------------------------------------------------------------------------------
/src/cards/coffeApi.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | const CoffeApi = () => {
6 | const [response, setResponse] = useState(null);
7 |
8 | useEffect(() => {
9 | fetch("https://asli-fun-fact-api.herokuapp.com/")
10 | .then((res) => res.json())
11 | .then(({ data }) => {
12 | setResponse(data.fact);
13 | console.log(data.fact);
14 | });
15 | }, []);
16 | return (
17 |
18 |
Fun Fact API
19 |
20 | {response !== null ? (
21 |
22 |
{response}
23 |
24 | ) : null}
25 |
26 |
30 |
34 |
35 | );
36 | };
37 |
38 | export default CoffeApi;
39 |
--------------------------------------------------------------------------------
/src/cards/PageVisits.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ApiInfo from "../components/apiInfo";
3 | import ContributorInfo from "../components/contributorInfo";
4 |
5 | const PageVisits = () => {
6 | const [status, setStatus] = useState("");
7 |
8 | useEffect(() => {
9 | const dk = async () => {
10 | let data = await fetch(
11 | "https://api.countapi.xyz/hit/vedangj044.just-calling-random-api/visits"
12 | );
13 | const ans = await data.json();
14 | setStatus(ans.value);
15 | };
16 | dk();
17 | }, []);
18 |
19 | return (
20 |
21 |
Welcome !!
22 |
26 |
You are the visitor {status} :)
27 |
28 |
29 |
33 |
34 |
35 | );
36 | };
37 |
38 | export default PageVisits;
39 |
--------------------------------------------------------------------------------
/src/cards/randomDadJokes.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const RandomDadJokes = () => {
7 | const [dadJoke, setdadJoke] = useState("");
8 | useEffect(() => {
9 | axios.get("https://dadjokes.io/").then((res) => {
10 | // axios.get("https://rapidapi.com/KegenGuyll/api/dad-jokes/details").then((res) => {
11 | // console.log(res.data);
12 | setdadJoke(res.data.joke);
13 | });
14 | }, []);
15 | // console.log(dadJoke);
16 | return (
17 |
18 |
19 |
Random Dad Jokes
20 |
{dadJoke}
21 |
22 |
26 |
30 |
31 |
32 | );
33 | };
34 |
35 | export default RandomDadJokes;
36 |
--------------------------------------------------------------------------------
/src/cards/randomGeekJokes.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const RandomGeekJokes = () => {
7 | const [geekJoke, setgeekJoke] = useState("");
8 | useEffect(() => {
9 | axios
10 | .get("https://geek-jokes.sameerkumar.website/api?format=json")
11 | .then((res) => {
12 | // console.log(res.data);
13 | setgeekJoke(res.data.joke);
14 | });
15 | }, []);
16 | // console.log(geekJoke);
17 | return (
18 |
19 |
20 |
21 | Random Geek Jokes
22 |
23 |
{geekJoke}
24 |
25 |
29 |
33 |
34 |
35 | );
36 | };
37 |
38 | export default RandomGeekJokes;
39 |
--------------------------------------------------------------------------------
/src/cards/randomDogfacts.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 | import axios from "axios";
5 | export default function RandomAnimfacts(props) {
6 | const [response, setResponse] = useState("");
7 |
8 | useEffect(() => {
9 | axios
10 | .get(
11 | `https://anime-facts-rest-api.herokuapp.com/api/v1/fma_brotherhood/${
12 | Math.floor(Math.random() * 10) + 1
13 | }`
14 | )
15 | .then((response) => {
16 | setResponse(response.data.data.fact);
17 | })
18 | .catch((err) => console.log(err));
19 | }, []);
20 |
21 | return (
22 |
23 |
Random Anime Facts
24 |
{response}
25 |
26 |
30 |
34 |
35 | );
36 | }
37 |
--------------------------------------------------------------------------------
/src/cards/ZipCodeDetailsAPI.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | const ZipCodeAPI = (props) => {
6 | const [zipCodeData, setZipCodeData] = useState({});
7 |
8 | useEffect(() => {
9 | fetch("https://api.zippopotam.us/us/33162")
10 | .then((response) => response.json())
11 | .then((data) => setZipCodeData(data));
12 | }, []);
13 |
14 | return (
15 |
16 |
Zip Code Details
17 |
18 | Zip Code : {zipCodeData["post code"]}
19 |
20 |
21 | Country : {zipCodeData.country}
22 |
23 |
24 | Country Abbreviation : {zipCodeData["country abbreviation"]}
25 |
26 |
27 |
31 |
32 |
33 | );
34 | };
35 |
36 | export default ZipCodeAPI;
37 |
--------------------------------------------------------------------------------
/src/cards/covidApi.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function Covidapi(props) {
6 | const [covidData, setCovidData] = useState({});
7 | useEffect(() => {
8 | fetch("https://api.covid19api.com/summary")
9 | .then((res) => res.json())
10 | .then((data) => setCovidData(data.Global));
11 | }, []);
12 |
13 | return (
14 |
15 |
Covid-19 Global Stats
16 |
17 | Total Confirmed : {covidData.TotalConfirmed}
18 |
19 |
20 | Total Deaths : {covidData.TotalDeaths}
21 |
22 |
23 | New Deaths : {covidData.NewDeaths}
24 |
25 |
26 |
30 |
34 |
35 | );
36 | }
37 |
--------------------------------------------------------------------------------
/src/cards/randomJokeApi.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const RandomJokeApi = () => {
7 | const [joke, setjoke] = useState("");
8 | const [delivery, setDelivery] = useState("");
9 |
10 | useEffect(() => {
11 | axios
12 | .get("https://v2.jokeapi.dev/joke/Programming,Miscellaneous")
13 | .then((res) => {
14 | setjoke(res.data.setup);
15 | setDelivery(res.data.delivery);
16 | });
17 | }, []);
18 |
19 | return (
20 |
21 |
22 |
Random Joke API
23 |
{joke}
24 |
{delivery}
25 |
26 |
30 |
31 |
32 |
33 | );
34 | };
35 |
36 | export default RandomJokeApi;
37 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Thank you for considering and taking the time to contribute! Product focuses on 100% education as well as upskilling developing countries and rural areas.
4 |
5 | The following are guidelines for contributing to this project.
6 |
7 | ## How to Report Bugs
8 |
9 | Please open [a new issue in the appropriate GitHub repository][new-issue] with steps to reproduce the problem you're experiencing.
10 |
11 | Be sure to include as much information including screenshots, text output, and both your expected and actual results.
12 |
13 | ## How to Request Enhancements
14 |
15 | First, please refer to the applicable [GitHub repository][github-repo] and search [the repository's GitHub issues][issues-list] to make sure your idea has not been (or is not still) considered.
16 |
17 | Then, please [create a new issue in the GitHub repository][new-issue] describing your enhancement.
18 |
19 | Be sure to include as much detail as possible including step-by-step descriptions, specific examples, screenshots or mockups, and reasoning for why the enhancement might be worthwhile.
20 |
21 | [new-issue]: https://github.com/vedangj044/just-calling-random-api/issues/new
22 | [github-repo]: https://github.com/vedangj044/just-calling-random-api
23 | [issues-list]: https://github.com/vedangj044/just-calling-random-api/issues
24 |
--------------------------------------------------------------------------------
/src/cards/NasaApi.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const NasaApi = () => {
7 | const [spaceData, setSpaceData] = useState("");
8 |
9 | useEffect(() => {
10 | axios
11 | .get("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY")
12 | .then((res) => {
13 | setSpaceData(res.data);
14 | })
15 | .catch((err) => {
16 | setSpaceData("Some error came :(");
17 | });
18 | }, []);
19 |
20 | return (
21 |
22 |
23 |
NASA Space API
24 |
25 | {spaceData.title}
26 |
27 |
28 |
29 |
33 |
34 |
35 |
36 | );
37 | };
38 |
39 | export default NasaApi;
40 |
--------------------------------------------------------------------------------
/src/cards/MemesApi.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function MemesApi(props) {
6 | const [response, setResponse] = useState(null);
7 |
8 | useEffect(() => {
9 | fetch("https://api.imgflip.com/get_memes")
10 | .then((res) => res.json())
11 | .then(({ data }) => {
12 | let random = Math.ceil(Math.random() * 100);
13 | setResponse(data.memes[random]);
14 | // console.log(data.memes[random])
15 | });
16 | }, []);
17 |
18 | return (
19 |
20 |
Memes API
21 | {response !== null ? (
22 |
{response.name}
23 | ) : (
24 |
Loading
25 | )}
26 |
27 | {response !== null ? (
28 |
29 | ) : null}
30 |
31 |
35 |
36 |
37 | );
38 | }
39 |
--------------------------------------------------------------------------------
/src/cards/randomAnime.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const RandomAnime = () => {
7 | const [anime, setAnime] = useState({});
8 | useEffect(() => {
9 | axios.get("https://animechan.vercel.app/api/random/").then((res) => {
10 | // console.log(res.data)
11 | setAnime(res.data);
12 | });
13 | }, []);
14 | return (
15 |
16 |
17 |
18 | Random Anime Quotes
19 |
20 |
{anime.quote}
21 |
- {anime.character}
22 |
in {anime.anime}
23 |
24 |
28 |
32 |
33 |
34 | );
35 | };
36 |
37 | export default RandomAnime;
38 |
--------------------------------------------------------------------------------
/src/cards/randomQuotes.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function RandomQuotes(props) {
6 | // React hooks are used here to call the inbuilt fetch api
7 | // and display the response in a component.
8 | // Contributor's have to use fetch api to call any public api
9 | // and render the response to a component. Contributor's must
10 | // inlcude the ContributorInfo and ApiInfo component, with
11 | // suitable props. Refer to README.md for details.
12 |
13 | const [response, setResponse] = useState("");
14 |
15 | useEffect(() => {
16 | fetch("https://api.quotable.io/random")
17 | .then((resp) => resp.json())
18 | .then((data) => setResponse(data.content));
19 | }, []);
20 |
21 | return (
22 |
23 |
Random Quotes API
24 |
{response}
25 |
26 |
30 |
34 |
35 | );
36 | }
37 |
--------------------------------------------------------------------------------
/src/cards/SpacexcrewAPI.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const SpacexCrew = () => {
7 | const [Crew, setCrew] = useState("");
8 | useEffect(() => {
9 | axios.get("https://api.spacexdata.com/v4/crew/").then((res) => {
10 | setCrew(res.data[Math.floor(res.data.length * Math.random())]);
11 | });
12 | }, []);
13 |
14 | return (
15 |
16 |
17 |
Spacex Crew Members
18 |
19 |
Crew Member : {Crew.name}
20 |
21 | Agency name: {Crew.agency}
22 |
23 |
24 |
28 |
32 |
33 |
34 | );
35 | };
36 |
37 | export default SpacexCrew;
38 |
--------------------------------------------------------------------------------
/src/cards/HistoryOfTheDay.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import ApiInfo from "../components/apiInfo";
3 | import ContributorInfo from "../components/contributorInfo";
4 |
5 | const HistoryOfTheDay = () => {
6 | const [status, setStatus] = useState({ flag: false, message: "" });
7 | var today = new Date();
8 | var dd = String(today.getDate()).padStart(2, "0");
9 | var mm = String(today.getMonth() + 1).padStart(2, "0");
10 |
11 | const btnHandler = async () => {
12 | setStatus("Loading...");
13 | let data = await fetch("http://numbersapi.com/" + mm + "/" + dd + "/date");
14 | const ans = await data.text();
15 | setStatus({ flag: true, message: ans });
16 | };
17 |
18 | return (
19 |
20 |
History of the day !!
21 |
{status.message}
22 |
26 | Get The Fact
27 |
28 |
29 |
33 |
34 |
35 | );
36 | };
37 |
38 | export default HistoryOfTheDay;
39 |
--------------------------------------------------------------------------------
/src/cards/BeerApi.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function BeerAPI(props) {
6 | const [response, setResponse] = useState(null);
7 |
8 | useEffect(() => {
9 | fetch("https://api.punkapi.com/v2/beers")
10 | .then((res) => res.json())
11 | .then((data) => {
12 | let random = Math.ceil(Math.random() * 25);
13 | // console.log(data[random])
14 | setResponse(data[random]);
15 | });
16 | }, []);
17 |
18 | return (
19 |
20 |
Beer API
21 | {response !== null ? (
22 |
{response.name}
23 | ) : (
24 |
Loading
25 | )}
26 |
27 | {response !== null ? (
28 |
34 | ) : null}
35 |
36 |
40 |
41 |
42 | );
43 | }
44 |
--------------------------------------------------------------------------------
/src/cards/breadPuns.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function BreadPuns(props) {
6 | // React hooks are used here to call the inbuilt fetch api
7 | // and display the response in a component.
8 | // Contributor's have to use fetch api to call any public api
9 | // and render the response to a component. Contributor's must
10 | // inlcude the ContributorInfo and ApiInfo component, with
11 | // suitable props. Refer to README.md for details.
12 |
13 | const [response, setResponse] = useState("");
14 |
15 | useEffect(() => {
16 | fetch("https://my-bao-server.herokuapp.com/api/breadpuns")
17 | .then((res) => res.json())
18 | .then((data) => {
19 | // console.log(data);
20 | setResponse(data);
21 | });
22 | }, []);
23 |
24 | return (
25 |
26 |
Bread Puns API
27 |
{response}
28 |
29 |
33 |
37 |
38 | );
39 | }
40 |
--------------------------------------------------------------------------------
/src/cards/PublicApiApi.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import ApiInfo from "../components/apiInfo";
3 | import ContributorInfo from "../components/contributorInfo";
4 |
5 | function PublicApi() {
6 | let [response, setResponse] = useState(null);
7 |
8 | useEffect(() => {
9 | fetch("https://api.publicapis.org/entries")
10 | .then((res) => res.json())
11 | .then(({ entries }) => {
12 | let random = Math.floor(Math.random() * 100);
13 | // console.log(entries[random])
14 | setResponse(entries[random]);
15 | });
16 | }, []);
17 |
18 | return (
19 |
20 |
Random Public API
21 | {response !== null ? (
22 | <>
23 |
29 | {response.API}
30 |
31 |
{response.Description}
32 | >
33 | ) : (
34 |
Loading
35 | )}
36 |
37 |
41 |
42 |
43 | );
44 | }
45 |
46 | export default PublicApi;
47 |
--------------------------------------------------------------------------------
/src/cards/GenderGuess.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { useState } from "react";
3 | import ContributorInfo from "./../components/contributorInfo";
4 | import ApiInfo from "./../components/apiInfo";
5 |
6 | function GenderGuess() {
7 | let [name, setName] = useState("");
8 | let [gender, setGender] = useState("");
9 |
10 | const search = (name) => {
11 | fetch(`https://api.genderize.io/?name=${name}`)
12 | .then((res) => res.json())
13 | .then((data) => {
14 | setGender(data.gender);
15 | });
16 | };
17 |
18 | return (
19 |
20 |
Gender Guessing API
21 |
22 |
setName(e.target.value)}
27 | />
28 |
29 |
search(name)}
31 | className="bg-gray-900 p-2 rounded-2xl text-white"
32 | >
33 | Search your Gender!
34 |
35 |
36 | {gender !== "" ? (
37 |
{gender}
38 | ) : null}
39 |
40 |
44 |
48 |
49 | );
50 | }
51 |
52 | export default GenderGuess;
53 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "just-calling-random-api",
3 | "version": "0.1.0",
4 | "private": true,
5 | "homepage": "https://vedangj044.github.io/just-calling-random-api",
6 | "dependencies": {
7 | "@craco/craco": "^6.3.0",
8 | "@testing-library/jest-dom": "^5.14.1",
9 | "@testing-library/react": "^11.2.7",
10 | "@testing-library/user-event": "^12.8.3",
11 | "axios": "^0.21.4",
12 | "craco": "0.0.3",
13 | "gh-pages": "^3.2.3",
14 | "react": "^17.0.2",
15 | "react-dom": "^17.0.2",
16 | "react-icons": "^4.3.1",
17 | "react-scripts": "4.0.3",
18 | "web-vitals": "^1.1.2"
19 | },
20 | "scripts": {
21 | "start": "craco start",
22 | "build": "craco build",
23 | "test": "craco test",
24 | "eject": "react-scripts eject",
25 | "predeploy": "npm run build",
26 | "deploy": "gh-pages -d build",
27 | "prepare": "husky install"
28 | },
29 | "eslintConfig": {
30 | "extends": [
31 | "react-app",
32 | "react-app/jest"
33 | ]
34 | },
35 | "browserslist": {
36 | "production": [
37 | ">0.2%",
38 | "not dead",
39 | "not op_mini all"
40 | ],
41 | "development": [
42 | "last 1 chrome version",
43 | "last 1 firefox version",
44 | "last 1 safari version"
45 | ]
46 | },
47 | "devDependencies": {
48 | "autoprefixer": "^9.8.6",
49 | "husky": "^7.0.2",
50 | "lint-staged": "^11.2.3",
51 | "postcss": "^7.0.36",
52 | "prettier": "2.4.1",
53 | "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.16"
54 | },
55 | "lint-staged": {
56 | "**/*": "prettier --write --ignore-unknown"
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/components/content.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | export default function Message(props) {
4 | return (
5 |
6 |
7 |
Why this page exists?
8 |
9 | This page is for anyone around the globe who wants to start their
10 | open-source journey with{" "}
11 |
12 |
17 | {" "}
18 | Hacktoberfest{" "}
19 |
20 |
21 | . All you have to do is choose any publically available API, create a
22 | react component which calls your chosen API and display its response
23 | on the main page. You can find all the details and step-by-step
24 | procedures to make your first PR. Let's get going!
25 |
26 |
36 |
37 |
38 | );
39 | }
40 |
--------------------------------------------------------------------------------
/src/cards/randomCreditCard.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const RandomCreditCard = () => {
7 | const [creditCard, setCreditCard] = useState("");
8 | useEffect(() => {
9 | const formData = new FormData();
10 | formData.append("Type", "visa");
11 | axios({
12 | method: "post",
13 | url: "https://randommer.io/Card",
14 | data: formData,
15 | headers: { "Content-Type": "multipart/form-data" },
16 | })
17 | .then((response) => {
18 | setCreditCard(response.data);
19 | })
20 | .catch(function (response) {
21 | console.error(response);
22 | });
23 | }, []);
24 |
25 | return (
26 |
27 |
28 |
Random Credit Card
29 | {creditCard && (
30 |
31 | Card Number : {creditCard.cardNumber}
32 | CVV: {creditCard.cvv}
33 | Name: {creditCard.fullName}
34 | pin: {creditCard.pin}
35 | type: Visa
36 |
37 | )}
38 |
39 |
43 |
47 |
48 |
49 | );
50 | };
51 |
52 | export default RandomCreditCard;
53 |
--------------------------------------------------------------------------------
/src/cards/robohash.js:
--------------------------------------------------------------------------------
1 | import { useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | const RandomRoboFriend = () => {
6 | const [randomId, setRandomId] = useState(1);
7 |
8 | const DEFAULT_NAME = "Hijal";
9 |
10 | const generateRandomIdHandler = () => {
11 | let randomId = Math.floor(Math.random() * 100);
12 | setRandomId(randomId);
13 | };
14 |
15 | return (
16 |
17 |
18 |
Random ROBO Friend
19 |
20 |
21 |
22 |
27 |
{DEFAULT_NAME}
28 |
29 |
35 | New Friend
36 |
37 |
38 |
39 |
40 |
44 |
45 |
46 |
47 | );
48 | };
49 |
50 | export default RandomRoboFriend;
51 |
--------------------------------------------------------------------------------
/src/cards/RandomAnimeSeries.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const RandomAnimeSeries = () => {
7 | const [anime, setAnime] = useState("");
8 |
9 | useEffect(() => {
10 | axios
11 | .get("https://anime-facts-rest-api.herokuapp.com/api/v1")
12 | .then((res) => {
13 | const randomNumber = Math.floor(res.data.data.length * Math.random());
14 | setAnime(res.data.data[randomNumber]);
15 | })
16 | .catch((err) => {
17 | setAnime(false);
18 | });
19 | }, []);
20 |
21 | return (
22 |
23 |
24 |
Random Anime Series API
25 | {setAnime ? (
26 |
27 | {anime.anime_name}
28 |
29 | ) : (
30 |
31 | No Anime Series found
32 |
33 | )}
34 |
35 | {setAnime && (
36 |
41 | )}
42 |
43 |
47 |
51 |
52 |
53 | );
54 | };
55 |
56 | export default RandomAnimeSeries;
57 |
--------------------------------------------------------------------------------
/src/cards/RandomValorantWeapon.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const RandomValorantWeapon = () => {
7 | const [weapon, setWeapon] = useState("");
8 |
9 | useEffect(() => {
10 | axios
11 | .get("https://valorant-api.com/v1/weapons")
12 | .then((res) => {
13 | const randomNumber = Math.floor(res.data.data.length * Math.random());
14 | setWeapon(res.data.data[randomNumber]);
15 | })
16 | .catch((err) => {
17 | setWeapon(false);
18 | });
19 | }, []);
20 |
21 | return (
22 |
23 |
24 |
25 | Random Valorant Weapon API
26 |
27 | {weapon && weapon.displayName ? (
28 |
29 | {weapon.displayName}
30 |
31 | ) : (
32 |
33 | No Weapon Found
34 |
35 | )}
36 |
37 | {weapon && weapon.displayIcon && (
38 |
43 | )}
44 |
45 |
49 |
50 |
51 |
52 | );
53 | };
54 |
55 | export default RandomValorantWeapon;
56 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Build and Deploy
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | pull_request:
7 | branches: [main]
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 |
13 | strategy:
14 | matrix:
15 | node-version: [12.x]
16 |
17 | steps:
18 | - name: Checkout repository
19 | uses: actions/checkout@v2
20 |
21 | - name: Set up Node.js ${{ matrix.node-version }}
22 | uses: actions/setup-node@v1
23 | with:
24 | node-version: ${{ matrix.node-version }}
25 |
26 | - name: Install dependencies
27 | run: npm install
28 |
29 | - name: Check formatting
30 | run: npx prettier --check .
31 |
32 | - name: Build
33 | run: npm run build
34 | env:
35 | REACT_APP_GIPHY_API_KEY: ${{ secrets.REACT_APP_GIPHY_API_KEY }}
36 | REACT_APP_WEATHER_API_KEY: ${{ secrets.REACT_APP_WEATHER_API_KEY }}
37 | REACT_APP_HOLIDAY_API_KEY: ${{ secrets.REACT_APP_HOLIDAY_API_KEY }}
38 |
39 | - name: Deploy
40 | run: |
41 | git config --global user.name $user_name
42 | git config --global user.email $user_email
43 | git remote set-url origin https://${github_token}@github.com/${repository}
44 | npm run deploy
45 | env:
46 | user_name: "github-actions[bot]"
47 | user_email: "github-actions[bot]@users.noreply.github.com"
48 | github_token: ${{ secrets.DEPLOYMENT }}
49 | repository: ${{ github.repository }}
50 | REACT_APP_GIPHY_API_KEY: ${{ secrets.REACT_APP_GIPHY_API_KEY }}
51 | REACT_APP_WEATHER_API_KEY: ${{ secrets.REACT_APP_WEATHER_API_KEY }}
52 | REACT_APP_HOLIDAY_API_KEY: ${{ secrets.REACT_APP_HOLIDAY_API_KEY }}
53 | REACT_APP_MOVIE_API_KEY: ${{ secrets.REACT_APP_MOVIE_API_KEY }}
54 |
--------------------------------------------------------------------------------
/src/cards/foaasapi.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { useState } from "react";
3 | import ContributorInfo from "./../components/contributorInfo";
4 | import ApiInfo from "./../components/apiInfo";
5 |
6 | export default function Foaas() {
7 | let [from, setFrom] = useState("");
8 | let [to, setTo] = useState("");
9 | let [response, setResponse] = useState("");
10 |
11 | const search = () => {
12 | fetch("https://foaas.com/shutup/" + to + "/" + from, {
13 | method: "GET",
14 | headers: {
15 | Accept: "application/json",
16 | },
17 | })
18 | .then((res) => res.json())
19 | .then((data) => {
20 | setResponse(data);
21 | });
22 | };
23 |
24 | return (
25 |
26 |
27 | STFU as a service
28 |
29 |
{
36 | setFrom(e.target.value);
37 | }}
38 | />
39 |
40 |
{
47 | setTo(e.target.value);
48 | }}
49 | />
50 |
51 |
search()}
53 | className="bg-blue-900 p-2 rounded-2xl text-white"
54 | >
55 | GO
56 |
57 | {response !== "" ? (
58 |
59 | {response.message} {response.subtitle}
60 |
61 | ) : null}
62 |
63 |
64 |
65 |
66 |
67 | );
68 | }
69 |
--------------------------------------------------------------------------------
/src/cards/GetIcon.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState, useRef } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const GetIcon = () => {
7 | const [Icon, setIcon] = useState(false);
8 | const website = useRef();
9 | const [websiteUrl, setWebsiteUrl] = useState("youtube.com");
10 |
11 | useEffect(() => {
12 | axios
13 | .get("https://icon.horse/icon/" + websiteUrl)
14 | .then((res) => {
15 | setIcon("https://icon.horse/icon/" + websiteUrl);
16 | })
17 | .catch((err) => {
18 | setIcon(false);
19 | console.log("Some an error came :(");
20 | });
21 | }, [websiteUrl]);
22 |
23 | const submitHandler = (event) => {
24 | event.preventDefault();
25 | setWebsiteUrl(website.current.value);
26 | website.current.value = "";
27 | };
28 |
29 | return (
30 |
31 |
32 |
Website Icon API
33 | {Icon ? (
34 |
35 | ) : (
36 |
37 | Some an error came :(
38 |
39 | )}
40 |
47 |
51 | Get Icon
52 |
53 |
54 |
58 |
59 |
60 |
61 | );
62 | };
63 |
64 | export default GetIcon;
65 |
--------------------------------------------------------------------------------
/src/cards/RandomMovieQuote.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const movieQuoteOriginalValue = {
7 | quote: "",
8 | role: "",
9 | show: "",
10 | };
11 |
12 | const RandomMovieQuote = () => {
13 | const [isError, setIsError] = useState(false);
14 | const [movieQuote, setMovieQuote] = useState(movieQuoteOriginalValue);
15 |
16 | const resetMovieQuote = () => {
17 | setMovieQuote(movieQuoteOriginalValue);
18 | };
19 |
20 | useEffect(() => {
21 | axios
22 | .get("https://movie-quote-api.herokuapp.com/v1/quote/")
23 | .then((res) => {
24 | const movieQuoteData = res.data;
25 | setMovieQuote({
26 | quote: movieQuoteData.quote,
27 | role: movieQuoteData.role,
28 | show: movieQuoteData.show,
29 | });
30 | setIsError(false);
31 | })
32 | .catch((e) => {
33 | resetMovieQuote();
34 | setIsError(true);
35 | });
36 | }, []);
37 |
38 | return (
39 |
40 |
41 |
Random Movie Quete
42 |
43 |
44 |
45 | {!isError ? (
46 | “ {movieQuote.quote} ”
47 | ) : (
48 | “ Something Error! ”
49 | )}
50 |
51 |
52 | {!isError && `${movieQuote.role} - ${movieQuote.show}`}
53 |
54 |
55 |
56 |
60 |
64 |
65 |
66 | );
67 | };
68 |
69 | export default RandomMovieQuote;
70 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
19 |
20 |
24 |
33 | Just calling random api
34 |
35 |
36 | You need to enable JavaScript to run this app.
37 |
38 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/cards/ricknmortyApi.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | const RicknmortyApi = () => {
6 | const [character, setCharacter] = useState("");
7 |
8 | let getChar = () => {
9 | let random = Math.floor(Math.random() * 20);
10 | let pg = Math.floor(Math.random() * 34);
11 |
12 | fetch(`https://rickandmortyapi.com/api/character/?page=${pg}`)
13 | .then((res) => res.json())
14 | .then((data) => {
15 | setCharacter(data.results[random]);
16 | })
17 | .catch((err) => console.log(err));
18 | };
19 | let lc = { ...character.location };
20 | return (
21 | <>
22 |
23 |
Rick and Morty API
24 |
28 | Generate
29 |
30 |
31 |
38 |
39 |
{character.name}
40 |
41 |
42 | {character.status}
43 |
44 |
45 | {character.species}
46 |
47 |
48 | {lc.name}
49 |
50 |
51 |
52 |
53 |
54 |
58 |
62 |
63 | >
64 | );
65 | };
66 |
67 | export default RicknmortyApi;
68 |
--------------------------------------------------------------------------------
/src/cards/randomPlaceholderImage.js:
--------------------------------------------------------------------------------
1 | import { React, useState, useEffect } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const RandomPlaceholderImage = () => {
7 | const [width, setWidth] = useState("");
8 | const [height, setHeight] = useState("");
9 | const [url, setUrl] = useState("https://picsum.photos/200/300");
10 |
11 | useEffect(() => {}, [url]);
12 |
13 | const getImage = (e) => {
14 | e.preventDefault();
15 | let newUrl = `http://picsum.photos/${width}/${height}`;
16 | axios
17 | .get(newUrl)
18 | .then((response) => {
19 | setUrl(newUrl);
20 | })
21 | .catch((error) => {
22 | setUrl("https://picsum.photos/200/300");
23 | });
24 | };
25 |
26 | return (
27 |
28 |
29 | Random placeholder image Api
30 |
31 |
32 |
33 | {
38 | setHeight(e.target.value);
39 | }}
40 | value={height}
41 | />
42 | {
47 | setWidth(e.target.value);
48 | }}
49 | value={width}
50 | />
51 |
56 | Get random image
57 |
58 |
59 |
63 |
64 |
65 | );
66 | };
67 |
68 | export default RandomPlaceholderImage;
69 |
--------------------------------------------------------------------------------
/src/cards/bookDetails.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | const BookDetails = (props) => {
6 | const [bookData, setBookData] = useState(null);
7 | const [isbn, setIsbn] = useState("");
8 |
9 | const loadDataHandler = () => {
10 | fetch(`http://openlibrary.org/api/volumes/brief/isbn/${isbn}.json`)
11 | .then((response) => response.json())
12 | .then((data) => {
13 | if (data !== []) {
14 | const keys = Object.keys(data.records);
15 | setBookData(data.records[keys].data);
16 | }
17 | })
18 | .catch((error) => console.log(error));
19 | };
20 |
21 | return (
22 |
23 |
Book Details by ISBN
24 |
25 |
26 | setIsbn(e.target.value)}
34 | />
35 |
36 |
37 |
41 | Find
42 |
43 |
44 |
45 |
46 | Title : {bookData && bookData.title}
47 |
48 |
49 | {/* Zip Code : {"ff"} */}
50 | Publish Date : {bookData && bookData.publish_date}
51 |
52 |
53 | Number of Pages : {bookData && bookData.number_of_pages}
54 |
55 |
56 |
60 |
61 |
62 | );
63 | };
64 |
65 | export default BookDetails;
66 |
--------------------------------------------------------------------------------
/src/cards/PasswordGenerator.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import ApiInfo from "../components/apiInfo";
3 | import ContributorInfo from "../components/contributorInfo";
4 |
5 | const PasswordGenerator = () => {
6 | const [length, setLength] = useState("");
7 | const [password, setPassword] = useState("");
8 | const [status, setStatus] = useState({
9 | flag: false,
10 | message: "Enter the length of password",
11 | });
12 |
13 | const btnHandler = async () => {
14 | setStatus("Loading...");
15 |
16 | if (length >= 3) {
17 | let record = await fetch(
18 | "https://passwordinator.herokuapp.com/generate?num=true&char=true&caps=true&len=" +
19 | length
20 | );
21 | record = await record.json();
22 | setPassword(record.data);
23 | setStatus({ flag: true, message: record.data });
24 | } else {
25 | setStatus({
26 | flag: false,
27 | message: "Length must be a number & can't be less than 3",
28 | });
29 | }
30 | };
31 |
32 | const myFunction = () => {
33 | navigator.clipboard.writeText(password);
34 | };
35 |
36 | return (
37 |
38 |
Password Generator
39 |
setLength(e.target.value)}
44 | placeholder="Length of Password"
45 | />
46 |
50 | Generate
51 |
52 | {status.flag && (
53 |
57 | Copy Password
58 |
59 | )}
60 |
{status.message}
61 |
62 |
66 |
70 |
71 | );
72 | };
73 |
74 | export default PasswordGenerator;
75 |
--------------------------------------------------------------------------------
/src/cards/dogWithAnimeQuotes.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 | import axios from "axios";
5 |
6 | export const DogAnimeQuotes = (props) => {
7 | const [dogInfo, setDogInfo] = useState(null);
8 | const [animeQuotes, setAnimeQuotes] = useState("Im wise");
9 |
10 | useEffect(() => {
11 | console.log("mounting dog with anime quotes ....");
12 | fetchApi();
13 | // console.log(quote);
14 | }, []);
15 |
16 | const fetchApi = async () => {
17 | console.log("im supposed to fetch APIs");
18 |
19 | try {
20 | const response = await axios.get(
21 | "https://dog.ceo/api/breeds/image/random"
22 | );
23 | console.log("dog image data -- ", response.data);
24 | setDogInfo(response.data.message);
25 | } catch (err) {
26 | console.log(err);
27 | }
28 |
29 | try {
30 | const response = await axios.get(
31 | "https://animechan.vercel.app/api/random"
32 | );
33 | setAnimeQuotes(response.data.quote);
34 | console.log(response.data);
35 | } catch (err) {
36 | setAnimeQuotes("Look at me, so cute...");
37 | console.log("error fetching anime quotes ", err);
38 | }
39 | };
40 |
41 | return (
42 |
43 |
Famous Dog Quotes
44 |
45 |
50 |
51 |
52 |
Doggo ~ "{animeQuotes}"
53 |
54 |
55 |
59 | Get Another
60 |
61 |
62 |
63 |
67 |
71 |
75 |
76 | );
77 | };
78 |
--------------------------------------------------------------------------------
/src/cards/url-shortener.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import ApiInfo from "../components/apiInfo";
3 | import ContributorInfo from "../components/contributorInfo";
4 |
5 | const UrlShortener = () => {
6 | const [longUrl, setLongUrl] = useState("");
7 | const [code, setCode] = useState("");
8 | const [status, setStatus] = useState({
9 | flag: false,
10 | message: "Enter the URL",
11 | });
12 |
13 | const btnHandler = async () => {
14 | setStatus({ flag: false, message: "Loading..." });
15 | let shortenUrl = await fetch("https://gotiny.cc/api", {
16 | method: "POST",
17 | headers: { "Content-Type": "application/json" },
18 | body: JSON.stringify({ input: longUrl }),
19 | });
20 | shortenUrl = await shortenUrl.json();
21 |
22 | try {
23 | setCode(shortenUrl[0].code);
24 | setStatus({ flag: true, message: "gotiny.cc/" + shortenUrl[0].code });
25 | } catch {
26 | setStatus({
27 | flag: false,
28 | message: "I'm sure you haven't enetered the proper URL :(",
29 | });
30 | }
31 | };
32 |
33 | const myFunction = () => {
34 | let tempUrl = "gotiny.cc/" + code;
35 | navigator.clipboard.writeText(tempUrl);
36 | };
37 |
38 | return (
39 |
40 |
URL Shortener
41 |
setLongUrl(e.target.value)}
46 | placeholder="Long URL"
47 | />
48 |
52 | Shorten URL
53 |
54 | {status.flag && (
55 |
59 | Copy URL
60 |
61 | )}
62 |
{status.message}
63 |
64 |
68 |
72 |
73 | );
74 | };
75 |
76 | export default UrlShortener;
77 |
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/cards/MusicPlayer.js:
--------------------------------------------------------------------------------
1 | import React, { useRef, useState } from "react";
2 | import ApiInfo from "../components/apiInfo";
3 | import ContributorInfo from "../components/contributorInfo";
4 |
5 | const MusicPlayer = () => {
6 | const [songName, setSongName] = useState("");
7 | const [source, setSource] = useState("");
8 | const audioElementRef = useRef();
9 | const [status, setStatus] = useState({
10 | flag: false,
11 | message: "Let's play your favourite song..",
12 | });
13 |
14 | const playBtnHandler = async () => {
15 | setStatus({ flag: false, message: "Loading..." });
16 | let audioUrl = await fetch("https://sudoic.herokuapp.com/sudoic", {
17 | method: "POST",
18 | headers: {
19 | "Content-type": "application/json",
20 | },
21 | mode: "cors",
22 | body: JSON.stringify({ query: songName + " song lyrics" }),
23 | });
24 | audioUrl = await audioUrl.json();
25 | if (audioUrl.data) {
26 | setSource(audioUrl.data);
27 | setStatus({ flag: true, message: "" });
28 | audioElementRef.current.play();
29 | } else {
30 | setStatus({ flag: false, message: "Song not found :(" });
31 | setSource("");
32 | }
33 | };
34 |
35 | return (
36 |
37 |
Music Player (Sudoic API)
38 |
setSongName(e.target.value)}
43 | placeholder="Type any song's name here..."
44 | />
45 |
49 | Play
50 |
51 | {/* displaying audio element only when we have a source to play the audio from */}
52 | {status.flag ? (
53 |
59 | ) : (
60 |
{status.message}
61 | )}
62 |
63 |
67 |
71 |
72 | );
73 | };
74 |
75 | export default MusicPlayer;
76 |
--------------------------------------------------------------------------------
/src/cards/githubUser.js:
--------------------------------------------------------------------------------
1 | import { useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const GithubUser = () => {
7 | const [valid, setValid] = useState(false);
8 | const [user, setUser] = useState({});
9 |
10 | const search = (username) => {
11 | if (username !== "")
12 | axios
13 | .get("https://api.github.com/users/" + username)
14 | .then((res) => {
15 | setUser(res.data);
16 | setValid(true);
17 | })
18 | .catch((err) => setValid(false));
19 | };
20 |
21 | return (
22 | <>
23 |
24 |
Search Random GitHub User
25 |
search(e.target.value)}
29 | placeholder="Type any random name here..."
30 | />
31 |
32 | {valid ? (
33 |
34 |
35 |
41 |
42 |
55 |
56 | ) : (
57 |
58 | )}
59 |
60 |
67 |
68 | >
69 | );
70 | };
71 |
72 | export default GithubUser;
73 |
--------------------------------------------------------------------------------
/src/cards/giphyapi.js:
--------------------------------------------------------------------------------
1 | import { useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 | import axios from "axios";
5 |
6 | const GiphyApi = () => {
7 | const key = process.env.REACT_APP_GIPHY_API_KEY;
8 |
9 | const [searchValue, setSearchValue] = useState(null);
10 | const [data, setData] = useState(null);
11 | const [loading, setLoading] = useState(false);
12 | const fetchGiphyApi = (search) => {
13 | if (!search) {
14 | return;
15 | }
16 | setLoading(true);
17 | axios
18 | .get(`https://api.giphy.com/v1/gifs/search?q=${search}&api_key=${key}`)
19 | .then((res) => {
20 | const { data } = res;
21 | setData(data);
22 | setLoading(false);
23 | })
24 | .catch((err) => console.error(err));
25 | };
26 |
27 | return (
28 |
29 |
30 |
31 |
Giphy API
32 |
setSearchValue(e.target.value)}
39 | />
40 |
fetchGiphyApi(searchValue)}
43 | >
44 | Search
45 |
46 |
47 |
48 | {loading && (
49 |
Loading...
50 | )}
51 | {data &&
52 | data.data.slice(0, 5).map((image, index) => {
53 | return (
54 |
60 | );
61 | })}
62 |
63 |
67 |
71 |
72 |
73 |
74 | );
75 | };
76 |
77 | export default GiphyApi;
78 |
--------------------------------------------------------------------------------
/src/cards/Sunshinetime.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function Sunshinetime(props) {
6 | const [lat, setLat] = useState(0.0);
7 | const [lng, setLng] = useState(0.0);
8 | const [latlng, setLatlng] = useState("0.0");
9 | const [sunrise, setSunrise] = useState("");
10 | const [sunset, setSunset] = useState("");
11 |
12 | useEffect(() => {
13 | fetch(
14 | `https://api.sunrise-sunset.org/json?lat=${lat}&lng=${lng}&date=today&v=${latlng}`
15 | )
16 | .then((res) => res.json())
17 | .then((data) => {
18 | console.log(data);
19 |
20 | if ("results" in data) {
21 | setSunrise(data.results.sunrise);
22 | setSunset(data.results.sunset);
23 | }
24 | })
25 | .catch((err) => {
26 | console.log("SHibe" + err);
27 | });
28 | }, [latlng, lat, lng]);
29 | return (
30 |
31 |
32 |
Sun shines
33 |
34 |
35 | Latitude:
36 | {
42 | setLat(e.target.value);
43 | }}
44 | />
45 |
46 |
47 |
48 |
49 | Longitude:
50 | {
56 | setLng(e.target.value);
57 | }}
58 | />
59 |
60 |
61 |
62 |
{
65 | setLatlng(`${lat}-${lng}`);
66 | }}
67 | >
68 | Check now
69 |
70 |
71 |
The Sun rises at: {sunrise}
72 |
The Sun sets at: {sunset}
73 |
74 |
78 |
82 |
83 |
84 | );
85 | }
86 |
--------------------------------------------------------------------------------
/src/cards/RandomAdage.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ApiInfo from "../components/apiInfo";
3 | import ContributorInfo from "../components/contributorInfo";
4 |
5 | const RandomAdage = () => {
6 | const [adage, setAdage] = useState("");
7 | const [adageQuestion, setAdageQuestion] = useState("");
8 | const [adageAnswer, setAdageAnswer] = useState("");
9 | const [adageQuote, setAdageQuote] = useState("");
10 |
11 | const getRandomAdage = () => {
12 | fetch("https://isvbscriptdead.com/api/fortune/")
13 | .then((response) => response.json())
14 | .then((result) => {
15 | if (result[0] === "Q") {
16 | setAdage("");
17 | setAdageQuote("");
18 | let indexOfA = result.indexOf("A:");
19 | setAdageQuestion(result.substring(0, indexOfA));
20 | setAdageAnswer(result.substring(indexOfA));
21 | } else if (result.includes("-- ")) {
22 | setAdageQuestion("");
23 | setAdageAnswer("");
24 | let indexOfDashDash = result.indexOf("-- ");
25 | setAdage(result.substring(0, indexOfDashDash));
26 | setAdageQuote(result.substring(indexOfDashDash));
27 | } else {
28 | setAdageQuestion("");
29 | setAdageAnswer("");
30 | setAdageQuote("");
31 | setAdage(result);
32 | }
33 | });
34 | };
35 |
36 | useEffect(() => {
37 | getRandomAdage();
38 | }, []);
39 |
40 | return (
41 |
42 |
adage
43 |
/ˈadɪdʒ/
44 |
a proverb or short statement expressing a general truth.
45 |
46 |
47 |
{adage}
48 | {adageQuestion && (
49 | {adageQuestion}
50 | )}
51 | {adageAnswer && (
52 | {adageAnswer}
53 | )}
54 | {adageQuote && (
55 | {adageQuote}
56 | )}
57 |
58 |
63 | Click for more
64 |
65 |
66 |
67 |
71 |
72 |
76 |
77 | );
78 | };
79 |
80 | export default RandomAdage;
81 |
--------------------------------------------------------------------------------
/src/cards/SimpleAdd.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | const SimpleAdd = () => {
6 | const [num1, setNum1] = useState(0);
7 | const [num2, setNum2] = useState(0);
8 |
9 | const debouncedNum1 = useDebounce(num1, 500);
10 | const debouncedNum2 = useDebounce(num2, 500);
11 |
12 | const [result, setResult] = useState(0);
13 |
14 | useEffect(() => {
15 | if (debouncedNum1 === "" || debouncedNum2 === "") return;
16 | fetch(
17 | `https://simple-calculator-api.vercel.app/api/add?nums=${debouncedNum1},${debouncedNum2}`
18 | )
19 | .then((r) => r.json())
20 | .then((d) => {
21 | setResult(d.sum || 0);
22 | });
23 | }, [debouncedNum1, debouncedNum2]);
24 | return (
25 |
26 |
27 | Adding two numners
28 |
29 |
30 | Number 1
31 | {
36 | const num =
37 | e.target.value === "" ? "" : parseInt(e.target.value, 10);
38 | setNum1(num);
39 | }}
40 | />
41 |
42 |
43 | Number 2
44 | {
49 | const num =
50 | e.target.value === "" ? "" : parseInt(e.target.value, 10);
51 | setNum2(num);
52 | }}
53 | />
54 |
55 |
Result: {result}
56 |
57 |
61 |
65 |
66 | );
67 | };
68 | export default SimpleAdd;
69 |
70 | function useDebounce(value, delay) {
71 | // State and setters for debounced value
72 | const [debouncedValue, setDebouncedValue] = useState(value);
73 | useEffect(
74 | () => {
75 | // Update debounced value after delay
76 | const handler = setTimeout(() => {
77 | setDebouncedValue(value);
78 | }, delay);
79 | // Cancel the timeout if value changes (also on delay change or unmount)
80 | // This is how we prevent debounced value from updating if value is changed ...
81 | // .. within the delay period. Timeout gets cleared and restarted.
82 | return () => {
83 | clearTimeout(handler);
84 | };
85 | },
86 | [value, delay] // Only re-call effect if value or delay changes
87 | );
88 | return debouncedValue;
89 | }
90 |
--------------------------------------------------------------------------------
/src/cards/EvaluateMath.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | const EvaluateMath = () => {
6 | const [expr, setExpr] = useState("1+2");
7 |
8 | const debouncedExpr = useDebounce(expr, 500);
9 |
10 | const [result, setResult] = useState(0);
11 | const [error, setError] = useState("");
12 | useEffect(() => {
13 | if (debouncedExpr === "") return;
14 | fetch(
15 | `https://simple-calculator-api.vercel.app/api/eval?expr=${encodeURIComponent(
16 | debouncedExpr
17 | )}`
18 | )
19 | .then((r) => r.json())
20 | .then((d) => {
21 | if ("result" in d) {
22 | setResult(d.result);
23 | setError("");
24 | } else {
25 | setResult(null);
26 | setError(d.error);
27 | }
28 | });
29 | }, [debouncedExpr]);
30 | return (
31 |
32 |
33 | Adding two numners
34 |
35 |
36 |
37 | Expression (e.g. 1+2){" "}
38 |
44 | See docs here
45 |
46 |
47 |
{
51 | setExpr(e.target.value);
52 | }}
53 | />
54 |
55 |
56 |
Result: {result}
57 | {!!error &&
Error: {error}
}
58 |
59 |
63 |
67 |
68 | );
69 | };
70 | export default EvaluateMath;
71 |
72 | function useDebounce(value, delay) {
73 | // State and setters for debounced value
74 | const [debouncedValue, setDebouncedValue] = useState(value);
75 | useEffect(
76 | () => {
77 | // Update debounced value after delay
78 | const handler = setTimeout(() => {
79 | setDebouncedValue(value);
80 | }, delay);
81 | // Cancel the timeout if value changes (also on delay change or unmount)
82 | // This is how we prevent debounced value from updating if value is changed ...
83 | // .. within the delay period. Timeout gets cleared and restarted.
84 | return () => {
85 | clearTimeout(handler);
86 | };
87 | },
88 | [value, delay] // Only re-call effect if value or delay changes
89 | );
90 | return debouncedValue;
91 | }
92 |
--------------------------------------------------------------------------------
/src/cards/HaikuSyllableCounter.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import axios from "axios";
3 | import ApiInfo from "../components/apiInfo";
4 | import ContributorInfo from "../components/contributorInfo";
5 |
6 | const HaikuSyllableCounter = () => {
7 | const [input, setInput] = useState("");
8 | const [wordMeta, setWordMeta] = useState({});
9 | const [syllables, setSyllables] = useState([0, 0, 0]);
10 |
11 | const recalculateSyllables = async () => {
12 | const inputArr = parseInput(input);
13 | let newWordMeta = { ...wordMeta };
14 | let newLineSyllables = [0, 0, 0];
15 | for (let i = 0; i < inputArr.length; i++) {
16 | const line = inputArr[i];
17 | let lineSyllables = 0;
18 | for (const word of line) {
19 | let wordSyllables = 0;
20 | if (wordMeta[word]) {
21 | wordSyllables = wordMeta[word];
22 | } else {
23 | wordSyllables = await getSyllables(word);
24 | newWordMeta = { ...newWordMeta, [word]: wordSyllables };
25 | }
26 | lineSyllables += wordSyllables;
27 | }
28 | newLineSyllables[i] = lineSyllables;
29 | }
30 | setSyllables(newLineSyllables);
31 | setWordMeta(newWordMeta);
32 | };
33 |
34 | return (
35 |
36 |
Haiku Syllable Counter
37 |
60 | );
61 | };
62 |
63 | const getSyllables = async (word) => {
64 | try {
65 | const res = await axios.get(
66 | `https://api.datamuse.com/words?sp=${word}&md=s&max=1`
67 | );
68 | const data = await res.data;
69 | return data[0].numSyllables || 0;
70 | } catch (error) {
71 | return 0;
72 | }
73 | };
74 |
75 | const parseInput = (input) => {
76 | return input.split("\n").map((line) =>
77 | line
78 | .replace(/\W+/g, " ")
79 | .split(" ")
80 | .filter((word) => word !== "")
81 | );
82 | };
83 |
84 | const SyllableCount = ({ line, count }) => {
85 | return (
86 |
87 |
Syllables line {line}:
88 |
{count}
89 |
90 | );
91 | };
92 |
93 | export default HaikuSyllableCounter;
94 |
--------------------------------------------------------------------------------
/src/cards/imageCompressionAPI.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | const ImageCompression = () => {
6 | const [originalUrl, setOriginalUrl] = useState(
7 | "https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg"
8 | );
9 | const [quality, setQuality] = useState(5);
10 | const [compressedUrl, setCompressedUrl] = useState("");
11 |
12 | useEffect(() => {
13 | compressImage(originalUrl, quality);
14 | // eslint-disable-next-line
15 | }, []);
16 |
17 | const compressImage = (url, picQuality) => {
18 | fetch(`https://api.resmush.it/ws.php?img=${url}&qlty=${picQuality}`)
19 | .then((r) => r.json())
20 | .then((res) => {
21 | console.log(res);
22 | setCompressedUrl(res.dest);
23 | })
24 | .catch((err) => console.error(err));
25 | };
26 |
27 | return (
28 |
29 |
30 |
31 |
Image Compression
32 |
Url
33 |
setOriginalUrl(e.target.value)}
40 | />
41 |
42 | Quality
43 |
44 |
51 | setQuality(
52 | +e.target.value > 100
53 | ? 100
54 | : +e.target.value < 1
55 | ? 1
56 | : +e.target.value
57 | )
58 | }
59 | />
60 |
compressImage(originalUrl, quality)}
63 | >
64 | Compress
65 |
66 |
67 |
71 |
72 |
73 |
74 |
75 |
Original
76 |
77 |
78 |
79 |
Compressed
80 |
81 |
82 |
83 |
84 |
85 | );
86 | };
87 |
88 | export default ImageCompression;
89 |
--------------------------------------------------------------------------------
/src/cards/Dungeons.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const Dungeons = () => {
7 | const [searchValue, setSearchValue] = useState(null);
8 | const [result, setResult] = useState(null);
9 | const [loading, setLoading] = useState(false);
10 |
11 | const searchHandler = (e) => {
12 | e.preventDefault();
13 | if (!searchValue) {
14 | return;
15 | }
16 | setLoading(true);
17 | axios
18 | .get(`https://www.dnd5eapi.co/api/spells/${searchValue}`)
19 | .then((res) => {
20 | const { data } = res;
21 | console.log(data);
22 | setResult(data);
23 | setLoading(false);
24 | })
25 | .catch((err) => console.log(err));
26 | };
27 |
28 | return (
29 |
30 |
Dungeons and Dragons
31 |
setSearchValue(e.target.value)}
36 | placeholder="Enter spell (eg acid-arrow)..."
37 | />
38 |
42 | Search
43 |
44 |
45 |
46 | {loading && (
47 |
Loading...
48 | )}
49 | {result && (
50 | <>
51 |
52 |
Name :
53 | {result.name}
54 |
55 |
56 |
57 |
Range :
58 | {result.range}
59 |
60 |
61 |
62 |
Material :
63 | {result.material}
64 |
65 |
66 |
67 |
Description :
68 | {result.desc[0]}
69 |
70 |
71 |
72 |
Higher Level :
73 |
74 | {result.higher_level[0]}
75 |
76 |
77 |
78 | >
79 | )}
80 |
81 |
85 |
86 |
87 | );
88 | };
89 |
90 | export default Dungeons;
91 |
--------------------------------------------------------------------------------
/src/cards/publicholiday.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { useState } from "react";
3 | import axios from "axios";
4 | import ContributorInfo from "../components/contributorInfo";
5 | import ApiInfo from "../components/apiInfo";
6 | const Publicholiday = () => {
7 | const [holiday, setholiday] = useState([]);
8 | const [day, setday] = useState("");
9 | const [month, setmonth] = useState("");
10 | const [year, setyear] = useState("");
11 |
12 | const getdata = () => {
13 | const API_KEY = process.env.REACT_APP_HOLIDAY_API_KEY;
14 | axios
15 | .get(
16 | `https://holidays.abstractapi.com/v1/?api_key=${API_KEY}&country=in
17 | &year=${year}&month=${month}&day=${day}`
18 | )
19 | .then((response) => {
20 | console.log(response.data);
21 | //console.log(response.data);
22 | setholiday(response.data);
23 | })
24 | .catch((error) => {
25 | console.log(error);
26 | });
27 | };
28 |
29 | return (
30 |
31 |
32 | Enter the following to know if there is a public holiday or not
33 |
34 |
41 |
42 |
{
49 | setday(e.target.value);
50 | }}
51 | />
52 |
53 |
{
60 | setmonth(e.target.value);
61 | }}
62 | />
63 |
64 |
{
71 | setyear(e.target.value);
72 | }}
73 | />
74 |
75 |
82 | Submit
83 |
84 |
85 |
86 |
87 | {holiday.length <= 0 ? (
88 |
No holiday!😢
89 | ) : (
90 |
Yup,it's {holiday[0].name}😃
91 | )}
92 |
96 |
100 |
101 | );
102 | };
103 |
104 | export default Publicholiday;
105 |
--------------------------------------------------------------------------------
/src/cards/weatherApi.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { useState } from "react";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | function WeatherApi() {
7 | const REACT_APP_WEATHER_API_KEY = process.env.REACT_APP_WEATHER_API_KEY;
8 |
9 | const updatePlaceData = () => {
10 | fetch(
11 | `https://api.weatherapi.com/v1/current.json?key=${REACT_APP_WEATHER_API_KEY}&q=${place}`
12 | )
13 | .then((res) => res.json())
14 | .then((data) => {
15 | console.log(data);
16 | setPlaceData(data);
17 | });
18 | };
19 | const [place, setPlace] = useState("");
20 | const [placeData, setPlaceData] = useState({});
21 | return (
22 |
23 |
24 |
Weather Card
25 |
26 |
{
32 | setPlace(e.target.value);
33 | }}
34 | />
35 |
39 | search
40 |
41 |
42 |
43 | {placeData.location ? (
44 | <>
45 |
46 |
47 | {placeData.current.temp_c}°
48 |
49 |
50 | {placeData.location.name}{" "}
51 |
52 |
53 |
54 |
55 | Wind Now{" "}
56 |
57 | {placeData.current.wind_kph} Km/hr {" "}
58 |
59 |
60 |
61 |
62 | Humidity{" "}
63 |
64 | {placeData.current.humidity} %
65 |
66 |
67 |
68 |
69 | Precipitation{" "}
70 |
71 | {placeData.current.precip_in} %
72 |
73 |
74 |
75 |
76 | >
77 | ) : (
78 |
Not Found!
79 | )}
80 |
81 |
82 |
83 |
87 |
91 |
92 |
93 | );
94 | }
95 |
96 | export default WeatherApi;
97 |
--------------------------------------------------------------------------------
/src/cards/weatherApi2.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | const WeatherApi2 = () => {
6 | const [cityName, setCityName] = useState("");
7 |
8 | const [showResults, setShowResults] = useState(false);
9 | const [showError, setShowError] = useState(false);
10 | const [temp, setTemp] = useState("");
11 | const [weather, setWeather] = useState("");
12 |
13 | const getCityName = (e) => {
14 | setCityName(e.target.value);
15 | setShowResults(false);
16 | setShowError(false);
17 | };
18 |
19 | const apiKey = process.env.REACT_APP_WEATHER_API2_KEY;
20 | const unit = "metric";
21 | const url =
22 | "https://api.openweathermap.org/data/2.5/weather?q=" +
23 | cityName +
24 | "&units=" +
25 | unit +
26 | "&appid=" +
27 | apiKey;
28 | const getTemperature = async () => {
29 | let dataFound = false;
30 |
31 | await fetch(url)
32 | .then((res) => {
33 | if (res.status === 200) {
34 | return res.json();
35 | } else {
36 | return {
37 | main: { temp: "NOT FOUND" },
38 | weather: [{ description: "NOT FOUND" }],
39 | };
40 | }
41 | })
42 | .then((data) => {
43 | if (data.main.temp !== "NOT FOUND") {
44 | setTemp(data.main.temp);
45 | setWeather(data.weather[0].description);
46 | dataFound = true;
47 | }
48 | });
49 | if (dataFound) {
50 | setShowResults(true);
51 | } else {
52 | setShowError(true);
53 | }
54 | };
55 |
56 | const Results = () => (
57 | <>
58 |
59 | {" "}
60 | The temperature in{" "}
61 | {cityName.charAt(0).toUpperCase() + cityName.slice(1)} is{" "}
62 | {temp}° celsius and the weather
63 | is {weather}
64 |
65 | >
66 | );
67 | const Error = () => (
68 | <>
69 |
70 | {" "}
71 | The weather for the provided location couldn't be found
72 |
73 | >
74 | );
75 | return (
76 |
77 |
78 | Weather By City Name API
79 |
80 |
81 |
82 |
89 |
90 |
91 |
92 |
96 | Get Weather
97 |
98 |
99 |
100 | {showResults ?
: null}
101 | {showError ?
: null}
102 |
106 |
110 |
111 | );
112 | };
113 |
114 | export default WeatherApi2;
115 |
--------------------------------------------------------------------------------
/src/cards/TrendingRepositories.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 | import axios from "axios";
5 |
6 | const TrendingRepositories = () => {
7 | const [trendingRepos, setTrendingRepos] = useState([]);
8 | const [trendingReposJSX, setTrendingReposJSX] = useState([]);
9 |
10 | useEffect(() => {
11 | const getTrendingRepos = async () => {
12 | const { data } = await axios.get(
13 | "https://api.trending-github.com/github/repositories",
14 | {
15 | params: {
16 | // period can be daily, weekly or monthly
17 | period: "daily",
18 | },
19 | }
20 | );
21 |
22 | setTrendingRepos(data);
23 | };
24 |
25 | getTrendingRepos();
26 | }, []);
27 |
28 | const getTrendingReposJSX = () => {
29 | const trendingReposJSX = trendingRepos.map((repo) => (
30 |
34 |
35 |
51 |
52 |
53 |
58 |
{repo.stars}
59 |
60 |
61 |
66 |
{repo.forks}
67 |
68 |
69 |
70 |
71 | ));
72 |
73 | setTrendingReposJSX(trendingReposJSX);
74 | };
75 |
76 | return (
77 |
78 |
Trending GitHub Repositories
79 |
80 |
81 |
82 | {/* Added the show button for controlled API call */}
83 | {trendingReposJSX.length === 0 && (
84 |
88 | Show Trending Repositories
89 |
90 | )}
91 | {trendingReposJSX.length !== 0 && (
92 |
setTrendingReposJSX([])}
95 | >
96 | Close
97 |
98 | )}
99 |
100 |
101 | {trendingReposJSX.length > 0 && trendingReposJSX}
102 |
103 |
104 |
105 |
106 |
110 |
114 |
115 | );
116 | };
117 |
118 | export default TrendingRepositories;
119 |
--------------------------------------------------------------------------------
/src/cards/pokeAPI.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function RandomAdvice(props) {
6 | const [pokemon, setPokemon] = useState({});
7 | const [pokeName, setPokeName] = useState("");
8 | const [loading, setLoading] = useState(false);
9 | const [status, setStatus] = useState(200);
10 | const [suggestions, setSuggestions] = useState([]);
11 |
12 | const pokeApiUrl = "https://pokeapi.co/api/v2/pokemon";
13 |
14 | useEffect(() => {
15 | fetch(`${pokeApiUrl}/?limit=9`)
16 | .then((res) => res.json())
17 | .then((data) => setSuggestions(data.results));
18 | }, []);
19 |
20 | const setLocalEntry = (url, payload) =>
21 | localStorage.setItem(url, JSON.stringify(payload));
22 | const getLocalEntry = (url) => JSON.parse(localStorage.getItem(url));
23 |
24 | const onSubmit = async (event) => {
25 | event.preventDefault();
26 | try {
27 | setLoading(true);
28 | const url = `${pokeApiUrl}/${pokeName.toLowerCase()}`;
29 | const localEntry = getLocalEntry(url);
30 | if (localEntry) {
31 | return setPokemon(localEntry);
32 | }
33 | const response = await fetch(url);
34 | setStatus(response.status);
35 |
36 | const data = await response.json();
37 | setLocalEntry(url, data);
38 | setPokemon(data);
39 | } catch (error) {
40 | console.error(error);
41 | } finally {
42 | setLoading(false);
43 | }
44 | };
45 |
46 | const capitalize = (string) => {
47 | if (string) {
48 | return string
49 | .charAt(0)
50 | .toUpperCase()
51 | .concat(
52 | string
53 | .split("")
54 | .splice(1, string.length - 1)
55 | .join("")
56 | );
57 | }
58 | };
59 |
60 | return (
61 |
125 | );
126 | }
127 |
--------------------------------------------------------------------------------
/src/cards/cryptoDetails.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 |
5 | export default function CryptoDetails(props) {
6 | const [cryptoName, setCryptoName] = useState();
7 | const [data, setData] = useState([]);
8 | const [finalData, setFinalData] = useState([]);
9 | const [error, setError] = useState();
10 | var checked;
11 |
12 | useEffect(() => {
13 | fetch("https://api.coincap.io/v2/assets")
14 | .then((res) => res.json())
15 | .then((res) => setData([res.data]));
16 | }, []);
17 |
18 | const displayDetails = () => {
19 | data.map((res) => {
20 | res
21 | .filter((id) => id.id === cryptoName)
22 | .map((final) => {
23 | checked = 1;
24 | setFinalData([final]);
25 | return 0;
26 | });
27 | return 0;
28 | });
29 | if (checked === 1) {
30 | setError(0);
31 | } else {
32 | setError(1);
33 | }
34 | document.getElementById("crypto").value = "";
35 | };
36 |
37 | return (
38 |
39 |
40 | Crypto Currrency Details :
41 |
42 |
43 |
44 | setCryptoName(e.target.value)}
51 | />
52 |
53 |
54 |
58 | Search
59 |
60 |
61 |
62 |
63 | {error === 1 ? (
64 |
65 |
66 |
67 | No such crptocurrency found!
68 |
69 |
70 |
71 | ) : (
72 | finalData.map((res) => {
73 | return (
74 |
75 |
76 |
77 |
78 |
Name :
79 |
{res.name}
80 |
81 |
82 |
ID :
83 |
{res.id}
84 |
85 |
86 |
Rank :
87 |
{res.rank}
88 |
89 |
90 |
Symbol :
91 |
{res.symbol}
92 |
93 |
94 |
price:
95 |
{res.priceUsd}
96 |
97 |
98 |
99 |
100 | );
101 | })
102 | )}
103 |
104 |
105 |
109 |
110 |
111 | );
112 | }
113 |
--------------------------------------------------------------------------------
/src/cards/RandomProfile.js:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from "react";
2 | import {
3 | FaEnvelopeOpen,
4 | FaUser,
5 | FaCalendarTimes,
6 | FaMap,
7 | FaPhone,
8 | FaLock,
9 | } from "react-icons/fa";
10 | import ContributorInfo from "../components/contributorInfo";
11 | import ApiInfo from "../components/apiInfo";
12 |
13 | const RandomProfile = () => {
14 | const url = "https://randomuser.me/api/";
15 | const defaultImage = "https://randomuser.me/api/portraits/men/23.jpg";
16 |
17 | // common conventions
18 | const [isLoading, setIsLoading] = useState(true);
19 | const [randomPerson, setRandomPerson] = useState(null);
20 | const [title, setTitle] = useState("name");
21 | const [value, setValue] = useState("random person");
22 |
23 | const fetchRandomPerson = async () => {
24 | setIsLoading(true);
25 | const response = await fetch(url);
26 | const data = await response.json();
27 | // let's have a look at the API
28 | const person = data.results[0];
29 | // destructure values
30 | const {
31 | phone,
32 | email,
33 | login: { password },
34 | name: { first, last },
35 | dob: { age },
36 | picture: { large: image },
37 | location: {
38 | street: { number, name },
39 | },
40 | } = person;
41 | // es6 feature
42 | const newPerson = {
43 | image,
44 | phone,
45 | email,
46 | password,
47 | age,
48 | street: `${number} ${name}`,
49 | name: `${first} ${last}`,
50 | };
51 |
52 | setRandomPerson(newPerson);
53 | setIsLoading(false);
54 | setTitle("name");
55 | setValue(newPerson.name);
56 | };
57 |
58 | useEffect(() => {
59 | fetchRandomPerson();
60 | }, []);
61 |
62 | const handleValue = (e) => {
63 | if (e.target.classList.contains("icon")) {
64 | const newValue = e.target.dataset.id;
65 | setTitle(newValue);
66 | setValue(randomPerson[newValue]);
67 | }
68 | };
69 |
70 | return (
71 |
72 |
73 |
Random User API
74 |
75 |
76 |
77 |
82 |
my {title} is
83 |
{value}
84 |
85 |
86 |
87 |
88 |
93 |
94 |
95 |
96 |
97 |
98 |
103 |
104 |
105 |
110 |
111 |
112 |
117 |
118 |
119 |
120 |
121 | {isLoading ? "loading..." : "random user"}
122 |
123 |
124 |
125 |
126 |
130 |
134 |
135 |
136 | );
137 | };
138 |
139 | export default RandomProfile;
140 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | - Demonstrating empathy and kindness toward other people
21 | - Being respectful of differing opinions, viewpoints, and experiences
22 | - Giving and gracefully accepting constructive feedback
23 | - Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | - Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | - The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | - Trolling, insulting or derogatory comments, and personal or political attacks
33 | - Public or private harassment
34 | - Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | - Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | .
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/src/cards/Movies.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import axios from "axios";
3 | import ContributorInfo from "../components/contributorInfo";
4 | import ApiInfo from "../components/apiInfo";
5 |
6 | const MovieCard = (props) => {
7 | const [isSeeMore, setIsSeeMore] = useState(false);
8 | const { movie } = props;
9 | const movieOverview = isSeeMore
10 | ? movie.overview
11 | : movie.overview.substr(0, 50) + "...";
12 |
13 | return (
14 |
15 |
16 |
21 |
22 |
23 |
{movie.title}
24 |
25 |
26 | Release date : {movie.release_date}
27 |
28 |
29 | Vote (avg) : {movie.vote_average}
30 |
31 |
32 | Vote count : {movie.vote_count}
33 |
34 |
35 | Popularity : {movie.popularity}
36 |
37 |
38 | {movieOverview}
39 |
40 |
41 | {isSeeMore ? (
42 | setIsSeeMore(false)}
45 | >
46 | see less
47 |
48 | ) : (
49 | setIsSeeMore(true)}
52 | >
53 | see more
54 |
55 | )}
56 |
57 |
58 |
59 |
60 | );
61 | };
62 |
63 | const Movies = () => {
64 | const [keyword, setKeyword] = useState("");
65 | const [movies, setMovies] = useState([]);
66 | const [isLoading, setIsLoading] = useState(false);
67 | const [currentPage, setCurrentPage] = useState(1);
68 | const [totalPage, setTotalPage] = useState(0);
69 |
70 | const searchMovies = (page = 1) => {
71 | const apiKey = process.env.REACT_APP_MOVIE_API_KEY;
72 | const params = {
73 | api_key: apiKey,
74 | query: keyword,
75 | page,
76 | };
77 | const headers = {
78 | "Content-Type": "application/json",
79 | };
80 | const url = "https://api.themoviedb.org/3/search/movie";
81 |
82 | setIsLoading(true);
83 |
84 | axios
85 | .get(url, { params, headers })
86 | .then((response) => {
87 | console.log(response);
88 | if (!response || !response.data || !response.data.results) return;
89 |
90 | setMovies(response.data.results);
91 | setTotalPage(response.data.total_pages);
92 | setCurrentPage(page);
93 | })
94 | .catch((error) => {
95 | console.error(error.message);
96 | })
97 | .finally(() => setIsLoading(false));
98 | };
99 |
100 | const handlePreviousPage = () => {
101 | if (currentPage <= 1) return;
102 |
103 | searchMovies(currentPage - 1);
104 | };
105 |
106 | const handleNextPage = () => {
107 | if (currentPage >= totalPage) return;
108 |
109 | searchMovies(currentPage + 1);
110 | };
111 |
112 | return (
113 |
114 |
Movies API
115 |
116 |
117 | setKeyword(e.target.value)}
123 | />
124 | searchMovies()}
127 | >
128 | {isLoading ? "Loading.." : "Search"}
129 |
130 |
131 |
132 | {movies.length > 0 && (
133 |
134 |
135 | Page {currentPage} of {totalPage}
136 |
137 |
138 |
139 | {movies.map((movie) => {
140 | return ;
141 | })}
142 |
143 |
144 |
145 |
150 | {"<"} Previous
151 |
152 | = totalPage}
156 | >
157 | Next {">"}
158 |
159 |
160 |
161 | )}
162 |
163 |
167 |
171 |
172 | );
173 | };
174 |
175 | export default Movies;
176 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import "./App.css";
2 | import RandomValorantWeapon from "./cards/RandomValorantWeapon";
3 | import GetIcon from "./cards/GetIcon";
4 | import WeatherApi2 from "./cards/weatherApi2";
5 | import RandomAnimeSeries from "./cards/RandomAnimeSeries";
6 | import CoffeApi from "./cards/coffeApi";
7 | import Header from "./components/header";
8 | import Message from "./components/content";
9 | import RandomKanyeQuote from "./cards/RandomKanyeQuote";
10 | import PublicApi from "./cards/PublicApiApi";
11 | import MemesApi from "./cards/MemesApi";
12 | import MusicPlayer from "./cards/MusicPlayer";
13 | import RandomQuotes from "./cards/randomQuotes";
14 | import RandomAdvice from "./cards/randomAdvice";
15 | import RandomAnime from "./cards/randomAnime";
16 | import StarWarsAPI from "./cards/starWarsAPI";
17 | import RandomDadJoke from "./cards/randomDadJoke";
18 | import RandomCatFacts from "./cards/randomCatFacts";
19 | import ChuckNorrisJoke from "./cards/chuckNorrisJoke";
20 | import RandomGeekJokes from "./cards/randomGeekJokes";
21 | import RandomBriyaniPics from "./cards/RandomBriyaniPics";
22 | import RandomActivity from "./cards/boredAPI";
23 | import RandomAnimfacts from "./cards/randomDogfacts";
24 | import BreadPuns from "./cards/breadPuns";
25 | import RandomDogimage from "./cards/RandomDogimage";
26 | import PokeApi from "./cards/pokeAPI";
27 | import RandomCreditCard from "./cards/randomCreditCard";
28 | import RandomFoxImage from "./cards/randomFoxImage";
29 | import Covidapi from "./cards/covidApi";
30 | import GitHubUser from "./cards/githubUser";
31 | import RandomCatimages from "./cards/RandomCatimages";
32 | import ZipCodeDetailsAPI from "./cards/ZipCodeDetailsAPI";
33 | import ImageCompression from "./cards/imageCompressionAPI";
34 | import GiphyApi from "./cards/giphyapi";
35 | import Dungeons from "./cards/Dungeons";
36 | import WeatherApi from "./cards/weatherApi";
37 | import UrlShortener from "./cards/url-shortener";
38 | import CryptoDetails from "./cards/cryptoDetails";
39 | import RandomJokeApi from "./cards/randomJokeApi";
40 | import FakeStoreAPI from "./cards/fakeStoreAPI";
41 | import RicknMorty from "./cards/ricknmortyApi";
42 | import RandomMoiveQuote from "./cards/RandomMovieQuote";
43 | import RandomDuckAPI from "./cards/RandomDuckAPI";
44 | import RandomFoodPicApi from "./cards/randomFoodPics";
45 | import PasswordGenerator from "./cards/PasswordGenerator";
46 | import TrendingRepositories from "./cards/TrendingRepositories";
47 | import QuoteClearAPI from "./cards/quoteClearAPI";
48 | import RandomCarImage from "./cards/randomCarImage";
49 | import NasaApi from "./cards/NasaApi";
50 | import Poemist from "./cards/randomPoemsAPI";
51 | import BookDetails from "./cards/bookDetails";
52 | import RandomProfile from "./cards/RandomProfile";
53 | import Publicholiday from "./cards/publicholiday";
54 | import TronaldDump from "./cards/tronalddump";
55 | import HistoryOfTheDay from "./cards/HistoryOfTheDay";
56 | import BeerAPI from "./cards/BeerApi";
57 | import CovidUsaCases from "./cards/UsaCovidCases";
58 | import GenderGuess from "./cards/GenderGuess";
59 | import RandomGotQuotes from "./cards/randomGotQuotes";
60 | import AgeCalculator from "./cards/ageCalculator";
61 | import HaikuSyllableCounter from "./cards/HaikuSyllableCounter";
62 | import Robohash from "./cards/robohash";
63 | import { DogAnimeQuotes } from "./cards/dogWithAnimeQuotes";
64 | import RandomPlaceholderImage from "./cards/randomPlaceholderImage";
65 | import Foaas from "./cards/foaasapi";
66 | import RandomDadJokes from "./cards/randomDadJokes";
67 | import PageVisits from "./cards/PageVisits";
68 | import RandomAdage from "./cards/RandomAdage";
69 | import Sunshinetime from "./cards/Sunshinetime";
70 | import SpacexCrew from "./cards/SpacexcrewAPI";
71 | import EvaluateMath from "./cards/EvaluateMath";
72 | import SimpleAdd from "./cards/SimpleAdd";
73 | import Movies from "./cards/Movies";
74 |
75 | function App() {
76 | return (
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 | );
152 | }
153 |
154 | export default App;
155 |
--------------------------------------------------------------------------------
/src/cards/fakeStoreAPI.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect } from "react";
2 | import ContributorInfo from "../components/contributorInfo";
3 | import ApiInfo from "../components/apiInfo";
4 | const FakeStoreAPI = () => {
5 | useEffect(() => {
6 | fetch("https://fakestoreapi.com/products/1")
7 | .then((res) => res.json())
8 | .then((json) => console.log(json));
9 | }, []);
10 | return (
11 |
12 |
13 |
The Fake store API
14 |
15 | Best api to create e-commerce project with CRUD operations where we
16 | will be getting following data from the fake store api:
17 |
18 |
19 | 1.Categories available
20 | 2.Products in each Category
21 | 3.Product details
22 |
23 |
24 | This is a small ecommerce site which is done using fakestore api
25 | (includes all basic redux functionalities ) -
26 |
32 | Click here
33 |
34 |
35 |
39 |
40 |
41 |
42 | );
43 | };
44 |
45 | export default FakeStoreAPI;
46 |
--------------------------------------------------------------------------------
/src/cards/ageCalculator.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { useState } from "react";
3 | import ContributorInfo from "./../components/contributorInfo";
4 | import ApiInfo from "./../components/apiInfo";
5 |
6 | export default function AgeCalculator() {
7 | let [day, setDay] = useState("");
8 | let [month, setMonth] = useState("");
9 | let [year, setYear] = useState("");
10 | let [response, setResponse] = useState("");
11 |
12 | const search = () => {
13 | fetch(
14 | `https://starta11.herokuapp.com/calculate?day=${day}&month=${month}&year=${year}`
15 | )
16 | .then((res) => res.json())
17 | .then((data) => {
18 | setResponse(data);
19 | });
20 | };
21 |
22 | return (
23 |
24 |
25 | Interplanetary Age Calculator
26 |
27 |
{
34 | setDay(e.target.value);
35 | }}
36 | />
37 |
38 |
{
45 | setMonth(e.target.value);
46 | }}
47 | />
48 |
49 |
{
56 | setYear(e.target.value);
57 | }}
58 | />
59 |
60 |
search()}
62 | className="bg-green-900 p-2 rounded-2xl text-white"
63 | >
64 | Search your Age
65 |
66 | {response !== "" ? (
67 |
68 | Mercury : {response.mercury} years Venus :{" "}
69 | {response.venus} years Earth :{" "}
70 | {response.earth} years
71 |
72 | Mars : {response.mars} years Jupiter :{" "}
73 | {response.jupiter} years Saturn :{" "}
74 | {response.saturn} years
75 |
76 |
77 | Neptune : {response.neptune} years Uranus :{" "}
78 | {response.uranus} years Pluto :{" "}
79 | {response.pluto} years
80 |
81 | ) : null}
82 |
86 |
90 |
91 | );
92 | }
93 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Just Calling Random APIs
2 |
3 | 
4 | 
5 | [](https://gitter.im/JustCallingRandomAPI/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
6 |
7 | This is a react project to help you get started on your open-source journey. All you need to do is to call any [public API](https://github.com/public-apis/public-apis) and show us its response in your react component. It could be quotes, cat images, bitcoin - anything. Design it the way you want! Complete your Hacktoberfest challenge this year.
8 |
9 | ## Table of content
10 |
11 | - [Hacktoberfest](#hacktoberfest)
12 | - [What's in it for you?](#whats-in-it-for-you)
13 | - [Prerequisite](#prerequisite)
14 | - [Git and Github](#git--github)
15 | - [What's an API?](#whats-an-api)
16 | - [React](#react)
17 | - [Tailwind](#tailwind)
18 | - [Local setup](#local-setup)
19 | - [How to contribute?](#how-to-contribute)
20 | - [Contributors](#contributors)
21 |
22 | ## Hacktoberfest
23 |
24 | 
25 |
26 | [Hacktoberfest](https://hacktoberfest.digitalocean.com/) is a global challenge organized by DigitalOcean. It encourages participation in giving back to the open-source community by completing pull requests and participating in events. You can sign up anytime between 1 and October 31. Pull requests can be submitted to this repo or any opted-in GitHub or GitLab repo. To get a T-shirt :tshirt:, you must make 4 approved pull requests (PRs). :tada:
27 |
28 | [](https://hacktoberfest.digitalocean.com/resources/participation)
29 |
30 | ## What's in it for you?
31 |
32 | After contributing you would find yourself familiar and more confident with
33 |
34 | :heavy_check_mark: Basics of GitHub workflow :metal:
35 |
36 | :heavy_check_mark: Basics of React and Tailwind :yellow_heart:
37 |
38 | :heavy_check_mark: How to read API documentation and consume APIs :computer:
39 |
40 | ## Prerequisite
41 |
42 | ### Git & Github
43 |
44 | Here, we have mentioned the instructions to set up git. If you don't already know what Git is, check out this blog by [FreeCodeCamp](https://www.freecodecamp.org/news/what-is-git-and-how-to-use-it-c341b049ae61/).
45 |
46 | - Login / Sign-up to [Github](https://github.com/login).
47 | - Download and install [Git](https://git-scm.com/downloads).
48 | - Configure git
49 | - Launch terminal or command promt.
50 | - Run the commands.
51 | - `git config --global user.name "Your name"`
52 | - `git config --global user.email "Your email address"`
53 | - Optionally, you can [setup ssh keys](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) to authenticate easily.
54 |
55 | ### What's an API?
56 |
57 | API stands for Application Programming Interface. Imagine what happens at a restaurant :fork_and_knife: - You order your favorite food :pizza: ( Request ), the waiter serves your order when it's ready (API Response). You are not aware of how the food is prepared. Similarly, you request data from an API, and the API returns it to you. You need not be aware of what's happening behind the scenes. Now, anybody who knows where the restaurant is, and how to communicate with the waiter can place an order. Similarly, anyone can consume an API even computer programs :robot:.
58 |
59 | Whenever you visit [just-callling-random-api](https://vedangj044.github.io/just-calling-random-api/) you would see a new quote, I could have manually created a list of 1000 quotes and picked up anyone at random but instead, I can just consume [`Quotable`](https://forum.freecodecamp.org/t/free-api-inspirational-quotes-json-with-code-examples/311373/5) API offered by FreeCodeCamp which saves me all the trouble of manually creating the list and offers way more quotes than I could have added.
60 |
61 | There are amazing people out there, who have created a large number of awesome APIs - random Cat pictures :cat2: , random dogs pictures :dog:, breaking bad quotes, harry potter quotes, bitcoin prices :moneybag: , NASA space images, etc. You can find all of these and many more at [Public APIs repository](https://github.com/public-apis/public-apis).
62 |
63 | For this project, you need to pick up any API you like from this list, read about how you can use it, try calling it and understanding its response, and then consuming it your react components. We are extremely excited to see what API you choose and what you make with it! :tada:
64 |
65 | [](https://www.freecodecamp.org/news/what-is-an-api-in-english-please-b880a3214a82/)
66 |
67 | ### React
68 |
69 | React is a JavaScript library created for building fast and interactive user interfaces for web applications. It allows developers to create web applications that can change data, without reloading the page. Above all, it's simple and easy to learn. Here's a quick [](https://www.youtube.com/watch?v=Tn6-PIqc4UM) by Fireship.
70 |
71 | We are also going to use React Hooks - These allow developers to use state inside a functional component. More about it - [](https://www.youtube.com/watch?v=TNhaISOUy6Q)
72 |
73 | To start with react you need to install NPM. If you don't have it installed on your system, then you need to head to the [official Node.js website](https://nodejs.org/en/) to download and install Node, which also includes NPM (Node Package Manager). Select the "Recommended For Most Users" button and download the current version for your operating system.
74 |
75 | [](https://www.w3schools.com/REACT/react_getstarted.asp)
76 |
77 | ### Tailwind
78 |
79 | Tailwind is a utility-first CSS framework. For this project, we don't need to know about it in detail, but it would help you style your contribution if you understand the basics. To style a component, all you need to do is specify a tailwind class in its class name. Tailwind classes are very intuitive and you can find all of them in this [cheat sheet](https://nerdcave.com/tailwind-cheat-sheet). Tailwind is pretty awesome and you can know more about it [here](https://tailwindcss.com/docs).
80 |
81 | ### Local setup
82 |
83 | - Go to the top of this page and click on the "Fork" button.
84 |
85 | 
86 |
87 | This would make a copy of this repository in your account. You will see `/just-calling-random-api`.
88 |
89 | 
90 |
91 | - Clone the repository
92 | - Click on the "Code" button and copy the URL.
93 | - On your local machine, run terminal / cmd and type `git clone `. This creates a new folder named "just-calling-random-api".
94 | - Go to the folder.
95 | - Run `npm install` or `yarn install` to install all dependencies.
96 | - Run `npm start` or `yarn start` to start the web app.
97 |
98 | ### Docker setup
99 |
100 | These instructions will cover usage information and for the docker container.
101 |
102 | #### Prerequisities
103 |
104 | In order to run this container you'll need docker installed.
105 |
106 | - [Windows](https://docs.docker.com/windows/started)
107 | - [OS X](https://docs.docker.com/mac/started/)
108 | - [Linux](https://docs.docker.com/linux/started/)
109 |
110 | #### Usage
111 |
112 | ```
113 | # build docker image
114 | $ docker build . -t just-calling-random-api:latest
115 |
116 | # Run docker image
117 | $ docker run -p 80:80 just-calling-random-api:latest
118 | ```
119 |
120 | You can access the application in http://localhost
121 |
122 | ## How to contribute?
123 |
124 | ### Preparation
125 |
126 | - Make sure that the main branch of your fork is even with this repo.
127 |
128 | 
129 |
130 | - Otherwise, click on the "Fetch and merge" button and go to the project folder on your computer and run `git pull` to update the changes in your local repo.
131 |
132 | 
133 |
134 | - Launch a terminal and run the commands
135 | - `git branch ` - This creates a new branch. The branch name should be similar to the API name.
136 | - `git checkout ` - Checkout to your branch. This helps you work in parallel but without disturbing files on the main branch.
137 |
138 | ### Working on your contribution
139 |
140 | - Go to the [Public APIs repository](https://github.com/public-apis/public-apis).
141 | - Browse through the list and pick any.
142 | - The chosen API should have HTTPS enabled.
143 | - Think of some creative use-case of this API, something you would like everybody to see.
144 | - Now, Open VS code or any text editor.
145 | - Create a new file in the `src/cards` folder.
146 | - Create and export a basic function component. An example is given here. The components' name should briefly describe its purpose.
147 |
148 | ```
149 | import React from "react";
150 | function MyComponent() {
151 | return Hi, This is my component. ;
152 | }
153 | ```
154 |
155 | - Now, go to `app.js`. Import and render the component you just created. Now when you do `npm start` you should see a new component.
156 | - Go through the documentation of your API. It would contain instructions on its usage. Use those instructions to create a fetch request. Take help from randomQuotes component. This step would be different for all of us. Don't worry, API documentation and code in other components would give you enough clues. Consume the API and display its response in your component.
157 | - If your API requires an API Key, follow these [instructions](https://dev.to/thepuskar/how-to-hide-your-api-keys-in-react-4k55). Never add API key in the code. Text us on the Gitter channel and we would add an environment variable for your key.
158 | - Great, if you have done the above part Congratulations! :tada:
159 | - Use the tailwind [cheatsheet](https://nerdcave.com/tailwind-cheat-sheet) to style your work.
160 | - Include the following in your component after making appropriate changes.
161 |
162 | ```
163 |
164 | apiName= [ Name of API used ] />
165 | ```
166 |
167 | - Run the project to verify your code works as expected.
168 |
169 | ### Submitting your work
170 |
171 | - Open a terminal and run these commands
172 | - `git add .` - stage your changes.
173 | - `git commit -m ` - commit changes
174 | - `git checkout main` - checkout back to the main branch
175 | - `git push --all` - push all changes to Github.
176 | - Go to your fork, you would see a pop-up asking you to make a PR. Click on "Compare & pull request".
177 |
178 | 
179 |
180 | - Write a small description and complete the checklist. Click on "Make a PR".
181 |
182 | Wait for it to get approved and merged. Awesome, you have made your first contribution. To make a further contribution, you need to create new branches. Your next contributions could be improvements to previous work or a new API call. Certain things may not work as expected, or you may have doubts about some steps mentioned above. Need not worry, just hop on to our [gitter channel](https://gitter.im/JustCallingRandomAPI/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) and ask.
183 |
184 | ### Contributors
185 |
186 | List generated with [contributors-img](https://contrib.rocks). [Updates every 24 hrs]
187 |
188 |
189 |
190 |
191 |
--------------------------------------------------------------------------------