-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18810fe
commit 51ad95e
Showing
3 changed files
with
43 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,58 @@ | ||
# Quotes API | ||
## Introduction | ||
The Quotes API is a versatile tool build in Django that provides access to a vast collection of inspirational, motivational, and thought-provoking quotes. Whether you're building an application, website, or project, this API allows you to effortlessly integrate inspiring quotes into your content, enriching user experiences. | ||
This is an API for performing the CRUD Operation on the Database. It is developed using Python (Django Rest Framework). | ||
|
||
## Features | ||
- Extensive Database: The API offers a comprehensive collection of quotes from various categories, ensuring you find the perfect quote for your needs. | ||
- Random Quote Generation: Surprise and inspire users with random quotes, perfect for applications that seek to deliver fresh content. | ||
- Author Attribution: Each quote includes the author, enabling proper attribution for the wisdom and insights shared. | ||
- API Integration: The Quotes API provides a straightforward HTTP interface for seamless integration into various platforms and programming languages. | ||
- Open Access: The API is open and accessible to everyone, without complex authentication requirements, making it ideal for hobbyists, educational projects, and developers at all levels. | ||
|
||
## Usage | ||
<p>To use the Quotes API, you can make a GET request to the provided endpoint `/api/quotes` to retrieve a random joke in JSON format.</p> | ||
Use the Quotes API by making simple HTTP requests to the API endpoints to retrieve quotes that align with your project's goals. This versatility allows you to easily integrate inspirational quotes into mobile apps, websites, scripts, and more. | ||
|
||
### Example in JS | ||
Here's an example of how to use the Quotes API to fetch a random quote in JS: | ||
## Features | ||
The URL Shortner has the following features. | ||
- User can perform `GET`,`POST`,`PUT` and `DELETE` Operation. | ||
|
||
```JavaScript | ||
fetch("GET","https://quotesapi.santosh0.com.np/api/quotes/") | ||
.then(response=>response.json()) | ||
.then(response=>{ | ||
console.log(response); | ||
}).catch(e=>{ | ||
console.log(e); | ||
}) | ||
``` | ||
### Example in Python | ||
Here's an example of how to use the Quotes API to fetch a random quote in Python: | ||
## Usages | ||
You System must have the following things to use this Blog App. | ||
- Installation of `python` and `pip` | ||
|
||
```python | ||
import requests | ||
Python is available for every platform. Download it according to you os. You can download it from [Here.](https://www.python.org/downloads/) | ||
|
||
url = "https://quotesapi.santosh0.com.np/api/quotes/" | ||
response = requests.get(url) | ||
data = response.json() | ||
|
||
print(f"Random Quote: {data['quotes']} - {data['author']}") | ||
Follow the mentioned procedure to run this project in your local system. | ||
- Clone or Download the Repository | ||
```bash | ||
git clone https://github.com/santoshvandari/QuotesAPI | ||
cd QuotesAPI | ||
``` | ||
### Example in Java | ||
Here's an example of how to use the Quotes API to fetch a random quote in Java: | ||
|
||
```java | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.Request; | ||
import okhttp3.Response; | ||
import okhttp3.ResponseBody; | ||
import org.json.JSONObject; | ||
|
||
public class QuotesApiClient { | ||
public static void main(String[] args) { | ||
OkHttpClient client = new OkHttpClient(); | ||
String apiUrl = "https://quotesapi.santosh0.com.np/api/quotes/"; | ||
|
||
Request request = new Request.Builder() | ||
.url(apiUrl) | ||
.get() | ||
.build(); | ||
|
||
try { | ||
Response response = client.newCall(request).execute(); | ||
if (response.isSuccessful()) { | ||
ResponseBody responseBody = response.body(); | ||
if (responseBody != null) { | ||
String jsonData = responseBody.string(); | ||
JSONObject json = new JSONObject(jsonData); | ||
String quote = json.getString("auotesd"); | ||
String author = json.getString("author"); | ||
System.out.println("Random Quote: " + quote + " - " + author); | ||
} | ||
} else { | ||
System.out.println("Error: " + response.code() + " - " + response.message()); | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
- Create the Virtual Environment Before installing the requirements. | ||
```Bash | ||
python3 -m virtualenv venv #For Linux User | ||
``` | ||
- Activate the Virtual Environment | ||
```bash | ||
source venv/bin/activate #For Linux and MAC User | ||
Note: It is not Necessary to Create Virtual Environment but recommanded. | ||
``` | ||
- Install the Requirements | ||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
### Example Response | ||
|
||
```json | ||
{ | ||
"quotes": "If you want to live a happy life, tie it to a goal, not to people or things.", | ||
"author": "Albert Einstein" | ||
} | ||
- Create the Migrations and Migrate the Model | ||
```bash | ||
python3 manage.py makemigrations | ||
python3 manage.py migrate | ||
``` | ||
|
||
- Run the Server | ||
```bash | ||
python3 manage.py runserver | ||
``` | ||
|
||
## Conclusion | ||
The Quotes API provides a simple and fun way to generate Quotes. Feel free to use it in your projects or contribute to its development. We appreciate your support and welcome any feedback or suggestions. Enjoy the laughter! | ||
- Open the url in Browser | ||
```bash | ||
http://127.0.0.1:8000/ | ||
``` | ||
|
||
## Contributing | ||
|
||
We welcome contributions! If you'd like to contribute to this project, please check out our [Contribution Guidelines](Contribution.md). | ||
We welcome contributions! If you'd like to contribute to this Blog app, please check out our [Contribution Guidelines](Contribution.md). | ||
|
||
## Code of Conduct | ||
|
||
Please review our [Code of Conduct](CodeOfConduct.md) before participating in this project. | ||
Please review our [Code of Conduct](CodeOfConduct.md) before participating in this app. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT [License](LICENSE). | ||
This project is licensed under the [License](LICENSE). |