diff --git a/views/api.erb b/views/api.erb index fcd482f4..96d3d110 100644 --- a/views/api.erb +++ b/views/api.erb @@ -45,27 +45,17 @@
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
- This example uses the neocities module, which works for node.js and web browsers (via browserify). You can install it by running npm install neocities --global in your terminal.
+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') -api.uploadFiles([{ - name: 'newfileonsite.html' - path: './local.html' -}], function(resp) { - if(resp.result == 'error') - throw new Error(resp.error_type+' - '+resp.message) - - // Display response from API +api.upload([ + {name: 'hello.html', path: './local.html'} +], function(resp) { console.log(resp) })- -
- -
@@ -84,6 +74,14 @@ api.uploadFiles([{
curl -d "filenames[]=img1.jpg" -d "filenames[]=img2.jpg" \
https://YOURUSER:YOURPASS@neocities.org/api/delete
+
+var NeoCities = require('neocities') +var api = new NeoCities('YOURUSERNAME', 'YOURPASSWORD') + +api.delete(['img1.jpg', 'img2.jpg'], function(resp) { + console.log(resp) +})
This call lets you retreive information about a web site. This call does not require site authorization if you provide a sitename argument. Note that the sitename is the same as a username. If you provide auth credentials, you will receive the info for the auth user's site. Dates conform to RFC2822 format, and there are helpers for parsing it into a time object for most programming languages. @@ -103,8 +101,28 @@ $ curl https://neocities.org/api/info?sitename=youpi "tags": [] } } - +
Getting your own site's info:
$ curl https://YOURUSER:YOURPASS@neocities.org/api/info
+ Your site:
++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') + +api.info('madamfrp', function(resp) { + console.log(resp) +})