Skip to content

Commit

Permalink
Merge branch 'master' into vi4985
Browse files Browse the repository at this point in the history
  • Loading branch information
pallasivasai committed Aug 8, 2024
2 parents b75a226 + 2a30e95 commit 0e035b6
Show file tree
Hide file tree
Showing 287 changed files with 28,429 additions and 2 deletions.
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,40 @@ git push -u origin Branch_Name
- Go to your repository in browser and click on compare and pull requests.
Then add a title and description to your pull request that explains your contribution.

### Alternatively, contribute using GitHub Desktop

1. **Open GitHub Desktop:**
Launch GitHub Desktop and log in to your GitHub account if you haven't already.

2. **Clone the Repository:**
- If you haven't cloned the APIVerse repository yet, you can do so by clicking on the "File" menu and selecting "Clone Repository."
- Choose the APIVerse repository from the list of repositories on GitHub and clone it to your local machine.

3. **Switch to the Correct Branch:**
- Ensure you are on the branch that you want to submit a pull request for.
- If you need to switch branches, you can do so by clicking on the "Current Branch" dropdown menu and selecting the desired branch.

4. **Make Changes:**
Make your changes to the code or files in the repository using your preferred code editor.

5. **Commit Changes:**
- In GitHub Desktop, you'll see a list of the files you've changed. Check the box next to each file you want to include in the commit.
- Enter a summary and description for your changes in the "Summary" and "Description" fields, respectively. Click the "Commit to <branch-name>" button to commit your changes to the local branch.

6. **Push Changes to GitHub:**
After committing your changes, click the "Push origin" button in the top right corner of GitHub Desktop to push your changes to your forked repository on GitHub.

7. **Create a Pull Request:**
- Go to the GitHub website and navigate to your fork of the APIVerse repository.
- You should see a button to "Compare & pull request" between your fork and the original repository. Click on it.

8. **Review and Submit:**
- On the pull request page, review your changes and add any additional information, such as a title and description, that you want to include with your pull request.
- Once you're satisfied, click the "Create pull request" button to submit your pull request.

9. **Wait for Review:**
Your pull request will now be available for review by the project maintainers. They may provide feedback or ask for changes before merging your pull request into the main branch of the APIVerse repository.

### Need more help?🤔

You can refer to the following articles on basics of Git and Github and also contact the Project Mentors,
Expand Down
3 changes: 3 additions & 0 deletions Existing_API_Collection/Anime Api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Anime Facts Rest API

