Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rapid API #392

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions New_APIs/Rapid API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>RapidAPI Marketplace</title>
</head>
<body>
<header>
<h1>RapidAPI Marketplace</h1>
</header>
<main id="app">
<section>
<h2>Discover an API</h2>
<button id="fetchApiButton">Fetch Random API</button>
</section>
<section id="api-info">
<h2>API Details</h2>
<div id="api"></div>
</section>
</main>
<script src="index.js"></script>
</body>
</html>
48 changes: 48 additions & 0 deletions New_APIs/Rapid API/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('fetchApiButton').addEventListener('click', fetchRandomApi);
});

async function fetchRandomApi() {
const apiKey = 'YOUR_RAPIDAPI_KEY';
const apiHost = 'example-apis.p.rapidapi.com'; // Replace with actual API host
const endpoint = `https://${apiHost}/apis/random`;

try {
const response = await fetch(endpoint, {
method: 'GET',
headers: {
'X-RapidAPI-Key': apiKey,
'X-RapidAPI-Host': apiHost,
'Accept': 'application/json'
}
});

if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}

const data = await response.json();
console.log('Fetched data:', data);
if (data.api) {
displayApi(data.api);
} else {
displayError('No API found.');
}
} catch (error) {
console.error('Error fetching API:', error);
displayError('Failed to fetch API details.');
}
}

function displayApi(api) {
const apiDiv = document.getElementById('api');
apiDiv.innerHTML = `
<h3>${api.name}</h3>
<p><strong>Category:</strong> ${api.category}</p>
<p><strong>Description:</strong> ${api.description}</p>
<a href="${api.api_url}" target="_blank">Explore API</a>
`;
}

function displayError(message) {
const apiDiv = document.getElementById('api');
15 changes: 15 additions & 0 deletions New_APIs/Rapid API/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "RapidAPIApp",
"name": "RapidAPI Marketplace",
"icons": [
{
"src": "icon.png",
"type": "image/png",
"sizes": "192x192"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#00c6ff",
"background_color": "#0072ff"
}
15 changes: 15 additions & 0 deletions New_APIs/Rapid API/pacjake.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "rapidapi-marketplace-app",
"version": "1.0.0",
"description": "A simple app to discover random APIs from RapidAPI Marketplace",
"main": "index.js",
"scripts": {
"start": "node server.js"
},
"author": "Your Name",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}

37 changes: 37 additions & 0 deletions New_APIs/Rapid API/package-lock.json

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

70 changes: 70 additions & 0 deletions New_APIs/Rapid API/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
body {
font-family: 'Arial', sans-serif;
background: linear-gradient(135deg, #00c6ff, #d3e84a);
color: #333;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
}

header {
text-align: center;
margin-bottom: 20px;
}

header h1 {
font-size: 3em;
color: #fff;
}

main {
background: rgba(255, 255, 255, 0.9);
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
text-align: center;
}

section {
margin-bottom: 20px;
}

h2 {
font-size: 2em;
margin-bottom: 10px;
color: #00c6ff;
}

button {
padding: 10px 20px;
font-size: 1em;
color: #fff;
background-color: #00c6ff;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}

button:hover {
background-color: #0072ff;
}

#api-info {
margin-top: 20px;
}

#api {
font-size: 1.2em;
background: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#api p {
margin: 10px 0;
}
Loading