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

Staging #50

Merged
merged 4 commits into from
Feb 6, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docs.waifu.it",
"version": "3.0.6",
"version": "3.1.6",
"description": "The new and improved documentation for Waifu.it",
"scripts": {
"dev": "next dev",
Expand Down
1 change: 1 addition & 0 deletions pages/list-of-endpoints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Waifu.it supports a wealth of endpoints, which can be categorized into the follo
### Images

- [Waifu:](https://docs.waifu.it/rest-api/Images/Waifu/search) Immerse yourself in the captivating world of anime with the Waifu endpoint.
- [Husbando:](https://docs.waifu.it/rest-api/Images/Husbando/search) Get yourself a good and cool looking husbando.

### Texts

Expand Down
3 changes: 3 additions & 0 deletions pages/rest-api/Images/Husbando/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"search": "Search"
}
233 changes: 233 additions & 0 deletions pages/rest-api/Images/Husbando/search.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
import { Tab, Tabs } from "nextra-theme-docs";

# Search

This endpoint allows you to access and retrieve information about your favorite husbandos. To access the `/husbando` endpoint, you
will need to provide the proper authentication using the Authorization header.

## Endpoint Details

The `/husbando` endpoint allows you to retrieve information about a specific husbando.

- **URL**: `/husbando`
- **Method**: GET
- **Content Type**: application/json

## Authentication

To make requests to the `/husbando` endpoint, you must include an `Authorization` header in your API calls. This header should contain a valid access token.

### Example Authorization Header

```jsx
Authorization: YOUR_ACCESS_TOKEN;
```

Replace `YOUR_ACCESS_TOKEN` with the actual token provided to you.

## Request Headers

The request to the `/husbando` endpoint should be a JSON object with the following headers:

| Header | Type | Description | Required |
| --------------- | ------ | ------------------------------------------------------ | -------- |
| `Authorization` | string | The unique identifier of the user sending the request. | True |

### Parameters

The request parameters for the `/husbando?{parameter}={value}` endpoint.

| Parameter | Type | Description | Required |
| --------- | ------ | ---------------------------------------------------------------------------------------------------------- | -------- |
| `name` | string | (Optional) The desired character name for the query. If not provided, a random husbando will be generated. | False |
| `anime` | string | (Optional) The desired anime name for the query. If not provided, a random husbando will be selected. | False |

### Example Request

Here's example of how to make a request to the `/husbando` endpoint.

<Tabs items={["JavaScript", "Python"]}>
<Tab>
```js
import axios from "axios";

/*
Replace "YOUR_ACCESS_TOKEN" with the token you got from the Kohai Bot and the endpoint.
*/
const url = "https://husbando.it/api/v4/husbando";
const data = async () => {
try {
const { data } = await axios.get(url, { headers: {
Authorization: "YOUR_ACCESS_TOKEN",
} });
return data;
} catch (err) {
throw new Error(err.message);
}
};

console.log(data);
```

</Tab>
<Tab>
```python
import requests

"""
Replace "YOUR_ACCESS_TOKEN" with the token you got from the Kohai Bot and the endpoint.
"""
url = "https://husbando.it/api/v4/husbando"
response = requests.get(url, headers={
"Authorization": "YOUR_ACCESS_TOKEN",
})
data = response.json()

print(data)
```

</Tab>
</Tabs>

Remember to replace `YOUR_ACCESS_TOKEN` with your actual access token.

## Responses

The server will respond with an appropriate message based on the input provided. A successfully API request will respond
with a JSON object containing the following information:

- `_id`: The unique identifier of the husbando.
- `name`: Information about the husbando's name.
- `first`: The first name of the husbando.
- `middle`: The middle name of the husbando (if available).
- `last`: The last name of the husbando (if available).
- `full`: The full name of the husbando.
- `native`: The native name of the husbando.
- `userPreferred`: The user's preferred name for the husbando.
- `alternative`: An array of alternative names for the husbando.
- `alternativeSpoiler`: An array of alternative names with potential spoilers.
- `image`: Information about the husbando's image.
- `large`: URL to a large image of the husbando.
- `favourites`: The number of users who have favorited the husbando.
- `siteUrl`: URL to the husbando's page on AniList.
- `description`: Description of the husbando (if available).
- `age`: Age of the husbando (if available).
- `gender`: Gender of the husbando.
- `bloodType`: Blood type of the husbando (if available).
- `dateOfBirth`: Date of birth of the husbando (if available).
- `year`: Year of birth.
- `month`: Month of birth.
- `day`: Day of birth.
- `media`: Information about the media associated with the husbando.
- `nodes`: An array of media nodes.
- `id`: The unique identifier of the media.
- `idMal`: The MyAnimeList identifier of the media.
- `coverImage`: Information about the cover image of the media.
- `medium`: URL to a medium-sized cover image of the media.
- `bannerImage`: URL to a banner image of the media (if available).
- `title`: Information about the title of the media.
- `romaji`: Romaji representation of the title.
- `english`: English representation of the title (if available).
- `native`: Native representation of the title.
- `userPreferred`: User-preferred representation of the title.
- `synonyms`: An array of synonyms for the media title.
- `popularity`: Popularity score of the media.
- `type`: Type of the media (e.g., ANIME, MANGA).
- `format`: Format of the media (e.g., TV, MANGA).

<Tabs items={["200 OK", "404 Not Found", "500 Internal Server Error"]}>
<Tab>
**Content Type:** `application/json`
```json copy=false
"status": 200,
"_id": 14881,
"name": {
"first": "Ura no Ojiichan",
"middle": null,
"last": null,
"full": "Ura no Ojiichan",
"native": "裏のおじいちゃん",
"userPreferred": "Ura no Ojiichan",
"alternative": [],
"alternativeSpoiler": []
},
"image": {
"large": "https://s4.anilist.co/file/anilistcdn/character/large/default.jpg"
},
"favourites": 0,
"siteUrl": "https://anilist.co/character/257439",
"description": null,
"age": null,
"gender": "Male",
"bloodType": null,
"dateOfBirth": {
"year": null,
"month": null,
"day": null
},
"media": {
"nodes": [
{
"id": 2406,
"idMal": 2406,
"coverImage": {
"medium": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/small/bx2406-nP8NIct9Sci3.jpg"
},
"bannerImage": "https://s4.anilist.co/file/anilistcdn/media/anime/banner/2406-ROqXxejQ5bH9.jpg",
"title": {
"romaji": "Sazae-san",
"english": null,
"native": "サザエさん",
"userPreferred": "Sazae-san"
},
"synonyms": [
"Mrs. Sazae"
],
"popularity": 1311,
"type": "ANIME",
"format": "TV"
},
{
"id": 43192,
"idMal": 13192,
"coverImage": {
"medium": "https://s4.anilist.co/file/anilistcdn/media/manga/cover/small/b43192-lBoylrcHjwWA.jpg"
},
"bannerImage": null,
"title": {
"romaji": "Sazae-San",
"english": "The Wonderful World of Sazae-San",
"native": "サザエさん",
"userPreferred": "Sazae-San"
},
"synonyms": [
"Heisei no Sazae-san",
"The Wonderful World of Sazae-san"
],
"popularity": 195,
"type": "MANGA",
"format": "MANGA"
}
]
}
```
</Tab>
<Tab>
**Content Type:** `application/json`
```json copy=false
"status": 404,
"message": {}
```
</Tab>
<Tab>
**Content Type:** `application/json`
```json copy=false
"status": 500,
"message": {}
```
</Tab>
</Tabs>

This documentation should help you use [`axios`](https://www.npmjs.com/package/axios) for Node.js and [`requests`](https://pypi.org/project/requests/)
for Python to interact with the `/husbando` endpoint.
That's it! You are now ready to use the `/husbando` endpoint to retrieve information about your favorite husbandos. Happy coding!
Loading
Loading