Skip to content

Commit 4d99160

Browse files
committed
Started on API documentation
1 parent 673e02c commit 4d99160

9 files changed

Lines changed: 293 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: "1.x.x"
3+
---
4+
5+
import HttpMethod from "@site/src/components/httpMethod";
6+
import HttpCode from "@site/src/components/httpCode";
7+
8+
# WeatherStack Core External API 1.x.x
9+
10+
<HttpMethod method="GET" /> <a id="root" href="#root">`/`</a>
11+
12+
<br /><br />
13+
14+
**Description:**
15+
This API route is simply to return a small JSON object, telling you some basic information as to
16+
what is running on that port.
17+
18+
<details>
19+
<summary>
20+
<HttpCode code="200" />
21+
</summary>
22+
23+
```json
24+
{
25+
"success": true,
26+
"code": 200,
27+
28+
"message": "Number 5 is alive!",
29+
30+
"version": "1.0.0", // Current version
31+
"name": "WeatherStack Core External API", // Name (Makes it easier to look it up)
32+
"repository": "https://github.com/WeatherStack/Core" // Repository link
33+
}
34+
```
35+
</details>
36+
37+
---
38+
39+
<HttpMethod method="GET" /> <a id="health-liveliness" href="#health-liveliness">`/v1/health/liveliness`</a>
40+
41+
<br /><br />
42+
43+
**Description:**
44+
Only returns status 200 if everything is good, and working correctly and as expected.
45+
46+
<details>
47+
<summary>
48+
<HttpCode code="200" />
49+
</summary>
50+
51+
No content.
52+
</details>
53+
54+
---
55+
56+
<HttpMethod method="GET" /> <a id="health-info" href="#health-info">`/v1/health/info`</a>
57+
58+
<br /><br />
59+
60+
**Description:**
61+
This API route gives more in-depth information, such as uptime.
62+
63+
<details>
64+
<summary>
65+
<HttpCode code="200" />
66+
</summary>
67+
68+
```json
69+
{
70+
"success": true,
71+
"code": 200,
72+
73+
"message": "Dude, you can't run from the future!",
74+
75+
"stats": {
76+
"uptime": 3538688.83811651,
77+
"uptime_human": "1 months 10 days 12 hours 24 minutes 32 seconds 838 milliseconds"
78+
}
79+
}
80+
```
81+
</details>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: "WeatherStack Core External API"
3+
---
4+
5+
| Major version | Link |
6+
| :------------ | :---------------------------------------------------- |
7+
| 1.x.x | [1.x.x documentation](/docs/apis/core_external_api/1) |
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: "1.x.x"
3+
---
4+
5+
import HttpMethod from "@site/src/components/httpMethod";
6+
import HttpCode from "@site/src/components/httpCode";
7+
8+
# WeatherStack Core Internal API 1.x.x
9+
:::note
10+
The majority of the API routes found on this page are designed to be used within C or C++ programs,
11+
so they may not return data that can be easily interpreted by languages such as JavaScript.
12+
13+
The API routes on this page **do not follow the default API guidelines** as they are internal API
14+
routes. This means that by default, these API routes are **insecure, and should not be publicly
15+
exposed**.
16+
17+
For more information on how to secure this internal endpoint for public exposure, please [follow
18+
this guide](/docs/apis/core_internal_api/securing/).
19+
:::
20+
21+
:::danger
22+
Exposing this endpoint without securing it is dangerous, and leaves a security vulnerability.
23+
:::
24+
25+
---
26+
27+
<HttpMethod method="GET" /> <a id="root" href="#root">`/`</a>
28+
29+
<br /><br />
30+
31+
**Description:**
32+
This API route is simply to return a small JSON object, telling you some basic information as to
33+
what is running on that port.
34+
35+
<details>
36+
<summary>
37+
<HttpCode code="200" />
38+
</summary>
39+
40+
```json
41+
{
42+
"success": true,
43+
"code": 200,
44+
45+
"message": "Number 5 is alive!",
46+
47+
"version": "1.0.0", // Current version
48+
"name": "WeatherStack Core Internal API", // Name (Makes it easier to look it up)
49+
"repository": "https://github.com/WeatherStack/Core" // Repository link
50+
}
51+
```
52+
</details>
53+
54+
---
55+
56+
<HttpMethod method="GET" /> <a id="health-liveliness" href="#health-liveliness">`/v1/health/liveliness`</a>
57+
58+
<br /><br />
59+
60+
**Description:**
61+
Only returns status 200 if everything is good, and working correctly and as expected.
62+
63+
<details>
64+
<summary>
65+
<HttpCode code="200" />
66+
</summary>
67+
68+
No content.
69+
</details>
70+
71+
---
72+
73+
<HttpMethod method="GET" /> <a id="health-info" href="#health-info">`/v1/health/info`</a>
74+
75+
<br /><br />
76+
77+
**Description:**
78+
This API route gives more in-depth information, such as uptime.
79+
80+
<details>
81+
<summary>
82+
<HttpCode code="200" />
83+
</summary>
84+
85+
```json
86+
{
87+
"success": true,
88+
"code": 200,
89+
90+
"message": "Dude, you can't run from the future!",
91+
92+
"stats": {
93+
"uptime": 3538688.83811651,
94+
"uptime_human": "1 months 10 days 12 hours 24 minutes 32 seconds 838 milliseconds"
95+
}
96+
}
97+
```
98+
</details>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: "WeatherStack Core Internal API"
3+
---
4+
5+
| Major version | Link |
6+
| :------------ | :---------------------------------------------------- |
7+
| 1.x.x | [1.x.x documentation](/docs/apis/core_internal_api/1) |

