Skip to content

Commit 089e08e

Browse files
committed
Changed password search to generate and fully documented
1 parent 5cb51a6 commit 089e08e

File tree

2 files changed

+138
-1
lines changed

2 files changed

+138
-1
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import { Tab, Tabs } from "nextra-theme-docs";
2+
3+
# Search
4+
5+
This endpoint allows you to generate random passwords. To access the `/password` endpoint, you
6+
will need to provide the proper authentication using the Authorization header.
7+
8+
9+
## Endpoint Details
10+
The `/password` endpoint allows you to retrieve information about a specific password.
11+
12+
- **URL**: `/password`
13+
- **Method**: GET
14+
- **Content Type**: application/json
15+
16+
## Authentication
17+
18+
To make requests to the `/password` endpoint, you must include an `Authorization` header in your API calls. This header should contain a valid access token.
19+
20+
### Example Authorization Header
21+
22+
```jsx
23+
Authorization: YOUR_ACCESS_TOKEN
24+
```
25+
26+
Replace `YOUR_ACCESS_TOKEN` with the actual token provided to you.
27+
28+
## Request
29+
### Headers
30+
31+
The request to the `/password` endpoint should be a JSON object with the following headers:
32+
33+
| Header | Type | Description | Required |
34+
| --------------- | ------- | ---------------------------------------------------- | -------- |
35+
| `Authorization` | string | The unique identifier of the user sending the request. | True |
36+
37+
### Parameters
38+
39+
The request parameters for the `/password` endpoint.
40+
41+
| Parameter | Type | Description | Required |
42+
| ------------- | ------ | ------------------------------------------------------------------------------------------------------------- | -------- |
43+
| `charLength` | number | (Optional) The desired length of the generated password. If not provided, a default length is used. | False |
44+
45+
## Example Request
46+
Here's an example of how to make a request to the `/password` endpoint.
47+
48+
<Tabs items={["JavaScript", "Python"]}>
49+
<Tab>
50+
```js
51+
import axios from "axios";
52+
53+
/*
54+
Replace "YOUR_ACCESS_TOKEN" with the token you got from the Kohai Bot and the endpoint.
55+
*/
56+
const url = "https://waifu.it/api/password";
57+
const charLength = 12; // Replace with your desired password length (optional).
58+
const data = async () => {
59+
try {
60+
const { data } = await axios.get(url, {
61+
headers: {
62+
Authorization: "YOUR_ACCESS_TOKEN",
63+
},
64+
params: {
65+
charLength: charLength || undefined,
66+
}
67+
});
68+
return data;
69+
} catch (err) {
70+
throw new Error(err.message);
71+
}
72+
};
73+
74+
console.log(data);
75+
```
76+
</Tab>
77+
<Tab>
78+
```python
79+
import requests
80+
81+
"""
82+
Replace "YOUR_ACCESS_TOKEN" with the token you got from the Kohai Bot and the endpoint.
83+
"""
84+
url = "https://waifu.it/api/password"
85+
86+
charLength = 12 # Replace with your desired password length (optional).
87+
88+
params = {
89+
"charLength": charLength if charLength is not None else None,
90+
}
91+
92+
response = requests.get(url, headers={
93+
"Authorization": "YOUR_ACCESS_TOKEN",
94+
}, params=params)
95+
96+
data = response.json()
97+
98+
print(data)
99+
```
100+
</Tab>
101+
</Tabs>
102+
103+
Remember to replace `YOUR_ACCESS_TOKEN` with your actual access token.
104+
105+
## Responses
106+
107+
The server will respond with an appropriate message based on the input provided. A successfully API request will respond
108+
with a JSON object containing the following information:
109+
110+
- `password`: The unique password that is generated for you.
111+
- `status`: Response status
112+
113+
<Tabs items={["200 OK", "404 Not Found", "500 Internal Server Error"]}>
114+
<Tab>
115+
**Content Type:** `application/json`
116+
```json copy=false
117+
"password": "&CbO891uM7G3"
118+
"status": 200,
119+
```
120+
</Tab>
121+
<Tab>
122+
**Content Type:** `application/json`
123+
```json copy=false
124+
"status": 404,
125+
"message": {}
126+
```
127+
</Tab>
128+
<Tab>
129+
**Content Type:** `application/json`
130+
```json copy=false
131+
"status": 500,
132+
"message": {}
133+
```
134+
</Tab>
135+
</Tabs>
136+
137+
This documentation should help you use [`axios`](https://www.npmjs.com/package/axios) for Node.js and [`requests`](https://pypi.org/project/requests/)
138+
for Python to interact with the `/password` endpoint.

pages/rest-api/Texts/Password/search.mdx

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)