The Anime Facts Rest API is an API written in Node.js to get anime facts.
72 changes: 72 additions & 0 deletions Existing_API_Collection/Anime Api/Src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""
Base module for the anime facts rest api. The API documentation can be found at
https://chandan-02.github.io/anime-facts-rest-api/
Mantainer of the API: Chandan Kumar (https://github.com/chandan-02)
"""
import typing, requests, random

from anime_api import exceptions
from anime_api.apis.anime_facts_rest_api.objects import Anime, Fact


class AnimeFactsRestAPI:
"""
Docs: https://chandan-02.github.io/anime-facts-rest-api/
"""

endpoint = "https://anime-facts-rest-api.herokuapp.com/api/v1"

def get_animes(self) -> typing.List[Anime]:
"""
Returns a list of all animes.
"""
response = requests.get(self.endpoint)

if response.status_code != 200:
raise exceptions.ServerError(
status_code=response.status_code,
)

return [
Anime(
id=anime["anime_id"],
name=anime["anime_name"],
image=anime["anime_img"],
)
for anime in response.json()["data"]
]

def get_anime_facts(self, anime_name: str) -> typing.List[Fact]:
"""
Returns a list of facts about the given anime (by it's name).
"""
response = requests.get(f"{self.endpoint}/{anime_name}")

if response.status_code != 200:
raise exceptions.ServerError(
status_code=response.status_code
)

return [
Fact(id=fact["fact_id"], fact=fact["fact"]) for fact in response.json()["data"]
]

def get_anime_random_fact(self, anime_name: str) -> Fact:
"""
Return a random fact about the given anime (by it's name).
"""
return random.choice(self.get_anime_facts(anime_name))

def get_fact(self, anime_name: str, fact_id: int) -> Fact:
"""
Returns a specific Fact by it's ID and it's anime's name.
"""
response = requests.get(f"{self.endpoint}/{anime_name}/{fact_id}")

if response.status_code != 200:
raise exceptions.ServerError(
status_code=response.status_code,
)

return Fact(id=response.json()["data"]["fact_id"], fact=response.json()["data"]["fact"])
41 changes: 41 additions & 0 deletions Existing_API_Collection/Anime Api/Src/objects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from dataclasses import dataclass

import typing


@dataclass
class Anime:
"""
Object representation of an anime
"""

id: int
name: str
image: str

@property
def facts(self):
"""
Returns a list of facts about the anime.
"""
from anime_api.apis import AnimeFactsRestAPI

api = AnimeFactsRestAPI()

return api.get_anime_facts(self.name)

def __str__(self):
return self.name.replace('_', ' ').title()


@dataclass
class Fact:
"""
Object representation of an anime fact
"""

id: int
fact: str

def __str__(self):
return self.fact
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
Run tests for the AnimeFactsRestAPI class.
Usage:
cd tests
poetry run python -m pytest anime_facts_rest_api.py
"""

import typing

from anime_api.apis.anime_facts_rest_api import AnimeFactsRestAPI
from anime_api.apis.anime_facts_rest_api.objects import Anime, Fact


def test_get_animes():
"""
Test the get_animes method. Should return a list of animes.
"""
animes: typing.List[Anime] = AnimeFactsRestAPI().get_animes()

assert isinstance(
animes, list
), "The return type of get_animes() is not a list."
assert len(animes) > 0, "The list of animes is empty."
assert isinstance(
animes[0], Anime
), "The list of animes does not contain objects.Anime objects."


def test_get_anime_facts():
"""
Test the get_anime_facts method. Should return a list of facts.
"""
facts: typing.List[Fact] = AnimeFactsRestAPI().get_anime_facts(anime_name="naruto")

assert isinstance(
facts, list
), "The return type of get_anime_facts() is not a list."
assert len(facts) > 0, "The list of facts is empty."
assert isinstance(
facts[0], Fact
), "The list of facts does not contain objects.Fact objects."

def test_get_fact():
"""
Test the get_fact method. Should return a single fact.
"""
fact: Fact = AnimeFactsRestAPI().get_fact(anime_name="naruto", fact_id=1)

assert isinstance(
fact, Fact
), "The return type of get_fact() is not a objects.Fact object."
105 changes: 105 additions & 0 deletions Existing_API_Collection/Covid19Tracker API/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
Sure, here's a README.md template for your COVID-19 Tracker API project:

````markdown
# COVID-19 Tracker API

A RESTful API for fetching COVID-19 statistics by country and globally.

## Getting Started

To get started with this API, follow the instructions below.

### Prerequisites

- Node.js and npm installed on your machine
- API key (optional, depending on the data source used)

### Installation

1. Clone the repository:

```bash
git clone https://github.com/your-username/covid19-tracker-api.git
```
````

2. Navigate to the project directory:

```bash
cd covid19-tracker-api
```

3. Install dependencies:

```bash
npm install
```

4. Set up environment variables (optional):

Create a `.env` file in the root directory and add your API key (if required) as follows:

```env
API_KEY=your-api-key
```

### Usage

1. Start the server:

```bash
npm start
```

2. The API endpoints are available at:

- `/countries`: Get a list of available countries and their codes.
- `/countries/:countryCode`: Get COVID-19 statistics for a specific country.
- `/global`: Get global COVID-19 statistics.

### Example Requests

- Get a list of available countries:

```http
GET http://localhost:3000/countries
```

- Get COVID-19 statistics for a specific country (replace `:countryCode` with the country code, e.g., "US" for the United States):

```http
GET http://localhost:3000/countries/:countryCode
```

- Get global COVID-19 statistics:
```http
GET http://localhost:3000/global
```

### Response Format

The API responses are in JSON format and include fields such as total cases, active cases, deaths, and recoveries.

Example response for `/countries/:countryCode`:

```json
{
"country": "United States",
"cases": 1000000,
"deaths": 50000,
"recovered": 800000
}
```

## Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

```

Feel free to customize this README template to include additional information or specific instructions relevant to your project setup and usage.
```
62 changes: 62 additions & 0 deletions Existing_API_Collection/Covid19Tracker API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>COVID-19 Tracker</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<div class="container">
<h1>COVID-19 Tracker</h1>
<div class="input-container">
<label for="country">Select Country:</label>
<select id="country"></select>
</div>
<div class="statistics-container">
<div class="country-statistics">
<h2><span id="selected-country"></span></h2>
<div class="statistic">
<span class="label">Total Cases:</span>
<span id="total-cases"></span>
</div>
<div class="statistic">
<span class="label">Active Cases:</span>
<span id="active-cases"></span>
</div>
<div class="statistic">
<span class="label">Deaths:</span>
<span id="deaths"></span>
</div>
<div class="statistic">
<span class="label">Recoveries:</span>
<span id="recoveries"></span>
</div>
</div>
<div class="global-statistics">
<h2>Global Statistics</h2>
<div class="statistic">
<span class="label">Total Cases:</span>
<span id="global-total-cases"></span>
</div>
<div class="statistic">
<span class="label">Active Cases:</span>
<span id="global-active-cases"></span>
</div>
<div class="statistic">
<span class="label">Deaths:</span>
<span id="global-deaths"></span>
</div>
<div class="statistic">
<span class="label">Recoveries:</span>
<span id="global-recoveries"></span>
</div>
</div>
</div>
</div>
<script src="script.js"></script>
</body>

</html>
Loading

0 comments on commit 0e035b6

Please sign in to comment.