diff --git a/views/api.erb b/views/api.erb index 9f212f88..e93dcc5f 100644 --- a/views/api.erb +++ b/views/api.erb @@ -53,19 +53,18 @@

Examples

Using cURL

Upload a single local file (local.html), which will be named hello.html on your site:

- $ curl -F hello.html=@local.html https://USER:PASS@neocities.org/api/upload +
$ curl -F "hello.html=@local.html" "https://USER:PASS@neocities.org/api/upload"
Using Node.js

This example uses the neocities module. You can install it by running npm install neocities --global in your terminal.

-
-var NeoCities = require('neocities')
-var api = new NeoCities('YOURUSERNAME', 'YOURPASSWORD')
+  
var neocities = require('neocities')
+var api = new neocities('YOURUSERNAME', 'YOURPASSWORD')
 
 api.upload([
   {name: 'hello.html', path: './local.html'}
 ], function(resp) {
   console.log(resp)
-})
+})

POST /api/delete

@@ -80,26 +79,22 @@ api.upload([

Delete img1.jpg and img2.jpg from your site:

- - curl -d "filenames[]=img1.jpg" -d "filenames[]=img2.jpg" \
https://YOURUSER:YOURPASS@neocities.org/api/delete -
+
curl -d "filenames[]=img1.jpg" -d "filenames[]=img2.jpg" \
"https://YOURUSER:YOURPASS@neocities.org/api/delete"
Using Node.js
-
-var NeoCities = require('neocities')
-var api = new NeoCities('YOURUSERNAME', 'YOURPASSWORD')
+  
var neocities = require('neocities')
+var api = new neocities('YOURUSERNAME', 'YOURPASSWORD')
 
 api.delete(['img1.jpg', 'img2.jpg'], function(resp) {
   console.log(resp)
-})
+})

GET /api/list

This call provides a list of files for your site. If you pass no arguments, it will return a list of all files. If you provide a path argument, it will return a list of files for the path. Dates conform to RFC2822.

Examples

Using cURL
-
-$ curl https://USER:PASS@neocities.org/api/list
+  
$ curl "https://USER:PASS@neocities.org/api/list"
 {
   "result": "success",
   "files": [
@@ -128,10 +123,9 @@ $ curl https://USER:PASS@neocities.org/api/list
     }
   ]
 }
-
+
-
-$ curl "https://USER:PASS@neocities.org/api/list?path=images"
+
$ curl "https://USER:PASS@neocities.org/api/list?path=images"
 {
   "result": "success",
   "files": [
@@ -143,7 +137,7 @@ $ curl "https://USER:PASS@neocities.org/api/list?path=images"
     }
   ]
 }
-
+

GET /api/info

@@ -151,8 +145,7 @@ $ curl "https://USER:PASS@neocities.org/api/list?path=images"

Examples

Using cURL
-
-$ curl https://neocities.org/api/info?sitename=youpi
+  
$ curl "https://neocities.org/api/info?sitename=youpi"
 {
   "result": "success",
   "info": {
@@ -163,31 +156,27 @@ $ curl https://neocities.org/api/info?sitename=youpi
     "domain": null,
     "tags": []
   }
-}
+}

Getting your own site's info:

- - $ curl https://YOURUSER:YOURPASS@neocities.org/api/info - +
$ curl "https://YOURUSER:YOURPASS@neocities.org/api/info"
Using Node.js

Your site:

-
-var NeoCities = require('neocities')
-var api = new NeoCities('YOURUSERNAME', 'YOURPASSWORD')
+  
var neocities = require('neocities')
+var api = new neocities('YOURUSERNAME', 'YOURPASSWORD')
 
 api.info(function(resp) {
   console.log(resp)
-})
+})

Getting data for a different site - such as the Madam FRP Manual:

-
-var NeoCities = require('neocities')
-var api = new NeoCities('YOURUSERNAME', 'YOURPASSWORD')
+  
var neocities = require('neocities')
+var api = new neocities('YOURUSERNAME', 'YOURPASSWORD')
 
 api.info('madamfrp', function(resp) {
   console.log(resp)
-})
+})

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!