New Affirmations API
We are excited to announce the launch of our brand-new Affirmations API, designed to provide easy access to a vast collection of motivational quotes and phrases. This API offers developers and users alike a powerful tool for integrating positive affirmations into various applications and services.
The Affirmations API provides three main endpoints:
/v1/affirmations/categories
/v1/affirmations/categories/{category}/random
/v1/affirmations/random
These endpoints allow users to retrieve affirmations categorized by theme, find a random affirmation within a specific category, or receive a completely random affirmation from our extensive database.
Getting Started
To start using the Affirmations API, you can subscribe at the following URL:
Once subscribed, you’ll receive your API key, which you’ll need to authenticate your requests.
API Endpoints
1. Get All Categories
Endpoint: GET /v1/affirmations/categories
This endpoint returns a list of all available categories for affirmations.
Example Response:
{
"items": [
"love",
"health",
"beauty",
"gratitude",
"spiritual",
"happiness",
"money",
"blessing",
"sleep"
]
}
2. Get an Affirmation by Category
Endpoint: GET /v1/affirmations/categories/{category}/random
Parameters:
category
(path parameter): The category of the affirmation you want to retrieve
This endpoint returns a single affirmation that matches the specified category.
Example Response:
{
"text": "I make decisions that come from my heart",
"category": "love"
}
3. Get a Random Affirmation
Endpoint: GET /v1/affirmations/random
This endpoint returns a random affirmation from our extensive collection.
Response Schema:
{
"text": {
"type": "string"
},
"category": {
"type": "string"
}
}
Example Response:
{
"text": "I am free spirited and positive.",
"category": "beauty"
}
Error Handling
The API uses standard HTTP status codes to indicate the success or failure of requests:
- 200 OK: Successful request
- 400 Bad Request: Invalid input
- 401 Unauthorized: Authentication failed
- 403 Forbidden: Access denied
- 404 Not Found: Resource not found
Best Practices
- Always include your API key in the header of your requests.
- Handle errors gracefully in your application logic.
- Cache responses when appropriate to reduce API calls and improve performance.
- Consider implementing rate limiting on the client side to avoid overwhelming the server.
Conclusion
The new Affirmations API provides a simple yet powerful way to integrate positive affirmations into your projects. Whether you’re building a personal development app, creating a mindfulness platform, or simply looking to add inspiring quotes to your website, this API has got you covered. Start exploring today and watch your users benefit from these uplifting messages!