From a99628b2d5cb3723ea1017c28efbcd02790eaffa Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 13 Nov 2017 22:59:45 -0800 Subject: [PATCH 1/8] Public API docs --- package.json | 2 +- server/pages/Api.js | 200 ++++++++++++++++++++++++++++++++++++++++++++ server/routes.js | 2 + 3 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 server/pages/Api.js diff --git a/package.json b/package.json index 22f42910..1a062f37 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "NODE_ENV=production webpack --config webpack.config.prod.js --json | webpack-bundle-size-analyzer", "build": "npm run clean && npm run build:webpack", "start": "NODE_ENV=production node index.js", - "dev": "NODE_ENV=development nodemon --inspect --watch server index.js", + "dev": "NODE_ENV=development nodemon --watch server index.js", "lint": "npm run lint:flow && npm run lint:js", "lint:js": "eslint app", "lint:flow": "flow", diff --git a/server/pages/Api.js b/server/pages/Api.js new file mode 100644 index 00000000..f5b580e0 --- /dev/null +++ b/server/pages/Api.js @@ -0,0 +1,200 @@ +// @flow +import React from 'react'; +import Grid from 'styled-components-grid'; +import { Helmet } from 'react-helmet'; +import Flex from '../../shared/components/Flex'; + +export default function Pricing() { + return ( + + + Developer API + +
+

Outline API

+

+ First thing we build for Outline was its API. It's the heart and sole of the service and + as developers, it's our mission to make the API as rich and easy to use as possible. +

+

+ + While Outline is still in public beta, we might make small adjustments, including + breaking changes to the API. + +

+

Making requests

+

+ Outline's API follows simple RPC style conventions where each API endpoint is a method on{' '} + https://www.getoutline.com/api/<METHOD>. Both GET and{' '} + POST methods are supported but it's recommeded that you make all call using{' '} + POST. Only HTTPS is supported in production. +

+ +

+ For GET requests query string parameters are expected (e.g. + /api/document.info?id=...&token=...). When making POST requests, + request parameters are parsed depending on Content-Type header. To make a + call using JSON payload, one must pass Content-Type: application/json header: +

+ +

+ Example POST request: +

+
+          
+            {`
+curl https://www.getoutline.com/api/documents.info
+  -X POST
+  -H 'authorization: Bearer API_KEY'
+  -H 'content-type: application/json'
+  -H 'accept: application/json'
+  -d '{"id": "outline-api-NTpezNwhUP"}'
+`}
+          
+        
+ +

+ Example GET request: +

+
+          
+            {`
+curl https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP&token=API_KEY
+`}
+          
+        
+ +

Authentication

+ +

+ To access private API endpoints, you must provide a valid API key. You can create new API + keys in your account settings. Be careful when + handling your keys as they give access to all of your documents. +

+ +

+ To authenticate with Outline API, you can supply the API key as a header ( + Authorization: Bearer YOUR_API_KEY + ) or as part of the payload using token parameter. If you're making{' '} + GET requests, header based authentication is recommended so that your keys + don't leak into logs. +

+ +

+ Some API endpoints allow unauhenticated requests for public resources and they can be + called without an API key. +

+ +

Errors

+ +

+ All successful API requests will be returned with 200 status code and{' '} + ok: true in the response payload. If there's an error while making the + request, appropriate status code is returned with the error message: +

+ +
+          
+            {`
+{
+  "ok": false,
+  "error: "Not Found"
+}
+`}
+          
+        
+ +

Methods

+ + + + This method returns the information for currently logged in user. + + + + + + + + + You can upload small files and images as part of your documents. All files are stored + using Amazon S3. Instead of uploading files to Outline, you need to upload them directly + to S3 with special credentials which can be obtained through this endpoint. + + + + + + + + + + List all your document collections. + + + + + Returns detailed information on a document collection. + + + + +
+
+ ); +} + +type MethodProps = { + method: string, + label: string, + children: React.Element<*>, +}; + +const Method = (props: MethodProps) => { + const children = React.Children.toArray(props.children); + const description = children.find(child => child.type === Description); + const apiArgs = children.find(child => child.type === Arguments); + + return ( +
+

+ {props.method} - {props.label} +

+
{description}
+

Arguments

+

+ {`${process.env.URL}/api/${props.method}`} +

+ {apiArgs} +
+ ); +}; + +const Description = (props: { children: React.Element<*> }) =>

{props.children}