docs/apis/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "APIs"
3+
sidebar_position: 7
4+
---
5+
6+
| API | Version | Documentation |
7+
| :--------------------------------- | :------ | :---------------------------------------------------- |
8+
| **WeatherStack Core Internal API** | | |
9+
| | `1.x.x` | [Open documentation](/docs/apis/core_internal_api/1/) |
10+
| **WeatherStack Core External API** | | |
11+
| | `1.x.x` | [Open documentation](/docs/apis/core_external_api/1/) |

src/components/httpCode.module.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.httpCode {
2+
display: inline-block;
3+
padding: 0.2em 0.5em;
4+
border-radius: 4px;
5+
font-weight: bold;
6+
font-size: 0.9em;
7+
color: white;
8+
text-transform: uppercase;
9+
}
10+
11+
.http_200 {
12+
background-color: #49cc90;
13+
}

src/components/httpCode.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import clsx from 'clsx';
3+
import styles from './HttpCode.module.css';
4+
5+
const codeColors = {
6+
200: "http_200"
7+
};
8+
function HttpCode({ code }) {
9+
const colorClass = codeColors[code] || 'default';
10+
console.log(styles[colorClass]);
11+
return (
12+
<span className={clsx(styles.httpCode, styles[colorClass])}>
13+
{code}
14+
</span>
15+
);
16+
}
17+
export default HttpCode;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* Credits: https://blog.logrocket.com/api-documentation-guide/ */
2+
3+
.httpMethod {
4+
display: inline-block;
5+
padding: 0.2em 0.5em;
6+
margin-right: 0.5em;
7+
border-radius: 4px;
8+
font-weight: bold;
9+
font-size: 0.9em;
10+
color: white;
11+
text-transform: uppercase;
12+
}
13+
14+
.get {
15+
background-color: #61affe;
16+
}
17+
18+
.post {
19+
background-color: #49cc90;
20+
}
21+
22+
.put {
23+
background-color: #fca130;
24+
}
25+
26+
.patch {
27+
background-color: #50e3c2;
28+
}
29+
30+
.delete {
31+
background-color: #f93e3e;
32+
}
33+
34+
.default {
35+
background-color: #666;
36+
}

src/components/httpMethod.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Credits: https://blog.logrocket.com/api-documentation-guide/ */
2+
3+
import React from 'react';
4+
import clsx from 'clsx';
5+
import styles from './HttpMethod.module.css';
6+
7+
const methodColors = {
8+
GET: 'get',
9+
POST: 'post',
10+
PUT: 'put',
11+
PATCH: 'patch',
12+
DELETE: 'delete',
13+
};
14+
function HttpMethod({ method }) {
15+
const upperMethod = method.toUpperCase();
16+
const colorClass = methodColors[upperMethod] || 'default';
17+
return (
18+
<span className={clsx(styles.httpMethod, styles[colorClass])}>
19+
{upperMethod}
20+
</span>
21+
);
22+
}
23+
export default HttpMethod;

0 commit comments

Comments
 (0)