Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit 26db7c8

Browse files
author
Kevin Richter
committed
Update introduction page
1 parent b205de6 commit 26db7c8

File tree

2 files changed

+75
-209
lines changed

2 files changed

+75
-209
lines changed

source/includes/_errors.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

source/index.html.md

Lines changed: 75 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -1,239 +1,127 @@
11
---
22
title: API Reference
33

4-
language_tabs: # must be one of https://git.io/vQNgJ
5-
- shell
6-
- ruby
7-
- python
4+
language_tabs:
5+
- php
86
- javascript
97

108
toc_footers:
11-
- <a href='#'>Sign Up for a Developer Key</a>
9+
- <a href='https://api.maps4news.com/register'>Sign Up for Maps4News</a>
1210
- <a href='https://github.com/lord/slate'>Documentation Powered by Slate</a>
1311

14-
includes:
15-
- errors
16-
1712
search: true
1813
---
1914

2015
# Introduction
2116

22-
Welcome to the Kittn API! You can use our API to access Kittn API endpoints, which can get information on various cats, kittens, and breeds in our database.
23-
24-
We have language bindings in Shell, Ruby, Python, and JavaScript! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
17+
Welcome to the API documentation for Maps4News.
2518

26-
This example API documentation page was created with [Slate](https://github.com/lord/slate). Feel free to edit it and use it as a base for your own API's documentation.
27-
28-
# Authentication
19+
This API allows you to manage everything about your account and your organisation. As well as generate Maps.
2920

30-
> To authorize, use this code:
21+
# API Wrapper
3122

32-
```ruby
33-
require 'kittn'
23+
> You can install the library using:
3424
35-
api = Kittn::APIClient.authorize!('meowmeowmeow')
3625
```
37-
38-
```python
39-
import kittn
40-
41-
api = kittn.authorize('meowmeowmeow')
26+
npm install @mapcreator/maps4news
4227
```
4328

44-
```shell
45-
# With shell, you can just pass the correct header with each request
46-
curl "api_endpoint_here"
47-
-H "Authorization: meowmeowmeow"
48-
```
49-
50-
```javascript
51-
const kittn = require('kittn');
52-
53-
let api = kittn.authorize('meowmeowmeow');
54-
```
55-
56-
> Make sure to replace `meowmeowmeow` with your API key.
57-
58-
Kittn uses API keys to allow access to the API. You can register a new Kittn API key at our [developer portal](http://example.com/developers).
59-
60-
Kittn expects for the API key to be included in all API requests to the server in a header that looks like the following:
29+
If you are using JavaScript to develop your app then you are in luck.
30+
We have created a query builder-like library that is able to do everything our API offers. It even does the Oauth login for you, in redirect, popup or password flow.
6131

62-
`Authorization: meowmeowmeow`
32+
The library is freely available on [github](https://github.com/MapCreatorEU/api-wrapper) and [npm](https://www.npmjs.com/package/@mapcreator/maps4news).
6333

64-
<aside class="notice">
65-
You must replace <code>meowmeowmeow</code> with your personal API key.
66-
</aside>
67-
68-
# Kittens
69-
70-
## Get All Kittens
71-
72-
```ruby
73-
require 'kittn'
74-
75-
api = Kittn::APIClient.authorize!('meowmeowmeow')
76-
api.kittens.get
77-
```
78-
79-
```python
80-
import kittn
81-
82-
api = kittn.authorize('meowmeowmeow')
83-
api.kittens.get()
84-
```
85-
86-
```shell
87-
curl "http://example.com/api/kittens"
88-
-H "Authorization: meowmeowmeow"
89-
```
90-
91-
```javascript
92-
const kittn = require('kittn');
34+
More information about the wrapper can be found on [this page](/api-wrapper.html)
9335

94-
let api = kittn.authorize('meowmeowmeow');
95-
let kittens = api.kittens.get();
96-
```
36+
# Authentication
9737

98-
> The above command returns JSON structured like this:
99-
100-
```json
101-
[
102-
{
103-
"id": 1,
104-
"name": "Fluffums",
105-
"breed": "calico",
106-
"fluffiness": 6,
107-
"cuteness": 7
108-
},
109-
{
110-
"id": 2,
111-
"name": "Max",
112-
"breed": "unknown",
113-
"fluffiness": 5,
114-
"cuteness": 10
115-
}
116-
]
117-
```
38+
> To authorize, use this code:
11839
119-
This endpoint retrieves all kittens.
40+
```php
41+
This example uses the guzzlehttp package from composer.
12042

121-
### HTTP Request
43+
<?php
12244

123-
`GET http://example.com/api/kittens`
45+
$host = "https://api.maps4news.com";
46+
$client_id = 0;
47+
$secret = "secret";
48+
$redirect_url = "http://localhost/callback";
12449

125-
### Query Parameters
50+
////////////////////////////
51+
// /login route in your app.
12652

127-
Parameter | Default | Description
128-
--------- | ------- | -----------
129-
include_cats | false | If set to true, the result will also include cats.
130-
available | true | If set to false, the result will include kittens that have already been adopted.
53+
// Prepare redirect to API login page.
54+
$query = http_build_query([
55+
'client_id' => $client_id,
56+
'redirect_uri' => 'http://localhost/callback',
57+
'response_type' => 'code'
58+
]);
13159

132-
<aside class="success">
133-
Remember — a happy kitten is an authenticated kitten!
134-
</aside>
60+
// Redirect user.
61+
header("Location: $host/oauth/authorize?$query");
13562

136-
## Get a Specific Kitten
63+
//////////////////////////////
64+
// /callback route in your app.
13765

138-
```ruby
139-
require 'kittn'
66+
$http = new GuzzleHttp\Client();
14067

141-
api = Kittn::APIClient.authorize!('meowmeowmeow')
142-
api.kittens.get(2)
143-
```
68+
// Get the user's access_token.
69+
$response = $http->post("$host/oauth/token", [
70+
'form_params' => [
71+
'grant_type' => 'authorization_code',
72+
'client_id' => $client_id,
73+
'client_secret' => $secret,
74+
'redirect_uri' => $redirect_url,
75+
'code' => $_POST['code']
76+
]
77+
]);
14478

145-
```python
146-
import kittn
79+
// Get the access token.
80+
$token = json_decode((string) $response->getBody(), true)['access_token'];
14781

148-
api = kittn.authorize('meowmeowmeow')
149-
api.kittens.get(2)
150-
```
82+
// Request the user's info.
83+
$response = $http->get("$host/v1/users/me", [
84+
'headers' => [
85+
'Authorization' => "Bearer $token",
86+
'Accept' => 'application/json'
87+
]
88+
]);
15189

152-
```shell
153-
curl "http://example.com/api/kittens/2"
154-
-H "Authorization: meowmeowmeow"
90+
// Display the user's information
91+
print_r(json_decode((string) $response->getBody()));
15592
```
15693

15794
```javascript
158-
const kittn = require('kittn');
159-
160-
let api = kittn.authorize('meowmeowmeow');
161-
let max = api.kittens.get(2);
162-
```
163-
164-
> The above command returns JSON structured like this:
165-
166-
```json
167-
{
168-
"id": 2,
169-
"name": "Max",
170-
"breed": "unknown",
171-
"fluffiness": 5,
172-
"cuteness": 10
173-
}
174-
```
175-
176-
This endpoint retrieves a specific kitten.
177-
178-
<aside class="warning">Inside HTML code blocks like this one, you can't use Markdown, so use <code>&lt;code&gt;</code> blocks to denote code.</aside>
179-
180-
### HTTP Request
95+
import { ImplicitFlow, Maps4News } from '@mapcreator/maps4news';
18196

182-
`GET http://example.com/kittens/<ID>`
97+
const API_CLIENT_ID = 0;
98+
const API_HOST = 'https://api.maps4news.com';
99+
const REDIRECT_URL = 'http://localhost/';
183100

184-
### URL Parameters
101+
const auth = new ImplicitFlow(API_CLIENT_ID, REDIRECT_URL);
102+
const api = new Maps4News(auth, API_HOST);
185103

186-
Parameter | Description
187-
--------- | -----------
188-
ID | The ID of the kitten to retrieve
104+
// Somewhere in your application
105+
api.authenticate();
189106

190-
## Delete a Specific Kitten
191-
192-
```ruby
193-
require 'kittn'
194-
195-
api = Kittn::APIClient.authorize!('meowmeowmeow')
196-
api.kittens.delete(2)
197-
```
198-
199-
```python
200-
import kittn
201-
202-
api = kittn.authorize('meowmeowmeow')
203-
api.kittens.delete(2)
204-
```
205-
206-
```shell
207-
curl "http://example.com/api/kittens/2"
208-
-X DELETE
209-
-H "Authorization: meowmeowmeow"
107+
// Get the user's information
108+
api.users.get('me').then(console.log);
210109
```
211110

212-
```javascript
213-
const kittn = require('kittn');
214-
215-
let api = kittn.authorize('meowmeowmeow');
216-
let max = api.kittens.delete(2);
217-
```
111+
> Make sure the <code>client_id</code>, <code>host</code> and <code>redirect_url</code> are correctly filled in.
218112
219-
> The above command returns JSON structured like this:
113+
The Maps4News API is an OAuth2 API. We support implicit and password flows.
220114

221-
```json
222-
{
223-
"id": 2,
224-
"deleted" : ":("
225-
}
226-
```
227-
228-
This endpoint deletes a specific kitten.
115+
<aside class="notice">
116+
You must have a valid client registered with us to be able to use the API. Clients are currently on request.
117+
</aside>
229118

230-
### HTTP Request
119+
# Next
231120

232-
`DELETE http://example.com/kittens/<ID>`
121+
The next step in learning about our API would be to look into our extensive documentation about all the available endpoints.
233122

234-
### URL Parameters
123+
[API Swagger docs](api.html)
235124

236-
Parameter | Description
237-
--------- | -----------
238-
ID | The ID of the kitten to delete
125+
Our you can look into how the wrapper works.
239126

127+
[API Wrapper docs](api-wrapper.html)

0 commit comments

Comments
 (0)