; +const Arguments = (props: { children: React.Element<*> }) => ( + + + + + + + + + + + {props.pagination && } + {props.children} + +
ArgumentRequiredDescription
+); +const Argument = (props: { children: React.Element<*> }) => ( + + {props.id} + {props.required ? 'required' : 'optional'} + {props.description} + +); +const PaginationArguments = () => [ + , + , +]; diff --git a/server/routes.js b/server/routes.js index 3edbf4be..b96ff7d1 100644 --- a/server/routes.js +++ b/server/routes.js @@ -12,6 +12,7 @@ import renderpage from './utils/renderpage'; import Home from './pages/Home'; import About from './pages/About'; import Pricing from './pages/Pricing'; +import Api from './pages/Api'; const isProduction = process.env.NODE_ENV === 'production'; const koa = new Koa(); @@ -46,6 +47,7 @@ if (process.env.NODE_ENV === 'production') { // static pages router.get('/about', ctx => renderpage(ctx, )); router.get('/pricing', ctx => renderpage(ctx, )); +router.get('/developers', ctx => renderpage(ctx, )); // home page router.get('/', async ctx => { From 00c214511688b86c37e13950bf93395ea936d7e3 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 13 Nov 2017 23:00:21 -0800 Subject: [PATCH 2/8] Public API docs --- server/pages/Api.js | 96 +++++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 34 deletions(-) diff --git a/server/pages/Api.js b/server/pages/Api.js index f5b580e0..3626d525 100644 --- a/server/pages/Api.js +++ b/server/pages/Api.js @@ -13,28 +13,33 @@ export default function Pricing() {

Outline API

- First thing we build for Outline was its API. It's the heart and sole of the service and - as developers, it's our mission to make the API as rich and easy to use as possible. + First thing we build for Outline was its API. It's the heart and sole + of the service and as developers, it's our mission to make the API as + rich and easy to use as possible.

- While Outline is still in public beta, we might make small adjustments, including - breaking changes to the API. + While Outline is still in public beta, we might make small + adjustments, including breaking changes to the API.

Making requests

- Outline's API follows simple RPC style conventions where each API endpoint is a method on{' '} - https://www.getoutline.com/api/<METHOD>. Both GET and{' '} - POST methods are supported but it's recommeded that you make all call using{' '} - POST. Only HTTPS is supported in production. + Outline's API follows simple RPC style conventions where each API + endpoint is a method on{' '} + https://www.getoutline.com/api/<METHOD>. Both{' '} + GET and POST methods are supported but it's + recommeded that you make all call using POST. Only HTTPS + is supported in production.

- For GET requests query string parameters are expected (e.g. - /api/document.info?id=...&token=...). When making POST requests, - request parameters are parsed depending on Content-Type header. To make a - call using JSON payload, one must pass Content-Type: application/json header: + For GET requests query string parameters are expected + (e.g. + /api/document.info?id=...&token=...). When making{' '} + POST requests, request parameters are parsed depending on{' '} + Content-Type header. To make a call using JSON payload, + one must pass Content-Type: application/json header:

@@ -67,30 +72,33 @@ curl https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP&tok

Authentication

- To access private API endpoints, you must provide a valid API key. You can create new API - keys in your account settings. Be careful when - handling your keys as they give access to all of your documents. + To access private API endpoints, you must provide a valid API key. You + can create new API keys in your{' '} + account settings. Be + careful when handling your keys as they give access to all of your + documents.

- To authenticate with Outline API, you can supply the API key as a header ( - Authorization: Bearer YOUR_API_KEY - ) or as part of the payload using token parameter. If you're making{' '} - GET requests, header based authentication is recommended so that your keys - don't leak into logs. + To authenticate with Outline API, you can supply the API key as a + header (Authorization: Bearer YOUR_API_KEY) or as part of + the payload using token parameter. If you're making{' '} + GET requests, header based authentication is recommended + so that your keys don't leak into logs.

- Some API endpoints allow unauhenticated requests for public resources and they can be - called without an API key. + Some API endpoints allow unauhenticated requests for public resources + and they can be called without an API key.

Errors

- All successful API requests will be returned with 200 status code and{' '} - ok: true in the response payload. If there's an error while making the - request, appropriate status code is returned with the error message: + All successful API requests will be returned with 200{' '} + status code and ok: true in the response payload. If + there's an error while making the request, appropriate status code is + returned with the error message:

@@ -117,24 +125,42 @@ curl https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP&tok
 
         
           
-            You can upload small files and images as part of your documents. All files are stored
-            using Amazon S3. Instead of uploading files to Outline, you need to upload them directly
-            to S3 with special credentials which can be obtained through this endpoint.
+            You can upload small files and images as part of your documents. All
+            files are stored using Amazon S3. Instead of uploading files to
+            Outline, you need to upload them directly to S3 with special
+            credentials which can be obtained through this endpoint.
           
           
-            
-            
-            
+            
+            
+            
           
         
 
-        
+        
           List all your document collections.
           
         
 
         
-          Returns detailed information on a document collection.
+          
+            Returns detailed information on a document collection.
+          
           
             
           
@@ -170,7 +196,9 @@ const Method = (props: MethodProps) => {
   );
 };
 
-const Description = (props: { children: React.Element<*> }) => 

{props.children}

