Quotes API Documentation
Introduction
Welcome to the FindIpInfo Quotes API! This free API lets you add inspirational and motivational quotes to your applications. Whether you're building a website, mobile app, or tool, you can fetch quotes by category (e.g., Love, Motivation), get a random quote, or explore available categories. This guide provides clear PHP and Java examples, perfect for beginners and experienced developers alike.
Step 1: Get Your API Key
To use the Quotes API, you need a unique API key for authentication. Follow these steps:
- Visit findipinfo.net.
- Sign Up or Log In.
- Go to API Settings in your dashboard.
- Generate and copy your API key.
Step 2: Explore API Endpoints
The Quotes API offers three endpoints to fetch quotes, random quotes, or categories. Replace
API_KEY with your key and CATEGORY with a category like Love or Motivation.
All responses include status, message, and findipinfo fields.
2.1 Fetch Quotes (Paginated)
Retrieve a list of quotes, optionally filtered by category, with pagination for easy navigation.
Endpoint:
https://findipinfo.net/api/quotes/{API_KEY}/{CATEGORY}?page={PAGE}&per_page={PER_PAGE}
Parameters:
- API_KEY (required): Your API key.
- CATEGORY (optional): Filter by category (e.g., Love, Motivation).
- page (optional): Page number (default: 1).
- per_page (optional): Quotes per page (default: 20, max: 100).
<?php
$apiKey = 'your-api-key-here';
$category = 'Love';
$page = 1;
$perPage = 20;
$url = "https://findipinfo.net/api/quotes/$apiKey/$category?page=$page&per_page=$perPage";
try {
$response = file_get_contents($url);
$data = json_decode($response, true);
if ($data['status'] === 'success') {
echo "Title: {$data['findipinfo']['title']}\n";
foreach ($data['findipinfo']['quotes'] as $quote) {
echo "Quote: {$quote['quote']} - {$quote['author']} ({$quote['category']})\n";
}
echo "Next Page: " . ($data['findipinfo']['pagination']['next_page_url'] ?? 'None') . "\n";
} else {
echo "Error: {$data['message']}\n";
}
} catch (Exception $e) {
echo "Request failed: {$e->getMessage()}\n";
}
?>
Add Dependencies
dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.google.code.gson:gson:2.11.0'
}
Create Quotes API Manager
import com.google.gson.Gson;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
public class QuotesApiManager {
private static final String BASE_URL = "https://findipinfo.net/api/quotes/%s/%s?page=%d&per_page=%d";
private final OkHttpClient client;
private final Gson gson;
public QuotesApiManager() {
client = new OkHttpClient();
gson = new Gson();
}
public void fetchQuotes(String apiKey, String category, int page, int perPage, QuotesCallback callback) {
String url = String.format(BASE_URL, apiKey, category != null ? category : "", page, perPage);
Request request = new Request.Builder().url(url).build();
client.newCall(request).enqueue(new okhttp3.Callback() {
@Override
public void onFailure(okhttp3.Call call, IOException e) {
callback.onFailure(e.getMessage());
}
@Override
public void onResponse(okhttp3.Call call, Response response) throws IOException {
if (!response.isSuccessful()) {
callback.onFailure("Request failed: " + response.code());
return;
}
String json = response.body().string();
QuotesData data = gson.fromJson(json, QuotesData.class);
callback.onSuccess(data);
}
});
}
}
Define Callback Interface
public interface QuotesCallback {
void onSuccess(QuotesData data);
void onFailure(String error);
}
Create Data Model
public class QuotesData {
private String status;
private String message;
private FindIpInfo findipinfo;
public String getStatus() { return status; }
public void setStatus(String status) { this.status = status; }
public String getMessage() { return message; }
public void setMessage(String message) { this.message = message; }
public FindIpInfo getFindipinfo() { return findipinfo; }
public void setFindipinfo(FindIpInfo findipinfo) { this.findipinfo = findipinfo; }
public static class FindIpInfo {
private String title;
private Quote[] quotes;
private Pagination pagination;
private Category[] categories;
public String getTitle() { return title; }
public void setTitle(String title) { this.title = title; }
public Quote[] getQuotes() { return quotes; }
public void setQuotes(Quote[] quotes) { this.quotes = quotes; }
public Pagination getPagination() { return pagination; }
public void setPagination(Pagination pagination) { this.pagination = pagination; }
public Category[] getCategories() { return categories; }
public void setCategories(Category[] categories) { this.categories = categories; }
}
public static class Quote {
private String quote;
private String author;
private String category;
public String getQuote() { return quote; }
public void setQuote(String quote) { this.quote = quote; }
public String getAuthor() { return author; }
public void setAuthor(String author) { this.author = author; }
public String getCategory() { return category; }
public void setCategory(String category) { this.category = category; }
}
public static class Pagination {
private String next_page_url;
private String prev_page_url;
public String getNextPageUrl() { return next_page_url; }
public void setNextPageUrl(String next_page_url) { this.next_page_url = next_page_url; }
public String getPrevPageUrl() { return prev_page_url; }
public void setPrevPageUrl(String prev_page_url) { this.prev_page_url = prev_page_url; }
}
public static class Category {
private String name;
private String start_color;
private String end_color;
private String image;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getStartColor() { return start_color; }
public void setStartColor(String start_color) { this.start_color = start_color; }
public String getEndColor() { return end_color; }
public void setEndColor(String end_color) { this.end_color = end_color; }
public String getImage() { return image; }
public void setImage(String image) { this.image = image; }
}
}
2.2 Fetch a Random Quote
Get a single random quote, optionally filtered by category.
Endpoint:
https://findipinfo.net/api/random-quote/{API_KEY}/{CATEGORY}
Parameters:
- API_KEY (required): Your API key.
- CATEGORY (optional): Filter by category (e.g., Love, Motivation).
<?php
$apiKey = 'your-api-key-here';
$category = 'Motivation';
$url = "https://findipinfo.net/api/random-quote/$apiKey/$category";
try {
$response = file_get_contents($url);
$data = json_decode($response, true);
if ($data['status'] === 'success') {
echo "Title: {$data['findipinfo']['title']}\n";
echo "Quote: {$data['findipinfo']['quote']['quote']} - {$data['findipinfo']['quote']['author']} ({$data['findipinfo']['quote']['category']})\n";
} else {
echo "Error: {$data['message']}\n";
}
} catch (Exception $e) {
echo "Request failed: {$e->getMessage()}\n";
}
?>
public class QuotesApiManager {
private static final String RANDOM_URL = "https://findipinfo.net/api/random-quote/%s/%s";
private final OkHttpClient client;
private final Gson gson;
public QuotesApiManager() {
client = new OkHttpClient();
gson = new Gson();
}
public void fetchRandomQuote(String apiKey, String category, QuotesCallback callback) {
String url = String.format(RANDOM_URL, apiKey, category != null ? category : "");
Request request = new Request.Builder().url(url).build();
client.newCall(request).enqueue(new okhttp3.Callback() {
@Override
public void onFailure(okhttp3.Call call, IOException e) {
callback.onFailure(e.getMessage());
}
@Override
public void onResponse(okhttp3.Call call, Response response) throws IOException {
if (!response.isSuccessful()) {
callback.onFailure("Request failed: " + response.code());
return;
}
String json = response.body().string();
QuotesData data = gson.fromJson(json, QuotesData.class);
callback.onSuccess(data);
}
});
}
}
// Usage example
QuotesApiManager apiManager = new QuotesApiManager();
apiManager.fetchRandomQuote("your-api-key-here", "Motivation", new QuotesCallback() {
@Override
public void onSuccess(QuotesData data) {
runOnUiThread(() -> {
if ("success".equals(data.getStatus())) {
String title = data.getFindipinfo().getTitle();
QuotesData.Quote quote = data.getFindipinfo().getQuote();
dataTextView.setText(title + ": " + quote.getQuote() + " - " + quote.getAuthor());
} else {
dataTextView.setText(data.getStatus() + ": " + data.getMessage());
}
});
}
@Override
public void onFailure(String error) {
runOnUiThread(() -> dataTextView.setText("Error: " + error));
}
});
2.3 Fetch Quote Categories
Retrieve a list of available quote categories with metadata like name, colors, and images.
Endpoint:
https://findipinfo.net/api/quote-categories/{API_KEY}
Parameters:
- API_KEY (required): Your API key.
<?php
$apiKey = 'your-api-key-here';
$url = "https://findipinfo.net/api/quote-categories/$apiKey";
try {
$response = file_get_contents($url);
$data = json_decode($response, true);
if ($data['status'] === 'success') {
echo "Title: {$data['findipinfo']['title']}\n";
foreach ($data['findipinfo']['categories'] as $category) {
echo "Category: {$category['name']} (Image: {$category['image']})\n";
}
} else {
echo "Error: {$data['message']}\n";
}
} catch (Exception $e) {
echo "Request failed: {$e->getMessage()}\n";
}
?>
public class QuotesApiManager {
private static final String CATEGORIES_URL = "https://findipinfo.net/api/quote-categories/%s";
private final OkHttpClient client;
private final Gson gson;
public QuotesApiManager() {
client = new OkHttpClient();
gson = new Gson();
}
public void fetchCategories(String apiKey, QuotesCallback callback) {
String url = String.format(CATEGORIES_URL, apiKey);
Request request = new Request.Builder().url(url).build();
client.newCall(request).enqueue(new okhttp3.Callback() {
@Override
public void onFailure(okhttp3.Call call, IOException e) {
callback.onFailure(e.getMessage());
}
@Override
public void onResponse(okhttp3.Call call, Response response) throws IOException {
if (!response.isSuccessful()) {
callback.onFailure("Request failed: " + response.code());
return;
}
String json = response.body().string();
QuotesData data = gson.fromJson(json, QuotesData.class);
callback.onSuccess(data);
}
});
}
}
// Usage example
QuotesApiManager apiManager = new QuotesApiManager();
apiManager.fetchCategories("your-api-key-here", new QuotesCallback() {
@Override
public void onSuccess(QuotesData data) {
runOnUiThread(() -> {
if ("success".equals(data.getStatus())) {
String title = data.getFindipinfo().getTitle();
QuotesData.Category[] categories = data.getFindipinfo().getCategories();
StringBuilder output = new StringBuilder(title + "\n");
for (QuotesData.Category category : categories) {
output.append("Category: ").append(category.getName()).append(" (Image: ").append(category.getImage()).append(")\n");
}
dataTextView.setText(output.toString());
} else {
dataTextView.setText(data.getStatus() + ": " + data.getMessage());
}
});
}
@Override
public void onFailure(String error) {
runOnUiThread(() -> dataTextView.setText("Error: " + error));
}
});
Step 3: Handle API Errors
The API returns a status field to indicate the request outcome. Check this field to manage
errors effectively.
Possible Status Values:
- success: Request successful, data in
findipinfo. - api_error: Invalid or missing API key.
- pagination_error: Invalid page or per_page parameters.
- data_error: No quotes found for the category.
- server_error: Internal server issue.
<?php
$apiKey = 'your-api-key-here';
$category = 'Love';
$url = "https://findipinfo.net/api/quotes/$apiKey/$category";
try {
$response = file_get_contents($url);
if ($response === false) {
echo "Connection error. Please try again.\n";
} else {
$data = json_decode($response, true);
switch ($data['status']) {
case 'success':
echo "Title: {$data['findipinfo']['title']}\n";
foreach ($data['findipinfo']['quotes'] as $quote) {
echo "Quote: {$quote['quote']} - {$quote['author']}\n";
}
break;
case 'api_error':
echo "API error: {$data['message']}\n";
break;
case 'pagination_error':
echo "Pagination error: {$data['message']}\n";
break;
case 'data_error':
echo "Data error: {$data['message']}\n";
break;
case 'server_error':
echo "Server error: {$data['message']}\n";
break;
}
}
} catch (Exception $e) {
echo "Request failed: {$e->getMessage()}\n";
}
?>
QuotesApiManager apiManager = new QuotesApiManager();
apiManager.fetchQuotes("your-api-key-here", "Love", 1, 20, new QuotesCallback() {
@Override
public void onSuccess(QuotesData data) {
runOnUiThread(() -> {
if ("success".equals(data.getStatus())) {
String title = data.getFindipinfo().getTitle();
StringBuilder output = new StringBuilder(title + "\n");
for (QuotesData.Quote quote : data.getFindipinfo().getQuotes()) {
output.append("Quote: ").append(quote.getQuote()).append(" - ").append(quote.getAuthor()).append("\n");
}
dataTextView.setText(output.toString());
} else {
dataTextView.setText(data.getStatus() + ": " + data.getMessage());
}
});
}
@Override
public void onFailure(String error) {
runOnUiThread(() -> dataTextView.setText("Error: " + error));
}
});
Step 4: API Response Examples
Success: Fetch Quotes
{
"status": "success",
"message": "Quotes retrieved successfully",
"findipinfo": {
"title": "Quotes From Love",
"quotes": [
{
"quote": "Love is all you need.",
"author": "The Beatles",
"category": "Love"
},
{
"quote": "The best thing to hold onto in life is each other.",
"author": "Audrey Hepburn",
"category": "Love"
}
],
"pagination": {
"next_page_url": "https://findipinfo.net/api/quotes/{API_KEY}/Love?page=2",
"prev_page_url": null
}
}
}
Success: Random Quote
{
"status": "success",
"message": "Random quote retrieved successfully",
"findipinfo": {
"title": "Random Motivation Quote",
"quote": {
"quote": "The only way to do great work is to love what you do.",
"author": "Steve Jobs",
"category": "Motivation"
}
}
}
Success: Fetch Categories
{
"status": "success",
"message": "Quote categories retrieved successfully",
"findipinfo": {
"title": "Quotes Categories",
"categories": [
{
"name": "Love",
"start_color": "#FF0000",
"end_color": "#FF9999",
"image": "https://findipinfo.net/assets/quotes/love.jpg"
},
{
"name": "Motivation",
"start_color": "#00FF00",
"end_color": "#99FF99",
"image": "https://findipinfo.net/assets/quotes/motivation.jpg"
}
]
}
}
Error: Invalid API Key
{
"status": "api_error",
"message": "Invalid API key",
"code": 401
}
Step 5: Get Support
Need help with the Quotes API? Contact our support team via WhatsApp at Live Support Chat.