diff --git a/server/pages/Api.js b/server/pages/Api.js index 023153c41..e3cb48c52 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} );