; +const Description = (props: { children: React.Element<*> }) => ( +

{props.children}

+); const Arguments = (props: { children: React.Element<*> }) => ( From e82654ab7f1a99ea1bd46d5ff3cb73554a004a49 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Tue, 14 Nov 2017 00:10:50 -0800 Subject: [PATCH 3/8] Public API docs --- app/index.js | 5 - app/menus/AccountMenu.js | 17 ++- app/static/flatpages/api.md | 199 ---------------------------------- app/static/flatpages/index.js | 6 - server/pages/Api.js | 169 ++++++++++++++++++----------- 5 files changed, 113 insertions(+), 283 deletions(-) delete mode 100644 app/static/flatpages/api.md delete mode 100644 app/static/flatpages/index.js diff --git a/app/index.js b/app/index.js index d95a906e..d63fbb92 100644 --- a/app/index.js +++ b/app/index.js @@ -24,7 +24,6 @@ import Collection from 'scenes/Collection'; import Document from 'scenes/Document'; import Search from 'scenes/Search'; import SlackAuth from 'scenes/SlackAuth'; -import Flatpage from 'scenes/Flatpage'; import ErrorAuth from 'scenes/ErrorAuth'; import Error404 from 'scenes/Error404'; @@ -33,8 +32,6 @@ import ScrollToTop from 'components/ScrollToTop'; import Layout from 'components/Layout'; import RouteSidebarHidden from 'components/RouteSidebarHidden'; -import flatpages from 'static/flatpages'; - import { matchDocumentSlug } from 'utils/routeHelpers'; let DevTools; @@ -92,7 +89,6 @@ const Auth = ({ children }: AuthProps) => { }; const notFoundSearch = () => ; -const Api = () => ; const DocumentNew = () => ; const RedirectDocument = ({ match }: { match: Object }) => ( @@ -141,7 +137,6 @@ render( - diff --git a/app/menus/AccountMenu.js b/app/menus/AccountMenu.js index 1678bfa5..93969ae7 100644 --- a/app/menus/AccountMenu.js +++ b/app/menus/AccountMenu.js @@ -23,6 +23,10 @@ class AccountMenu extends Component { this.props.ui.setActiveModal('settings'); }; + handleApi = () => { + window.location.href = '/developers'; + }; + handleLogout = () => { this.props.auth.logout(); window.location.href = BASE_URL; @@ -30,19 +34,12 @@ class AccountMenu extends Component { render() { return ( - - - Settings - + + Settings Keyboard shortcuts - - API documentation - + API documentation Logout ); diff --git a/app/static/flatpages/api.md b/app/static/flatpages/api.md deleted file mode 100644 index 0edc14b6..00000000 --- a/app/static/flatpages/api.md +++ /dev/null @@ -1,199 +0,0 @@ -# Outline API - -_Our API is currently in beta and we might make minor adjustments._ - -## Making requests - -Outline's API follows JSON RPC style conventions where each API endpoint is a method on `https://www.getoutline.com/api/`. Each request needs to be made using HTTPS and both `GET` and `POST` (recommended) methods are supported. - -For `GET` requests query string parameters are expected (e.g. `/api/document.info?id=...&token=...`). When making `POST` requests, request parameters are parsed depending on `Content-Type` header. To make a call using JSON payload, one must pass `Content-Type: application/json` header: - -```shell -curl 'https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP'\ - -H 'authorization: Bearer '\ - -H 'content-type: application/json'\ - -H 'accept: application/json' -``` - -## Authentication - -To access private API endpoints, you must provide a valid API key. You can create new API keys in your [account settings](https://www.getoutline.com/settings). Be careful when handling your keys as they give access to all of your documents. - -To authenticate with Outline API, you can supply the API key as a header (`Authorization: Bearer `) or as part of the payload using `token` parameter. - -Some API endpoints allow unauhenticated requests for public resources and they can be called without an API key. - -## Errors - -All successful API requests will be returned with `200` status code and `ok: true` in the response payload. If there's an error while making the request, appropriate status code is returned with the `error` message: - -```json -{ - "ok": false, - "error: "Not Found" -} -``` - -## Methods - -### `user.info` - Get current user - -This method returns the information for currently logged in user. - -#### Arguments - -`https://www.getoutline.com/api/user.info` - -Parameter | Description ------------- | ------------- -`token` | Authentication token - ---- - -### `user.s3Upload` - Gets S3 upload credentials - -You can upload small files and images as part of your documents. All files are stored using Amazon S3. Instead of uploading files to Outline, you need to upload them directly to S3 with special credentials which can be obtained through this endpoint. - -#### Arguments - -`https://www.getoutline.com/api/user.s3Upload` - -Parameter | Description ------------- | ------------- -`token` | Authentication token -`filename` | Filename of the uploaded file -`kind` | Mimetype of the document -`size` | Filesize of the document - ---- - -### `collections.list` - List your document collections - -List all your document collections. - -#### Arguments - -`https://www.getoutline.com/api/collections.list` - -Parameter | Description ------------- | ------------- -`token` | Authentication token -`offset` | Pagination offset -`limit` | Pagination limit - ---- - -### `collections.info` - Get a document collection - -Returns detailed information on a document collection. - -#### Arguments - -`https://www.getoutline.com/api/collections.info` - -Parameter | Description ------------- | ------------- -`token` | Authentication token -`id` | Collection id - ---- - -### `collections.create` - Create a document collection - -Creates a new document collection. Outline supports two types of collections: - -- `atlas` - Structured collection with a navigation tree -- `journal` - Chronological collection of documents - -#### Arguments - -`https://www.getoutline.com/api/collections.create` - -Parameter | Description ------------- | ------------- -`token` | Authentication token -`name` | Collection name -`type` | Collection type. Allowed values: `atlas`, `journal` -`description` | _(Optional)_ Short description for the collection - ---- - -### `collections.updateNavigationTree` - Organize navigation tree - -Collection navigation can be re-organized by sending a modified version of the navigation tree. This method is available for collections with type `atlas`. - -#### Arguments - -`https://www.getoutline.com/api/collections.updateNavigationTree` - -Parameter | Description ------------- | ------------- -`token` | Authentication token -`id` | Collection id -`tree` | Modified navigation tree - ---- - -### `documents.info` - Get a document - -This method returns information for a document with a specific ID. Following identifiers are allowed: - -- UUID - `id` field of the document -- URI identifier - Human readable identifier used in Outline URLs (e.g. `outline-api-i48ZEZc5zjXndcP`) - -#### Arguments - -`https://www.getoutline.com/api/documents.info` - -Parameter | Description ------------- | ------------- -`token` | Authentication token -`id` | Document id or URI identifier - ---- - -### `documents.search` - Search documents - -This methods allows you to search all of your documents with keywords. - -#### Arguments - -`https://www.getoutline.com/api/documents.search` - -Parameter | Description ------------- | ------------- -`token` | Authentication token -`query` | Search query - ---- - -### `documents.create` - Create a new document - -This method allows you to publish a new document under an existing collection. If your collection is structured `type: atlas` collection, you can also create sub-documents for other documents with optional `parentDocument` parameter. - -#### Arguments - -`https://www.getoutline.com/api/documents.create` - -Parameter | Description ------------- | ------------- -`token` | Authentication token -`collection` | `id` of the collection to which the document is created -`title` | Title for the document -`text` | Content of the document in Markdown -`parentDocument` | _(Optional)_ `id` of the parent document within the collection - ---- - -### `documents.delete` - Delete a document - -Delete a document and all of its child documents if any. - -#### Arguments - -`https://www.getoutline.com/api/documents.delete` - -Parameter | Description ------------- | ------------- -`token` | Authentication token -`id` | Document id or URI identifier diff --git a/app/static/flatpages/index.js b/app/static/flatpages/index.js deleted file mode 100644 index 3b1fe70f..00000000 --- a/app/static/flatpages/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// @flow -import api from './api.md'; - -export default { - api, -}; diff --git a/server/pages/Api.js b/server/pages/Api.js index 3626d525..023153c4 100644 --- a/server/pages/Api.js +++ b/server/pages/Api.js @@ -2,7 +2,6 @@ import React from 'react'; import Grid from 'styled-components-grid'; import { Helmet } from 'react-helmet'; -import Flex from '../../shared/components/Flex'; export default function Pricing() { return ( @@ -13,33 +12,28 @@ export default function Pricing() {

Outline API

- First thing we build for Outline was its API. It's the heart and sole - of the service and as developers, it's our mission to make the API as - rich and easy to use as possible. + First thing we build for Outline was its API. It's the heart and sole of the service and + as developers, it's our mission to make the API as rich and easy to use as possible.

- While Outline is still in public beta, we might make small - adjustments, including breaking changes to the API. + While Outline is still in public beta, we might make small adjustments, including + breaking changes to the API.

Making requests

- Outline's API follows simple RPC style conventions where each API - endpoint is a method on{' '} - https://www.getoutline.com/api/<METHOD>. Both{' '} - GET and POST methods are supported but it's - recommeded that you make all call using POST. Only HTTPS - is supported in production. + Outline's API follows simple RPC style conventions where each API endpoint is a method on{' '} + https://www.getoutline.com/api/<METHOD>. Both GET and{' '} + POST methods are supported but it's recommeded that you make all call using{' '} + POST. Only HTTPS is supported in production.

- For GET requests query string parameters are expected - (e.g. - /api/document.info?id=...&token=...). When making{' '} - POST requests, request parameters are parsed depending on{' '} - Content-Type header. To make a call using JSON payload, - one must pass Content-Type: application/json header: + For GET requests query string parameters are expected (e.g. + /api/document.info?id=...&token=...). When making POST requests, + request parameters are parsed depending on Content-Type header. To make a + call using JSON payload, one must pass Content-Type: application/json header:

@@ -72,33 +66,30 @@ curl https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP&tok

Authentication

- To access private API endpoints, you must provide a valid API key. You - can create new API keys in your{' '} - account settings. Be - careful when handling your keys as they give access to all of your - documents. + To access private API endpoints, you must provide a valid API key. You can create new API + keys in your account settings. Be careful when + handling your keys as they give access to all of your documents.

- To authenticate with Outline API, you can supply the API key as a - header (Authorization: Bearer YOUR_API_KEY) or as part of - the payload using token parameter. If you're making{' '} - GET requests, header based authentication is recommended - so that your keys don't leak into logs. + To authenticate with Outline API, you can supply the API key as a header ( + Authorization: Bearer YOUR_API_KEY + ) or as part of the payload using token parameter. If you're making{' '} + GET requests, header based authentication is recommended so that your keys + don't leak into logs.

- Some API endpoints allow unauhenticated requests for public resources - and they can be called without an API key. + Some API endpoints allow unauhenticated requests for public resources and they can be + called without an API key.

Errors

- All successful API requests will be returned with 200{' '} - status code and ok: true in the response payload. If - there's an error while making the request, appropriate status code is - returned with the error message: + All successful API requests will be returned with 200 status code and{' '} + ok: true in the response payload. If there's an error while making the + request, appropriate status code is returned with the error message:

@@ -125,46 +116,100 @@ curl https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP&tok
 
         
           
-            You can upload small files and images as part of your documents. All
-            files are stored using Amazon S3. Instead of uploading files to
-            Outline, you need to upload them directly to S3 with special
-            credentials which can be obtained through this endpoint.
+            You can upload small files and images as part of your documents. All files are stored
+            using Amazon S3. Instead of uploading files to Outline, you need to upload them directly
+            to S3 with special credentials which can be obtained through this endpoint.
           
           
-            
-            
-            
+            
+            
+            
           
         
 
-        
+        
           List all your document collections.
           
         
 
         
-          
-            Returns detailed information on a document collection.
-          
+          Returns detailed information on a document collection.
           
             
           
         
+
+        
+          Creates a new document collection.
+          
+            
+            
+          
+        
+
+        
+          
+            

+ This method returns information for a document with a specific ID. Following + identifiers are allowed: +

+
    +
  • UUID - `id` field of the document
  • +
  • + URI identifier - Human readable identifier used in Outline URLs (e.g.{' '} + outline-api-i48ZEZc5zjXndcP) +
  • +
+
+ + + +
+ + + + This methods allows you to search all of your documents with keywords. + + + + + + + + + This method allows you to publish a new document under an existing collection. By + default a document is set to the parent collection root. If you want to create a + subdocument, you can pass parentDocument to set parent document. + + + + ID of the collection to which the document is created + + } + required + /> + + + + ID of the parent document within the collection + + } + /> + + + + + Delete a document and all of its child documents if any. + + + +
); @@ -196,9 +241,7 @@ const Method = (props: MethodProps) => { ); }; -const Description = (props: { children: React.Element<*> }) => ( -

{props.children}

-); +const Description = (props: { children: React.Element<*> }) =>

{props.children}

; const Arguments = (props: { children: React.Element<*> }) => (
From b4f7d9f61d2018a1ba00773e8d8df439a2787186 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sun, 19 Nov 2017 17:55:04 -0800 Subject: [PATCH 4/8] more docs --- server/pages/Api.js | 379 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 310 insertions(+), 69 deletions(-) diff --git a/server/pages/Api.js b/server/pages/Api.js index 023153c4..e3cb48c5 100644 --- a/server/pages/Api.js +++ b/server/pages/Api.js @@ -2,38 +2,92 @@ import React from 'react'; import Grid from 'styled-components-grid'; import { Helmet } from 'react-helmet'; +import styled from 'styled-components'; + +const Container = styled.div` + max-width: 720px; + margin: 0 auto; + + pre { + padding: 0.5em 1em; + background: #f9fbfc; + border-radius: 4px; + border: 1px solid #e8ebed; + overflow: scroll; + } + + code { + font-size: 15px; + } + + table { + border-collapse: collapse; + + thead { + td { + padding: 5px 12px 5px 0; + border-bottom: 1px solid #ddd; + vertical-align: bottom; + font-weight: 500; + } + } + + tbody, + thead { + td { + padding: 5px 12px 5px 0; + } + + td:last-child { + width: 100%; + padding-right: 0; + } + } + } + + h3 { + code { + font-size: 1.08em; + } + } +`; export default function Pricing() { return ( - Developer API + Developer API - Outline -
+

Outline API

- First thing we build for Outline was its API. It's the heart and sole of the service and - as developers, it's our mission to make the API as rich and easy to use as possible. + First thing we build for Outline was its API. It's the heart and sole + of the service and as developers, it's our mission to make the API as + rich and easy to use as possible.

- While Outline is still in public beta, we might make small adjustments, including - breaking changes to the API. + While Outline is still in public beta, we might make small + adjustments, including breaking changes to the API.

Making requests

- Outline's API follows simple RPC style conventions where each API endpoint is a method on{' '} - https://www.getoutline.com/api/<METHOD>. Both GET and{' '} - POST methods are supported but it's recommeded that you make all call using{' '} - POST. Only HTTPS is supported in production. + Outline's API follows simple RPC style conventions where each API + endpoint is a method on{' '} + https://www.getoutline.com/api/<METHOD>. Both{' '} + GET and POST methods are supported but it's + recommeded that you make all call using POST. Only HTTPS + is supported in production.

- For GET requests query string parameters are expected (e.g. - /api/document.info?id=...&token=...). When making POST requests, - request parameters are parsed depending on Content-Type header. To make a - call using JSON payload, one must pass Content-Type: application/json header: + For GET requests query string parameters are expected + (e.g. + /api/document.info?id=...&token=...). When making{' '} + POST requests, request parameters are parsed depending on{' '} + Content-Type header. To make a call using JSON payload, + one must pass Content-Type: application/json header:

@@ -41,8 +95,7 @@ export default function Pricing() {

           
-            {`
-curl https://www.getoutline.com/api/documents.info
+            {`curl https://www.getoutline.com/api/documents.info
   -X POST
   -H 'authorization: Bearer API_KEY'
   -H 'content-type: application/json'
@@ -57,8 +110,7 @@ curl https://www.getoutline.com/api/documents.info
         

           
-            {`
-curl https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP&token=API_KEY
+            {`curl https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP&token=API_KEY
 `}
           
         
@@ -66,36 +118,38 @@ curl https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP&tok

Authentication

- To access private API endpoints, you must provide a valid API key. You can create new API - keys in your account settings. Be careful when - handling your keys as they give access to all of your documents. + To access private API endpoints, you must provide a valid API key. You + can create new API keys in your{' '} + account settings. Be + careful when handling your keys as they give access to all of your + documents.

- To authenticate with Outline API, you can supply the API key as a header ( - Authorization: Bearer YOUR_API_KEY - ) or as part of the payload using token parameter. If you're making{' '} - GET requests, header based authentication is recommended so that your keys - don't leak into logs. + To authenticate with Outline API, you can supply the API key as a + header (Authorization: Bearer YOUR_API_KEY) or as part of + the payload using token parameter. If you're making{' '} + GET requests, header based authentication is recommended + so that your keys don't leak into logs.

- Some API endpoints allow unauhenticated requests for public resources and they can be - called without an API key. + Some API endpoints allow unauhenticated requests for public resources + and they can be called without an API key.

Errors

- All successful API requests will be returned with 200 status code and{' '} - ok: true in the response payload. If there's an error while making the - request, appropriate status code is returned with the error message: + All successful API requests will be returned with 200{' '} + status code and ok: true in the response payload. If + there's an error while making the request, appropriate status code is + returned with the error message:

           
-            {`
-{
+            {`{
   "ok": false,
   "error: "Not Found"
 }
@@ -116,59 +170,90 @@ curl https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP&tok
 
         
           
-            You can upload small files and images as part of your documents. All files are stored
-            using Amazon S3. Instead of uploading files to Outline, you need to upload them directly
-            to S3 with special credentials which can be obtained through this endpoint.
+            You can upload small files and images as part of your documents. All
+            files are stored using Amazon S3. Instead of uploading files to
+            Outline, you need to upload them directly to S3 with special
+            credentials which can be obtained through this endpoint.
           
           
-            
-            
-            
+            
+            
+            
           
         
 
-        
+        
           List all your document collections.
           
         
 
         
-          Returns detailed information on a document collection.
+          
+            Returns detailed information on a document collection.
+          
           
             
           
         
 
-        
+        
           Creates a new document collection.
           
             
-            
+            
           
         
 
         
           
             

- This method returns information for a document with a specific ID. Following - identifiers are allowed: + This method returns information for a document with a specific ID. + Following identifiers are allowed:

    -
  • UUID - `id` field of the document
  • - URI identifier - Human readable identifier used in Outline URLs (e.g.{' '} - outline-api-i48ZEZc5zjXndcP) + UUID - id field of the document +
  • +
  • + URI identifier - Human readable identifier used in Outline URLs + (e.g. outline-api-i48ZEZc5zjXndcP)
- +
- This methods allows you to search all of your documents with keywords. + This methods allows you to search all of your documents with + keywords. @@ -177,22 +262,32 @@ curl https://www.getoutline.com/api/documents.info?id=outline-api-NTpezNwhUP&tok - This method allows you to publish a new document under an existing collection. By - default a document is set to the parent collection root. If you want to create a - subdocument, you can pass parentDocument to set parent document. + This method allows you to publish a new document under an existing + collection. By default a document is set to the parent collection + root. If you want to create a subdocument, you can pass{' '} + parentDocument to set parent document. - ID of the collection to which the document is created + ID of the collection to which the document is + created } required /> - - + + - - Delete a document and all of its child documents if any. + + + This method allows you to modify already created document. + - + + + -
+ + + + Move a document into a new location inside the collection. This is + easily done by defining the parent document ID and optional index. + If no parent document is provided, the document will be moved to the + collection root. + + + + + + + + + + + Delete a document and all of its child documents if any. + + + + + + + + + Get a document with its ID or URL identifier from user's + collections. + + + + + + + + + Star (favorite) a document for authenticated user. + + + + + + + + + Unstar as starred (favorited) a document for authenticated user. + + + + + + + + + Return recently viewed documents for the authenticated user + + + + + + + Return recently starred documents for the authenticated user + + + + + + + Return revisions for a document. Upon each edit, a new revision is + stored. + + + +
); } +const MethodContainer = styled.div` + margin-bottom: 40px; +`; + +const Request = styled.h4` + text-transform: capitalize; +`; + type MethodProps = { method: string, label: string, @@ -227,22 +446,30 @@ const Method = (props: MethodProps) => { const apiArgs = children.find(child => child.type === Arguments); return ( -
+

{props.method} - {props.label}

{description}
-

Arguments

+ HTTP request & arguments

{`${process.env.URL}/api/${props.method}`}

{apiArgs} -
+ ); }; -const Description = (props: { children: React.Element<*> }) =>

{props.children}

; -const Arguments = (props: { children: React.Element<*> }) => ( +const Description = (props: { children: React.Element<*> }) => ( +

{props.children}

+); + +type ArgumentsProps = { + pagination?: boolean, + children?: React.Element<*> | string, +}; + +const Arguments = (props: ArgumentsProps) => (
@@ -253,15 +480,29 @@ const Arguments = (props: { children: React.Element<*> }) => ( - {props.pagination && } + {props.pagination && ( + // $FlowIssue + + )} {props.children}
); -const Argument = (props: { children: React.Element<*> }) => ( + +type ArgumentProps = { + id: string, + required?: boolean, + description: React.Element<*> | string, +}; + +const Argument = (props: ArgumentProps) => ( - {props.id} - {props.required ? 'required' : 'optional'} + + {props.id} + + + {props.required ? 'required' : 'optional'} + {props.description} ); From 116149c9f8de5dfdbb5715948ebf607710e35653 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sun, 19 Nov 2017 18:05:35 -0800 Subject: [PATCH 5/8] fixes --- app/menus/AccountMenu.js | 15 +++++++++++---- app/scenes/Flatpage/Flatpage.js | 32 -------------------------------- app/scenes/Flatpage/index.js | 3 --- server/pages/Api.js | 12 ++++++------ 4 files changed, 17 insertions(+), 45 deletions(-) delete mode 100644 app/scenes/Flatpage/Flatpage.js delete mode 100644 app/scenes/Flatpage/index.js diff --git a/app/menus/AccountMenu.js b/app/menus/AccountMenu.js index 93969ae7..64903907 100644 --- a/app/menus/AccountMenu.js +++ b/app/menus/AccountMenu.js @@ -1,6 +1,6 @@ // @flow import React, { Component } from 'react'; -import { Link, withRouter } from 'react-router-dom'; +import { withRouter } from 'react-router-dom'; import { inject, observer } from 'mobx-react'; import UiStore from 'stores/UiStore'; import AuthStore from 'stores/AuthStore'; @@ -34,12 +34,19 @@ class AccountMenu extends Component { render() { return ( - - Settings + + + Settings + Keyboard shortcuts - API documentation + + API documentation + Logout ); diff --git a/app/scenes/Flatpage/Flatpage.js b/app/scenes/Flatpage/Flatpage.js deleted file mode 100644 index 58bff50e..00000000 --- a/app/scenes/Flatpage/Flatpage.js +++ /dev/null @@ -1,32 +0,0 @@ -// @flow -import React from 'react'; -import { observer } from 'mobx-react'; -import CenteredContent from 'components/CenteredContent'; -import Editor from 'components/Editor'; -import PageTitle from 'components/PageTitle'; - -type Props = { - title: string, - content: string, -}; - -const Flatpage = observer((props: Props) => { - const { title, content } = props; - - return ( - - - {}} - onSave={() => {}} - onCancel={() => {}} - onImageUploadStart={() => {}} - onImageUploadStop={() => {}} - readOnly - /> - - ); -}); - -export default Flatpage; diff --git a/app/scenes/Flatpage/index.js b/app/scenes/Flatpage/index.js deleted file mode 100644 index 55cdbb81..00000000 --- a/app/scenes/Flatpage/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Flatpage from './Flatpage'; -export default Flatpage; diff --git a/server/pages/Api.js b/server/pages/Api.js index e3cb48c5..085b6e19 100644 --- a/server/pages/Api.js +++ b/server/pages/Api.js @@ -61,8 +61,8 @@ export default function Pricing() {

Outline API

- First thing we build for Outline was its API. It's the heart and sole - of the service and as developers, it's our mission to make the API as + First thing we build for Outline was its API. It’s the heart and sole + of the service and as developers, it’s our mission to make the API as rich and easy to use as possible.

@@ -73,10 +73,10 @@ export default function Pricing() {

Making requests

- Outline's API follows simple RPC style conventions where each API + Outline’s API follows simple RPC style conventions where each API endpoint is a method on{' '} https://www.getoutline.com/api/<METHOD>. Both{' '} - GET and POST methods are supported but it's + GET and POST methods are supported but it’s recommeded that you make all call using POST. Only HTTPS is supported in production.

@@ -143,7 +143,7 @@ export default function Pricing() {

All successful API requests will be returned with 200{' '} status code and ok: true in the response payload. If - there's an error while making the request, appropriate status code is + there’s an error while making the request, appropriate status code is returned with the error message:

@@ -353,7 +353,7 @@ export default function Pricing() { - Get a document with its ID or URL identifier from user's + Get a document with its ID or URL identifier from user’s collections. From 200f7039c952489cad29323606fd575e8276ffd8 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sun, 19 Nov 2017 18:41:36 -0800 Subject: [PATCH 6/8] more endpoints --- server/pages/Api.js | 543 ++++++++++++++++++++++++-------------------- 1 file changed, 295 insertions(+), 248 deletions(-) diff --git a/server/pages/Api.js b/server/pages/Api.js index 085b6e19..ec405030 100644 --- a/server/pages/Api.js +++ b/server/pages/Api.js @@ -158,276 +158,323 @@ export default function Pricing() {

Methods

+ + + + This method returns the information for currently logged in user. + + + + + - - - This method returns the information for currently logged in user. - - - - - + + + You can upload small files and images as part of your documents. + All files are stored using Amazon S3. Instead of uploading files + to Outline, you need to upload them directly to S3 with special + credentials which can be obtained through this endpoint. + + + + + + + - - - You can upload small files and images as part of your documents. All - files are stored using Amazon S3. Instead of uploading files to - Outline, you need to upload them directly to S3 with special - credentials which can be obtained through this endpoint. - - - - - - - + + List all your document collections. + + - - List all your document collections. - - + + + Returns detailed information on a document collection. + + + + + - - - Returns detailed information on a document collection. - - - - - + + Creates a new document collection. + + + + + - - Creates a new document collection. - - - - - + + + This method allows you to modify already created document. + + + + + + + - - -

- This method returns information for a document with a specific ID. - Following identifiers are allowed: -

-
    -
  • - UUID - id field of the document -
  • -
  • - URI identifier - Human readable identifier used in Outline URLs - (e.g. outline-api-i48ZEZc5zjXndcP) -
  • -
-
- - - -
+ + + Delete a collection and all of its documents. This action can't be + undone so please be careful. + + + + + - - - This methods allows you to search all of your documents with - keywords. - - - - - + + +

+ This method returns information for a document with a specific + ID. Following identifiers are allowed: +

+
    +
  • + UUID - id field of the document +
  • +
  • + URI identifier - Human readable identifier used in Outline + URLs (e.g. outline-api-i48ZEZc5zjXndcP) +
  • +
+
+ + + +
- - - This method allows you to publish a new document under an existing - collection. By default a document is set to the parent collection - root. If you want to create a subdocument, you can pass{' '} - parentDocument to set parent document. - - - - ID of the collection to which the document is - created - - } - required - /> - - - - ID of the parent document within the collection - - } - /> - - + + + This methods allows you to search all of your documents with + keywords. + + + + + - - - This method allows you to modify already created document. - - - - - - - + + + This method allows you to publish a new document under an existing + collection. By default a document is set to the parent collection + root. If you want to create a subdocument, you can pass{' '} + parentDocument to set parent document. + + + + ID of the collection to which the document is + created + + } + required + /> + + + + ID of the parent document within the collection + + } + /> + + - - - Move a document into a new location inside the collection. This is - easily done by defining the parent document ID and optional index. - If no parent document is provided, the document will be moved to the - collection root. - - - - - - - + + + This method allows you to modify already created document. + + + + + + + - - - Delete a document and all of its child documents if any. - - - - - + + + Move a document into a new location inside the collection. This is + easily done by defining the parent document ID and optional index. + If no parent document is provided, the document will be moved to + the collection root. + + + + + + + - - - Get a document with its ID or URL identifier from user’s - collections. - - - - - + + + Delete a document and all of its child documents if any. + + + + + - - - Star (favorite) a document for authenticated user. - - - - - + + + Get a document with its ID or URL identifier from user’s + collections. + + + + + - - - Unstar as starred (favorited) a document for authenticated user. - - - - - + + + Star (favorite) a document for authenticated user. + + + + + - - - Return recently viewed documents for the authenticated user - - - + + + Unstar as starred (favorited) a document for authenticated user. + + + + + - - - Return recently starred documents for the authenticated user - - - + + + Return recently viewed documents for the authenticated user + + + - - - Return revisions for a document. Upon each edit, a new revision is - stored. - - - + + + Return recently starred documents for the authenticated user + + + + + + + Return revisions for a document. Upon each edit, a new revision is + stored. + + + +
); } +const MethodList = styled.ul` + margin-bottom: 80px; +`; + +const Methods = (props: { children: React.Element<*> }) => { + const children = React.Children.toArray(props.children); + const methods = children.map(child => child.props.method); + + return ( +
+ + {methods.map(method => ( +
  • + {method} +
  • + ))} +
    + {children} +
    + ); +}; + const MethodContainer = styled.div` - margin-bottom: 40px; + margin-bottom: 80px; `; const Request = styled.h4` @@ -447,7 +494,7 @@ const Method = (props: MethodProps) => { return ( -

    +

    {props.method} - {props.label}

    {description}
    From 1e9669cbc04b9bfc9fa06d8f9282277b53f6eee1 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sun, 19 Nov 2017 18:43:21 -0800 Subject: [PATCH 7/8] tick --- server/pages/Api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/pages/Api.js b/server/pages/Api.js index ec405030..d7fc00f7 100644 --- a/server/pages/Api.js +++ b/server/pages/Api.js @@ -241,7 +241,7 @@ export default function Pricing() { - Delete a collection and all of its documents. This action can't be + Delete a collection and all of its documents. This action can`t be undone so please be careful. From 2adaa9424aa52c002329196168805419e484b069 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sun, 19 Nov 2017 18:47:20 -0800 Subject: [PATCH 8/8] typo --- server/pages/Api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/pages/Api.js b/server/pages/Api.js index d7fc00f7..e41b9b52 100644 --- a/server/pages/Api.js +++ b/server/pages/Api.js @@ -61,7 +61,7 @@ export default function Pricing() {

    Outline API

    - First thing we build for Outline was its API. It’s the heart and sole + First thing we build for Outline was its API. It’s the heart and soul of the service and as developers, it’s our mission to make the API as rich and easy to use as possible.