Skip to content

thatcomputerguy0101/neocities-node-extended

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Neocities-Extended Node.js Client Library

A node.js library for interacting with the Neocities api that actually has more capabilities than the original api itself.

Installation

WARNING - This module is not yet on NPM; the following command will not work

$ npm install neocities-extended

Instead, clone this repository where you want it to be installed, and reference the folder directly in the require statement.

Usage

First, require the library and initialize:

var Neocities = require('neocities-extended') // or reference to the folder
var api = new Neocities('YOURUSERNAME', 'YOURPASSWORD')

Uploading files to your site

// local file path is ./index.js, saved on site as derp.js

api.upload([
  {name: 'derp.js', path: './index.js'}
           ], function(resp) {
  console.log(resp)
})

Downloading files from your site

// site path is derp.js, saved on client as index.js

api.download([
    {name: 'derp.js', path: 'index.js'}
             ], function(resp) {
    console.log(resp)
})

Deleting files from your site

api.delete(['derp.js'], function(resp) {
  console.log(resp)
})

List the files on your site

api.list('dirname', function(resp) {
    console.log(resp)
})

Get site info (hits, et cetera)

api.info(function(resp) {
  console.log(resp)
})
api.info('youpi', function(resp) {
  console.log(resp)
})

Use an API Key

The API key is a more secure way to upload data, since it doesn't store or send your username or password. First, Log in normally with a callback for the key option. (This then uses the key once it is aquired instead of your username and password.)

var api = new Neocities('YOURUSERNAME', 'YOURPASSWORD', {key: function(key) {/* store your key here */}})

Then, use the key instead of the username or password the next time you log in.

var api = new Neocities('YOURAPIKEY')

Pushing a folder

// foo is the local folder, images is what it will be named on your site
// hidden.json is not uploaded, nor any file ending with .conf.json

api.push('foo/', 'images/', ['hidden.json', /\.conf\.json$/])

Pulling a folder

Similar to download, but for folders

// same argument syntax as push

api.pull('foo/', 'images', ['site.png'])

About

Extended library for the Neocities.org API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%