From 6e873a0778dabb5d580b029c3d21d612e1ec0b1b Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sat, 13 May 2017 18:55:48 -0500 Subject: [PATCH] add documentation for /api/key --- app/api.rb | 2 +- views/api.erb | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/api.rb b/app/api.rb index d3370fa4..18036eba 100644 --- a/app/api.rb +++ b/app/api.rb @@ -202,7 +202,7 @@ def api_error(status, error_type, message) end def api_error_invalid_auth - api_error 403, 'invalid_auth', 'invalid credentials - please check your username and password' + api_error 403, 'invalid_auth', 'invalid credentials - please check your username and password (or your api key)' end def api_not_found diff --git a/views/api.erb b/views/api.erb index e93dcc5f..d0a25451 100644 --- a/views/api.erb +++ b/views/api.erb @@ -177,6 +177,29 @@ var api = new neocities('YOURUSERNAME', 'YOURPASSWORD') api.info('madamfrp', function(resp) { console.log(resp) }) + + + +

GET /api/key

+

+ Returns an API key that you can use for the API instead of login credentials. + It will automatically generate a new API key if one doesn't exist yet for your site. +

+

Examples

+
Using cURL
+
$ curl "https://USER:PASS@neocities.org/api/key"
+{
+  "result": "success",
+  "api_key": "da77c3530c30593663bf7b797323e48c"
+}
+ +

Using the api key for requests:

+ +
$ curl -H "Authorization: Bearer da77c3530c30593663bf7b797323e48c" \
+https://neocities.org/api/info
+

Need something the API doesn't provide?

-

If the API does not supply something you need, contact us and we will try to add it! +

+ If the API does not supply something you need, contact us and we will try to add it! +