From cc6bc08706dcbc657b76ddb07ee1c4bdb6107249 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 27 Feb 2023 19:28:09 -0800 Subject: api docs --- src/routes/(static)/+layout.server.js | 16 +++++++ src/routes/(static)/+layout.svelte | 6 ++- src/routes/(static)/docs/+page.server.js | 4 ++ src/routes/(static)/docs/+page.svelte | 81 +++++++++++++++++++++++++------- 4 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 src/routes/(static)/+layout.server.js create mode 100644 src/routes/(static)/docs/+page.server.js (limited to 'src/routes/(static)') diff --git a/src/routes/(static)/+layout.server.js b/src/routes/(static)/+layout.server.js new file mode 100644 index 00000000..2deeebc5 --- /dev/null +++ b/src/routes/(static)/+layout.server.js @@ -0,0 +1,16 @@ +import { get, post, auth, protectedRoutes } from '$lib/utils'; + +export async function load({ cookies, request, url, params }) { + let token = cookies.get('token'); + let rate, + rates = { USD: 1 }; + + let user; + if (token) { + try { + user = await get('/me', auth(cookies)); + } catch (e) {} + } + + return { user }; +} diff --git a/src/routes/(static)/+layout.svelte b/src/routes/(static)/+layout.svelte index 6e31f17e..3d596dff 100644 --- a/src/routes/(static)/+layout.svelte +++ b/src/routes/(static)/+layout.svelte @@ -1,8 +1,12 @@ - + +
diff --git a/src/routes/(static)/docs/+page.server.js b/src/routes/(static)/docs/+page.server.js new file mode 100644 index 00000000..e80365fa --- /dev/null +++ b/src/routes/(static)/docs/+page.server.js @@ -0,0 +1,4 @@ +export let load = async ({ cookies }) => { + let token = cookies.get('token'); + return { token }; +}; diff --git a/src/routes/(static)/docs/+page.svelte b/src/routes/(static)/docs/+page.svelte index c634cd76..d44204d8 100644 --- a/src/routes/(static)/docs/+page.svelte +++ b/src/routes/(static)/docs/+page.svelte @@ -1,17 +1,67 @@ -Coming soon - - - - - - - - - - - - - + + +
+

API Documentation

+ +

+ Coinos has a simple REST API that can be used to register accounts, fetch data, and make + payments +

+ +

* = required parameter

+ +

Base URL

+
+
https://coinos.io/api
+
+
+ +

Auth Token

+

This JWT authorizes you to use the API

+
+
export token="{token}"
+
+
+ +

POST /register

+

Register a new user account with a username and password

+ + +

POST /login

+

Login to an account to get its auth token

+ + +

POST /invoice

+

Create an invoice.

+
+
+ type: bitcoin or lightning +
+
+ amount: integer satoshis (optional) +
+
+ webhook: a URL that we'll POST to when the invoice is + paid (optional) +
+
+ secret: a secret to send with the POST (optional) +
+
+ + + +

GET /invoice/:hash

+

+ Fetch an invoice by passing a bitcoin address or lightning payment hash +

+ +
+ @@ -73,5 +123,4 @@ Coming soon - - + -- cgit v1.2.3