Skip to content

Commit c1b1fb6

Browse files
committed
First iteration of new API documentation
1 parent f2d4998 commit c1b1fb6

File tree

3 files changed

+119
-16
lines changed

3 files changed

+119
-16
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## SimplyPrint API documentation
2-
**Link to the API documentation;** https://apidocs.simplyprint.io/
1+
# SimplyPrint API documentation
2+
3+
**Link to the API documentation;** <https://apidocs.simplyprint.io/>
34

45
This repository contains the entire SimplyPrint API documentation, all content is located in `/source/index.html.md` - edits or contributions are welcome.
56

source/includes/_errors.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Errors
22

3-
The SimplyPrint API uses the following error codes:
4-
3+
The SimplyPrint API uses the following HTTP error codes:
54

65
Error Code | Meaning
76
---------- | -------
@@ -15,3 +14,21 @@ Error Code | Meaning
1514
429 | Too Many Requests -- You're requesting too much - slow down
1615
500 | Internal Server Error -- We had a problem with our server. Try again later.
1716
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later.
17+
18+
## Error Response
19+
20+
> Error response example:
21+
22+
```json
23+
{
24+
"status": false,
25+
"message": "No API key provided, or not logged in"
26+
}
27+
```
28+
29+
When an error occurs, the API will return a JSON object with the following fields:
30+
31+
Field | Description | Type
32+
----- | ----------- | ----
33+
status | The status of the request | Boolean
34+
message | A message describing the error | String|null

source/index.html.md

+97-12
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ title: SimplyPrint API Reference
33

44
language_tabs: # must be one of https://git.io/vQNgJ
55
- shell: cURL
6-
- php: PHP
6+
- python: Python 3
77

88
toc_footers:
9-
- <a href='#'>Sign Up for a Developer Key <i>(coming soon)</i></a>
9+
- <a href='https://simplyprint.io' target='_blank'>SimplyPrint</a>
1010

1111
includes:
1212
- printers
@@ -21,22 +21,107 @@ meta:
2121
content: Documentation for the SimplyPrint API
2222
- name: keywords
2323
content: SimplyPrint API,SimplyPrint Documentation
24+
25+
# TODO; Add open graph tags
2426
---
2527

26-
# Introduction
28+
# Getting Started
29+
30+
<aside class="notice">
31+
<b>The SimplyPrint API is under construction!</b>
32+
33+
This means this site contains no real documentation yet, but it will soon.
34+
</aside>
35+
36+
Welcome to the **SimplyPrint API**!
37+
38+
This documentation goes through authenticating and how to use the API. To get started you'll need an API key.
39+
40+
## Getting an API key
41+
42+
To get an API key you'll need a SimplyPrint account that is either a member of an organization or has at least the [SimplyPrint Pro plan](https://simplyprint.io/#pricing).
43+
44+
To create your own API key you first need a SimplyPrint account, you can go to your [account settings](https://simplyprint.io/account/settings) and create a new API key.
45+
46+
TODO; Create API key page and explain how to create an API key.
47+
48+
## The base URL
49+
50+
The base URL for the SimplyPrint API is `https://api.simplyprint.io/{id}/`.
51+
52+
To use the base API at <https://api.simplyprint.io>, you will need to specify an id.
53+
54+
The id represents the unique identifier for the company that you are using the API key for. This id is used to access the specific functionality within the API that is associated with the company.
55+
56+
The endpoint represents the specific functionality that you want to access within the API. There are various endpoints available, each with its own specific purpose and functionality.
57+
58+
For example, if you want to access the `account/Test` endpoint for a company with an id of 123, you would use the following API endpoint:
59+
60+
<https://api.simplyprint.io/123/account/Test>
61+
62+
If you are part of an organization, you might need to ask your organization administrator to allow API access for your account for the organization.
2763

28-
**The SimplyPrint API is under construction!**
29-
This means this site contains no real documentation yet, but it will soon.
64+
<aside class="notice">
65+
<b>For the rest of this documentation, we will use the following variables:</b>
3066

67+
<ol>
68+
<li>Replace <code>{base_url}</code> with your base api url</li>
69+
<li>Replace <code>{API_KEY}</code> with your API key</li>
70+
</ol>
71+
</aside>
3172

32-
# Authentication
73+
## Test your API key
3374

34-
> To authorize, use this code:
75+
```shell
76+
curl {base_url}/account/Test \
77+
--header 'X-API-KEY: {API_KEY}'
78+
```
79+
80+
```python
81+
import requests
82+
83+
url = "{base_url}/account/Test"
3584

36-
```php
37-
<?php
38-
//Coming soon...
39-
?>
85+
r = requests.get(url, headers={'X-API-KEY': '{API_KEY}'})
86+
87+
print(r.json())
4088
```
4189

42-
Coming soon...
90+
> Success return:
91+
92+
```json
93+
{
94+
"status": true,
95+
"message": "Your API key is valid!"
96+
}
97+
```
98+
99+
> Error return in case of an invalid or missing API key:
100+
101+
```json
102+
{
103+
"status": false,
104+
"message": "No API key provided, or not logged in"
105+
}
106+
```
107+
108+
> Error return in case of missing permissions for the organization:
109+
110+
```json
111+
{
112+
"status": false,
113+
"message": "You don't have access to this account"
114+
}
115+
```
116+
117+
To verify that your API key is valid and that you have access to the desired organization, you can make a request to the `/account/Test` endpoint.
118+
119+
To make any request to the SimplyPrint API, you will need to include your API key in the request header. You can do this by including the `X-API-KEY` header in your request. On the right side of this page, you can see an example of how to make a request to the `/account/Test` endpoint using cURL and Python.
120+
121+
If you are unable to successfully make a request to the `/account/Test` endpoint using the provided example, there may be a few possible issues:
122+
123+
- Your API key may be invalid or missing. Make sure that you have a valid API key and that you are including it in the request header as shown in the example.
124+
- You may not have access to the organization specified in the `id` parameter. Make sure that you are using the correct `id` for the organization that you have access to.
125+
- There may be a problem with the base API URL or endpoint. Double check that you are using the correct base API URL and endpoint in your request.
126+
127+
If you are unable to resolve the issue after troubleshooting these potential issues, you may need to contact your organization administrator for further assistance. Otherwise, feel free to contact us via our [helpdesk](https://help.simplyprint.io/).

0 commit comments

Comments
 (0)